From patchwork Mon Jul 19 14:50:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 479869 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4217453jao; Mon, 19 Jul 2021 08:11:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyag8evv1WXOcXY+j5Hmw3plzAS4oKwwoFlPONRswdPMUWv9Jn09e3GuaGqbjoVoCVPUNA9 X-Received: by 2002:a17:906:2752:: with SMTP id a18mr28847010ejd.458.1626707511799; Mon, 19 Jul 2021 08:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626707511; cv=none; d=google.com; s=arc-20160816; b=yAmxz4k5UMyBBCUVwm6ftkId6KMYVQsGuXP1V8cdcLyHnEh3buhc+Bqi0RRd8KnILL ltXTJTtDWjAfsVF6nLM5rV7nfOQlhSxnIENGFYK1H2wBodg//NIlHOmPp4n3EJEqX8rO mfFEGYp4kDc6CjmfiPJKWFto+96c9IE5kBQnPrzbSPMaGBX7Yh2nRS1rXMK9/ZoqlxC2 CdGErsJNU41ku4CUC+Pgd9O5jrNLo17enFcHvBwVYU/cmE1qw9LLGkXND+BBqR/xGiU8 f89M6LFUKNClsQxBeEy3kSqA/cJbu409/PUHX1A8/bj3tm00QI2haV0+Ede3ZsaFxZ3f DARQ== 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=kZ/NZdD+Mq9v8hUjIMYts9bU5IAdDCwqa4mldVoXRJs82/EJjrDDwZd5TNrC8BDIoe ZgfhqSWWnyZZirDCdZH2q4U9gtEerTPKFqYGBBrGJnCcOr3FgRoD5aw7fd9GCY7Jih6t mw64NzX54z0tkSpdwS2x/hMcTqVWjx7mNVZxRydCOwop9wrnqOJgaqWS5uKDaHOjeiyg eUDJ4xa6dvOKUybW0Qd4YPQA5D7Zcps4fRULxyaL16OrDQSzIRBojkYEDqF2RLIaELDg +JLYfDBZhsBPCbW5cODkaY6mhCZ9Ap1a5nl4pGunUzq4AzYltoxDFEU9OVahFNz8UD5w TECQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tBOwiWBo; 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 d26si20449114ejc.620.2021.07.19.08.11.51; Mon, 19 Jul 2021 08:11:51 -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=tBOwiWBo; 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 S242822AbhGSOay (ORCPT + 12 others); Mon, 19 Jul 2021 10:30:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:38396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244329AbhGSO3g (ORCPT ); Mon, 19 Jul 2021 10:29:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C64C461165; Mon, 19 Jul 2021 15:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707358; bh=+mPVfOcxAxvOn4g1UTVHi39fRgRmaymEHJL+MrSZeuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tBOwiWBodg/ShZQ2Z5ttz4mL3D9zL4JFjEKjcuRzw83Oemcprwwy8Vg+98fyP13qD wf8xiM3guenZiczocvt3/m3n+BHcHh1uu4LkX3YQBh7n6j28MEzx0W1Ss9Vs+STusD bWuWVxbg8028t/3FSB5IYNPcUPLwQX+M4PSGBKZ8= 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.9 102/245] iio: humidity: am2315: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 19 Jul 2021 16:50:44 +0200 Message-Id: <20210719144943.722446760@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.288257948@linuxfoundation.org> References: <20210719144940.288257948@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);