From patchwork Mon Jul 12 06:10:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 472982 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2683930jao; Mon, 12 Jul 2021 00:24:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzD1C9X5Wpu8bxFLCGT7b7cxZoLVHkyDBtUOe8rkvKHpyxdTcOhiI8ymXup8wqFWGcVyDB5 X-Received: by 2002:a05:6402:216:: with SMTP id t22mr62399771edv.70.1626074592526; Mon, 12 Jul 2021 00:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626074592; cv=none; d=google.com; s=arc-20160816; b=h5uwloiWCJT0OLL9WCM/ab3BOVwYypQFUKjB3kprhC73VuXjENs80BxTWEUdfz9ern YB/vSzi1DIjn8PRaJJKNYPOFZNqYl+2iADq3giLwiy8AzWHqFJq2Qa4ruFm7+8mzgpYe kZT7+yPDw+caTVex05feQlhy9qOG+Q8FGafH5jRTxkce1qkZAfF6/Tv/xW3p3414oFK1 HvgH9qj6Nu/GM0kY1QS+wV3d+xeAO/eMPPX2i6ouJcWoKXgpIYEYbsG8EUgGeNQ1SLAP Mt/oZ3Jy+4UZHhkIqixGF51QwCG3DWWcefzxyTg75OGv7GyG+ovOMsROZMVzVuhEgGmR AOew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HYTa6UCTAFDmanzvXee0dNMV4Y/UbsJUpGB8gyZ8+Iw=; b=KWPGirP01JJJvxz3Y+1qt5cbbPDmEZTTQa4bmlkkvvDudz9N7w2NRuEW55wN+hKRP2 inSz11vgO+v6g8iZDsTNe8OTcFYgd8CD45PVtGKTG1EbVwHFaV7wJa5PhGq8X8BRTOMj z1h5a1tXtt7G/iLA4rxErm88rlGnyh3YC9p2W7NSjDRfoUPv9rZGgHJ6ITRZgKAs/fcx /M3x7Bloz/mLJBkIY15pQhXVwVCvln/IgaFO8V16hMdUviSKge9u7s5pzX1DKJtooWlT zocHvVOVD7DuliipfgcO1TIdpEZLttX7Jwm08sHlYGKA8sIbo+tLRKLMBR1sW5RhdMJl FRxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x04LR6AE; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d9si16909677edq.169.2021.07.12.00.23.12; Mon, 12 Jul 2021 00:23:12 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x04LR6AE; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241537AbhGLHXY (ORCPT + 12 others); Mon, 12 Jul 2021 03:23:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:59578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344921AbhGLHVg (ORCPT ); Mon, 12 Jul 2021 03:21:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EF76A611ED; Mon, 12 Jul 2021 07:18:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626074328; bh=I5p2o2CF+1CWKnG1I811kITf9YGmJq55t3a7Rr4VvdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x04LR6AEUdEIEvuJ8RiE/r08tJ5shKB1SOJm1rIrVRAfWgrLMd1Vt5ttV379kGsPX bLU8mSi25DSnsPgx+MqeD0z/yHOZi6/pS8QrVMDuV0S1T6NFK48e9rqZa5ibTccHGc lQ5rnw6dDaV9l09ZdMQnP8ZVuexO8onumpOS3pG8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Matt Ranostay , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.12 544/700] iio: prox: pulsed-light: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:27 +0200 Message-Id: <20210712061034.217581019@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jonathan Cameron [ Upstream commit 679cc377a03ff1944491eafc7355c1eb1fad4109 ] To make code more readable, use a structure to express the channel layout and ensure the timestamp is 8 byte aligned. Found during an audit of all calls of uses of iio_push_to_buffers_with_timestamp() Fixes: cb119d535083 ("iio: proximity: add support for PulsedLight LIDAR") Signed-off-by: Jonathan Cameron Cc: Matt Ranostay Acked-by: Matt Ranostay Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-14-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.30.2 diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c index cc206bfa09c7..d854b8d5fbba 100644 --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c @@ -44,7 +44,11 @@ struct lidar_data { int (*xfer)(struct lidar_data *data, u8 reg, u8 *val, int len); int i2c_enabled; - u16 buffer[8]; /* 2 byte distance + 8 byte timestamp */ + /* Ensure timestamp is naturally aligned */ + struct { + u16 chan; + s64 timestamp __aligned(8); + } scan; }; static const struct iio_chan_spec lidar_channels[] = { @@ -230,9 +234,9 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private) struct lidar_data *data = iio_priv(indio_dev); int ret; - ret = lidar_get_measurement(data, data->buffer); + ret = lidar_get_measurement(data, &data->scan.chan); if (!ret) { - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, iio_get_time_ns(indio_dev)); } else if (ret != -EINVAL) { dev_err(&data->client->dev, "cannot read LIDAR measurement");