From patchwork Mon Jul 12 06:10:51 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: 472873 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2648696jao; Sun, 11 Jul 2021 23:31:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSK2rIzUJiGF2WsZXM3NtLGXw5bwE3ZxwzHLclZqjLSAA2S3YC606yRzvKxLvriYeQha/P X-Received: by 2002:a50:ff09:: with SMTP id a9mr62647435edu.368.1626071472635; Sun, 11 Jul 2021 23:31:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071472; cv=none; d=google.com; s=arc-20160816; b=roWouFyEI2whQvkjG+6YX/miDgKOIkfKX4bjmYUgEEOIjYNbQ8Q73jkLWPs2idN5id KSI8e3mS0BSxH97ha6ZY+jx4okrE9NaE0u8pPzbYx3egptsbGRzSs1+9eiFwes0Z64ph unqgYFCA5SZ+LCImMoUA/Vp08KLH3CJNWYpG4ZEXZiYHPwHhq6BUZlkzt+a7jQxbK49S Xje/sgtjxDf+hTlCJEFylk9zf8Z/VDsSgetFxvIuAtfp330IeSCfjiOl1iuZd/jlVuTc jgxpRxY9gR0o0GKzAB3AATYmtHmOJxHAyvYdXVeNvnJj5lIRxnZqKofZ/5lt17j5wESX bL3Q== 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=0TCzm8NwJ2OTQZB+LbYXKxfT+1LM+I51+UdO0vQ4SWc=; b=We2B98OoeepCDqsXMTe9W/oAJu4QokuXX7fmhs2FCK9Nwk9JPNTYf6v9Jl9eQuM+1D 4CJDQOe71suzt95UFRognoh+6hOYg0/QPpjDOF7Ypl+80nVrz9XqIzTlHxoR+MecFn1F mazMoiyY1qG1d8XIm1fR6GgJmWL18V7Asskp23onh0ySvCKB6Fr57+CPAtrYC/YwmfXw OxLQjN0AJDcfpU1U86AY3JE1TeX7guwO+cHXhjiuADr3qZley9VP/yvbWycffL5rhb4w yOkpyH2fa8oo3fiJRLXGDDrnVcFsizalJRjs6o7BaX4EwS+CGPikVxZXGL+Bo3+Lug20 n1fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NX7JRPxU; 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 b1si16242569edx.272.2021.07.11.23.31.12; Sun, 11 Jul 2021 23:31: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=NX7JRPxU; 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 S233926AbhGLGd6 (ORCPT + 12 others); Mon, 12 Jul 2021 02:33:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:48074 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234861AbhGLG2b (ORCPT ); Mon, 12 Jul 2021 02:28:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CD135610FA; Mon, 12 Jul 2021 06:24:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071081; bh=nJsOtoWsL/fl7P58w+c06vgkdftY3UrTr9vD9JiarCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NX7JRPxUE0SSafyIT2aQk6v/bbAwT5W0wtGrx6Id7N1jyebPFjXG9C3+BPdNhZjlT xP6XKYZRFToBT6LCfqwKXNSVLLCnaqtq2/UO+K+yZkxKe66ScEA1w0jLcPM4awcxMg gJhPD8wYeiQl9UKDN6L1cbv+nJPDVpvk8hWR9+gU= 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 5.4 267/348] iio: accel: stk8ba50: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:51 +0200 Message-Id: <20210712060738.862850254@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060659.886176320@linuxfoundation.org> References: <20210712060659.886176320@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 334883894bc1e145a1e0f5de1b0d1b6a1133f0e6 ] 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: db6a19b8251f ("iio: accel: Add trigger support for STK8BA50") Signed-off-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-8-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/accel/stk8ba50.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) -- 2.30.2 diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c index c70ddec29eb4..edba3c13a979 100644 --- a/drivers/iio/accel/stk8ba50.c +++ b/drivers/iio/accel/stk8ba50.c @@ -91,12 +91,11 @@ struct stk8ba50_data { u8 sample_rate_idx; struct iio_trigger *dready_trig; bool dready_trigger_on; - /* - * 3 x 16-bit channels (10-bit data, 6-bit padding) + - * 1 x 16 padding + - * 4 x 16 64-bit timestamp - */ - s16 buffer[8]; + /* Ensure timestamp is naturally aligned */ + struct { + s16 chans[3]; + s64 timetamp __aligned(8); + } scan; }; #define STK8BA50_ACCEL_CHANNEL(index, reg, axis) { \ @@ -324,7 +323,7 @@ static irqreturn_t stk8ba50_trigger_handler(int irq, void *p) ret = i2c_smbus_read_i2c_block_data(data->client, STK8BA50_REG_XOUT, STK8BA50_ALL_CHANNEL_SIZE, - (u8 *)data->buffer); + (u8 *)data->scan.chans); if (ret < STK8BA50_ALL_CHANNEL_SIZE) { dev_err(&data->client->dev, "register read failed\n"); goto err; @@ -337,10 +336,10 @@ static irqreturn_t stk8ba50_trigger_handler(int irq, void *p) if (ret < 0) goto err; - data->buffer[i++] = ret; + data->scan.chans[i++] = ret; } } - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, pf->timestamp); err: mutex_unlock(&data->lock);