From patchwork Mon Jul 12 06:10:50 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: 472876 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2648787jao; Sun, 11 Jul 2021 23:31:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3yDaBD43LHHKiIy9fy1+Q6PrxNNrR8Tj6wT11ioTlKGWVAC2yEJMoFA2pJeKBZm9UeqxN X-Received: by 2002:a17:907:c20:: with SMTP id ga32mr51736988ejc.7.1626071478211; Sun, 11 Jul 2021 23:31:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071478; cv=none; d=google.com; s=arc-20160816; b=xB9LLlNLi4s57f7jIV+wIwvp7cpE6fZdJfSFtDBswScCOvRHCWLKVu5Jc5otrDScjX AYA9s4GvhHdERFmVPSqaf9X4GndEpn/r5W8tONvoPIW7iDsQ8QCLg/V7zfg7ZS+pbPdO iFfb46auJIYQiUXi/F8rZ2R44x5Bx0oobOTirIBOTEJRhTc+Pzpz2WSQkDKhrpYRdgXy kevGK84aSl82kw7RSt3sT2fu9KO8iWxfXPbR83UbyItK7aWxWZ0kbwwTZvNT9BKFeg9R oVxgOf/TUhLTgfmddLNTqbVxec5oqf72cJnWcay5MozL+EPkBiSakAb45wxe7pqLMld7 cp/A== 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=6ERKlJ/kGsv6HnuxvxDywRVuaQwQGm9Rynm09T9zYEs=; b=0RvImA2ASxuCPqndFKqRgZYU11nbMQBWLhZSooblobMih7Qd5NAm+NOySAJ4cCqoUX Pw+yxWr/iODty/Rgrc1oqGXWGHMq6Mo/FeZDOmBHYek5KUCKEgYRDjqILYRZNVW0eHm/ 7M4KhcUvXlY2rf0ALffYS3HfdbT0EWPA0Opt/e2bId8PU+1A/P71UtTWmsU18dWEY7dV HmTsHN9KKQ+atEcCuP57mDjEfaWH8zRL79oIFvRCCAquuvS7i6Gd57hivv6hp2p9YWpH raCAvSJvVGhErQDy69TmBvZOzTfHSo85H5zRZPtI08vqhQrUK2THPL1vH4dcWF3fSvAs 91xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IkKOQvxq; 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 z21si15300615edb.572.2021.07.11.23.31.18; Sun, 11 Jul 2021 23:31:18 -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=IkKOQvxq; 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 S236819AbhGLGeB (ORCPT + 12 others); Mon, 12 Jul 2021 02:34:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:48076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234091AbhGLG21 (ORCPT ); Mon, 12 Jul 2021 02:28:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7DE9961179; Mon, 12 Jul 2021 06:24:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071079; bh=3TjHv2nHFSfpcKUmfc90JCPU/RbQAJTOAjnfrnCLJb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IkKOQvxq431gp4IIZNeCn9wZU+NP45nnGV47otRBXr2Cw1OkFhVRyRZGBppfNL52V TAIaS0wzTetD7ykM3a+nUpYVP4qf87ut+Uqv3mou43qBInI3z/Bbkk4gtWyKriVhoX eyE6/Ap7rR0Y6ML9KVYntS3V53fweFTlqOln1uSw= 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 266/348] iio: accel: stk8312: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:50 +0200 Message-Id: <20210712060738.711081009@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 f40a71ffec808e7e51848f63f0c0d3c32d65081b ] 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: 95c12bba51c3 ("iio: accel: Add buffer mode for Sensortek STK8312") Signed-off-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-7-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/accel/stk8312.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.30.2 diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c index 58c160ccdee7..be66b8523977 100644 --- a/drivers/iio/accel/stk8312.c +++ b/drivers/iio/accel/stk8312.c @@ -103,7 +103,11 @@ struct stk8312_data { u8 mode; struct iio_trigger *dready_trig; bool dready_trigger_on; - s8 buffer[16]; /* 3x8-bit channels + 5x8 padding + 64-bit timestamp */ + /* Ensure timestamp is naturally aligned */ + struct { + s8 chans[3]; + s64 timestamp __aligned(8); + } scan; }; static IIO_CONST_ATTR(in_accel_scale_available, STK8312_SCALE_AVAIL); @@ -438,7 +442,7 @@ static irqreturn_t stk8312_trigger_handler(int irq, void *p) ret = i2c_smbus_read_i2c_block_data(data->client, STK8312_REG_XOUT, STK8312_ALL_CHANNEL_SIZE, - data->buffer); + data->scan.chans); if (ret < STK8312_ALL_CHANNEL_SIZE) { dev_err(&data->client->dev, "register read failed\n"); mutex_unlock(&data->lock); @@ -452,12 +456,12 @@ static irqreturn_t stk8312_trigger_handler(int irq, void *p) mutex_unlock(&data->lock); goto err; } - data->buffer[i++] = ret; + data->scan.chans[i++] = ret; } } 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);