From patchwork Mon Jul 19 14:50:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 479866 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4216967jao; Mon, 19 Jul 2021 08:11:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnxu/M3TmYokW5D40PkoBwlmrHTuaKRb23t8hDMdpuZvbhECOIPxQwwnPHeNVIUl5HrzpX X-Received: by 2002:a17:906:3e08:: with SMTP id k8mr27693090eji.89.1626707484506; Mon, 19 Jul 2021 08:11:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626707484; cv=none; d=google.com; s=arc-20160816; b=O6kDaG9n1+v44wSG5nDGioFd0T+2xNpjX3G8ZJaBGNHCqOfIUAPDO+kySePv7u9jdx HhlPvBp+WwFSQUQ5+WAqGcr2y0bWBTO7j024CIO/cK2+Tmdnh+oi6JuFwwn1dcIlQK5j eIj3bWEEi8fDusxfWMmxWjNDLXuL5cL8az9+7U006QCsUAnn8FvpJ0qd/Y5Zj5wih92n pD2DDaEu46B8aOYQHscMCRPoTcMW0acnfEP9OcV+VS0Ygj4OXLABdcX63cn/cKAaxnYz kuhJFPzb4U8AZY3MCnAsWIaeaVN1ZSzN7LoWWDRs5hzG9wyWmvw9alf3K0cz5+Tm/v29 YuvQ== 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=0P59cHdT3/dmyb7LWlrV4vjd8pMy77sISec2XBEuRRk=; b=zdeJPpvEjoye0fX0bwwydkokGnGoyEJ7qurvybH+qaIDJiUIqKvN4Z4YLLI5ToMqo+ /lKtQ3rCfohUv0hWNT1WNe15HHrk/NSfiEops9kVMmPy2/m5zQrcq+OcwQ3Tu/jPCnBx 6ewt3oy/keMTFPvFAQEBtkDVfHUhdBs96L3mnRQXDUPcPxs+U7C6uae50Z2KW6F5SCy4 XHA60EYt7e+LeB9Bkq2HYXmYFBXEWMADVSJOgPNxUaADsPV55ILOBz9gvhqI6KpKBya5 8+Qjg1RjrdCby1w2AC1KZFHxZ00JBA9nLZn6zh6OIod7jLqIxT48PUyNTeX4JGnM0Ipw LgMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TW92bWT6; 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.24; Mon, 19 Jul 2021 08:11:24 -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=TW92bWT6; 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 S243486AbhGSOaa (ORCPT + 12 others); Mon, 19 Jul 2021 10:30:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:38762 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243434AbhGSO20 (ORCPT ); Mon, 19 Jul 2021 10:28:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 03ABD61003; Mon, 19 Jul 2021 15:08:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707286; bh=we0Z8Qb5CRePw6IZiHrDko5jgmXm6I7fIZBCO5nZ510=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TW92bWT6fmfC8uMUZIFwG7upQXZajqk2LSL6m+SZ/jh9SLPDremC3O3zSrH5ISFqp 3onjabk3Lts5ATGzVpg2Q99YuhaDpUfSoDeBK3SN11oDrNspoVQRluks9Do1nb7F70 tgQvaS6/6ZJxLj8AkGDUrxMjn8KYeqmnXiWk9qZo= 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 098/245] iio: accel: stk8ba50: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 19 Jul 2021 16:50:40 +0200 Message-Id: <20210719144943.586728592@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 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 300d955bad00..5ca179cea2fb 100644 --- a/drivers/iio/accel/stk8ba50.c +++ b/drivers/iio/accel/stk8ba50.c @@ -94,12 +94,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) { \ @@ -329,7 +328,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; @@ -342,10 +341,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);