From patchwork Mon Jul 19 14:50:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 479901 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4226235jao; Mon, 19 Jul 2021 08:22:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiZaf3JwEyWgG59wdvqhbZY8Rcn0wlJA7EzY9jt6hFdyy+7kpYeiPDDOl6HaiSBVBBZeCO X-Received: by 2002:a05:6402:3507:: with SMTP id b7mr35581175edd.254.1626708137147; Mon, 19 Jul 2021 08:22:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626708137; cv=none; d=google.com; s=arc-20160816; b=DdUqEbYj95YJUCl9nzyO5SVxdRz03AIBkORdfCVa5Ld8KvpY8tUb2V2C7S3DEzIbku DFfBiIc3tkh2JUC7L2L9whYpKfJMKmFXfpc9yrzN7R5BXF859ZbVrVzlRMrkVPXw5PZa Z/bY0QwnFmwUEQPwUuR4+vpF9Sg/lLn341eJHDybRRrdNmvERBZfF8QO9Eg2p7/dFQu4 t8yFMYNu8xq2HAb0O+hhwuar9AFaKKZHy1uSdGJEGaKMAKKpSkc+IPFod/E8O51abHvh Vlkvd8dMm1bKoVfF1YwdxL2gdSflgpF0rLZvsnhcmZzrKNMm7p9OGnqMh5QQX6F5IG6y 3DKA== 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=Qi+8paDPQNp5TjNf1hPKijw4K3giD7tBbb4qhIMbT2I=; b=wT0F8G/+n+wf3ULv3CU3jiluixG1MOv5Vo8RQgBgBtoknfo15Ci+b9FmGhmrjX2h/C XzEQ39uf/wZ8JZYvU7v+HU9eVAQVl1c6SHGVOXTC9kJolujw4leMUjjuS9GHhynVqVax EJeHtoxgQr7J8ohhDt70Rk7gmBy6Lg84ov/TYxa7WQZlXB+6JJqvgaXv3Gz0UB2yPPEU jrLpaYc/OKLWQsj1hwV+/iaWi/CWNnGhnblD4NM+3uVnpmBHl8H0sclJLmMQIxLd9/sX SHfm2+dUHReOydxKjzkcTd8zys+oGOyNdEnkJevr6a0xlX2QKEw5tZ6nbxX2HuqD+/qM W0aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="K7lfL/Zo"; 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 l3si24719878ejo.634.2021.07.19.08.22.16; Mon, 19 Jul 2021 08:22:17 -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="K7lfL/Zo"; 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 S242896AbhGSOlY (ORCPT + 12 others); Mon, 19 Jul 2021 10:41:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:53816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343735AbhGSOjk (ORCPT ); Mon, 19 Jul 2021 10:39:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C3D3E60FE4; Mon, 19 Jul 2021 15:19:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707975; bh=+mPVfOcxAxvOn4g1UTVHi39fRgRmaymEHJL+MrSZeuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K7lfL/Zo/DFWiuHpwJkPSJdQPF82hovS/FieQefUk+SgTw89yGzEm5hF926O/62tk lE08gEv7nd4YgZIv2a9eyVnPughi4E/dSOCdXREAoquBE6l2dF4C93PsF13Hc4r1pf 9ngpQwz3cj6B6QVw40N0l3TSpXpWzUuW7obqV768= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Andy Shevchenko , Sasha Levin Subject: [PATCH 4.14 130/315] iio: humidity: am2315: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 19 Jul 2021 16:50:19 +0200 Message-Id: <20210719144947.160293340@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144942.861561397@linuxfoundation.org> References: <20210719144942.861561397@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 f4ca2e2595d9fee65d5ce0d218b22ce00e5b2915 ] 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: 0d96d5ead3f7 ("iio: humidity: Add triggered buffer support for AM2315") Signed-off-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-12-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/humidity/am2315.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) -- 2.30.2 diff --git a/drivers/iio/humidity/am2315.c b/drivers/iio/humidity/am2315.c index ff96b6d0fdae..77513fd84b99 100644 --- a/drivers/iio/humidity/am2315.c +++ b/drivers/iio/humidity/am2315.c @@ -36,7 +36,11 @@ struct am2315_data { struct i2c_client *client; struct mutex lock; - s16 buffer[8]; /* 2x16-bit channels + 2x16 padding + 4x16 timestamp */ + /* Ensure timestamp is naturally aligned */ + struct { + s16 chans[2]; + s64 timestamp __aligned(8); + } scan; }; struct am2315_sensor_data { @@ -170,20 +174,20 @@ static irqreturn_t am2315_trigger_handler(int irq, void *p) mutex_lock(&data->lock); if (*(indio_dev->active_scan_mask) == AM2315_ALL_CHANNEL_MASK) { - data->buffer[0] = sensor_data.hum_data; - data->buffer[1] = sensor_data.temp_data; + data->scan.chans[0] = sensor_data.hum_data; + data->scan.chans[1] = sensor_data.temp_data; } else { i = 0; for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength) { - data->buffer[i] = (bit ? sensor_data.temp_data : - sensor_data.hum_data); + data->scan.chans[i] = (bit ? sensor_data.temp_data : + sensor_data.hum_data); i++; } } mutex_unlock(&data->lock); - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, pf->timestamp); err: iio_trigger_notify_done(indio_dev->trig);