From patchwork Mon Jul 12 06:10:15 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: 472994 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2685145jao; Mon, 12 Jul 2021 00:26:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3YW0Dc3dzKzcEORBoTRqLUw/oHzIXLXHref9iYzhtRdMYxuy+oH6M+hQ1qcB7sN49fw9t X-Received: by 2002:a05:6402:c17:: with SMTP id co23mr28367122edb.68.1626074467614; Mon, 12 Jul 2021 00:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626074467; cv=none; d=google.com; s=arc-20160816; b=SuqbNyjmVlycZd1IUTfstApboPmfCj2CXkqYVS9/zxmZB2WPcXDGqGvo47jY1KA8Zp CZqmiLMJAkzastpQVhdtsvFVGLc/F1J7Irli7FOH39gxWB2LmK7/B9nzMTeOR54WEsMX uMq/9D5GJVENdZLu7TddYlX2Yl7aD2dmty1tnOS6w6rFfHabDg010tUzBvK9acRPoKdV /XGsRKKRaUUA46CV/jf34tjD0MBcBTjDJ4be9S6kRHxZK+SNOeRnJP+0GlsqlG27/AGB J93gTI//RF8CgyTJxYV1VY85O5xaBaX7On7aE9hWj7ZrPcmdcRwANOM7ryt2aC/PCuTL OvAA== 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=8lb/Ik/wQeH9ZD9JXc/2PhZJozhHJrl3ae01dwzg0bk=; b=BNYOLWG/QkSO2/oZRW1HdcnzwOhBK+RjvIYr/miBNEs33kc2gFAL3m+BSRqVRG8NNO Oy+G9YxGg24Nzm8eNIGP20JP7Q4a56TePTcxkAKQl1Xf/UTVdVi7xLiRL7XW21L2BrLw PLgV9WK/UCjnH49Pm+fKgT0EhYdrZVsg3pmeWi1MAyvKZTDK749swm4L9srk+dlEHDd2 wSLiFzuNKy3D3sKoMbdAW7J7c80ZEYZkt3iZ9RV6KTwmbfPsSivNTxieuUtpBj6+d1x4 WI2fEkH9cQKgbTs2Lqf+Wmw7Abvshweb5g6cOmC1kw8Xm4JvFkcn7XkdyxLJJXFyqbFk DorA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MuFw9lJ1; 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.21.07; Mon, 12 Jul 2021 00:21:07 -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=MuFw9lJ1; 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 S242813AbhGLHWl (ORCPT + 12 others); Mon, 12 Jul 2021 03:22:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:59406 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344873AbhGLHVY (ORCPT ); Mon, 12 Jul 2021 03:21:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4B359611ED; Mon, 12 Jul 2021 07:18:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626074316; bh=AkeRhEPYY+dMYHxvwsgAA8C77PGZ0KaeohoCJz8hJGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MuFw9lJ1NBZDMcVSl4CfDOihfR44tWq7PLcsb4PbVPTGOsjF7pavSS3VvgQnrFsni LwyxlAeTNhwF/GuI3QkkzsmjB6uTsh284V5EG4WRDtImAzVcYfeDH5j5Obz4FR7878 tPuTYxQoYH8OUTVzwg7FHmcofvnzrcmQJ46Yo2jA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Peter Meerwald , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.12 532/700] iio: accel: bma180: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:15 +0200 Message-Id: <20210712061033.078231312@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 fc36da3131a747a9367a05caf06de19be1bcc972 ] 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 this function. Fixes: b9a6a237ffc9 ("iio:bma180: Drop _update_scan_mode()") Signed-off-by: Jonathan Cameron Cc: Peter Meerwald Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-2-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/accel/bma180.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.30.2 diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index 2a6d73cc7333..9b0018874eec 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -164,7 +164,11 @@ struct bma180_data { int scale; int bw; bool pmode; - u8 buff[16]; /* 3x 16-bit + 8-bit + padding + timestamp */ + /* Ensure timestamp is naturally aligned */ + struct { + s16 chan[4]; + s64 timestamp __aligned(8); + } scan; }; enum bma180_chan { @@ -943,12 +947,12 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p) mutex_unlock(&data->mutex); goto err; } - ((s16 *)data->buff)[i++] = ret; + data->scan.chan[i++] = ret; } mutex_unlock(&data->mutex); - iio_push_to_buffers_with_timestamp(indio_dev, data->buff, time_ns); + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, time_ns); err: iio_trigger_notify_done(indio_dev->trig);