From patchwork Mon Jul 12 06:10:20 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: 472971 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2683367jao; Mon, 12 Jul 2021 00:24:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys9qz79e78qBRI9nr5Afd8GeKQz+NkYZJswY1JSJl+088F+IIfJ9hPRTdqihqUX9W/GjJt X-Received: by 2002:a05:6402:216:: with SMTP id t22mr62403317edv.70.1626074642655; Mon, 12 Jul 2021 00:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626074642; cv=none; d=google.com; s=arc-20160816; b=vrq1K06fOI7HiJOiGr9lSavNFC6Xa5bz28H64xQMcNA1j7Tp4TBdr3YAj7HSJMX4Lx jtlY7Ob8Z+2UYeiYY/GvnJprfb9Hk7qduxqE6+TPAkTX5hl9Vd/NOqKsxZRMLxvLWxgL pjHbisVV74tE9gGMt3p8fIeSvaa/5cjYiSiXyJ1+0CQu4EHpPEzzolLVpfYTHqzNmMca mEtdJX6MYxpDNfcO3DtbZJwh+4hYYzJBAb2G6BOnMqEogRBjGBuQb41SPyzEw0xADaQP ZHlVydgTiKpKAmVTQg0alz/p8Dcy52R48nSwaZyFyD71tfe0nOBKLUE4aGTRVmlRU83r dFpQ== 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=YnLdh5UMTNa94AY8BcSMvmTyJj5TxAt5Q8qKqaENzAA=; b=O87PbEUaK2AJ69nG6UxpnjgqOktrVFciWPVgbulQ8nv2BUPyK/AppWLZE5gnZ0tuCE ZdHhdtWEfGtZd/GK5/wjSjgep7VMc0//1LrfKoC4B5O+pZVs12B4t+pFUkMfFCJeK6p2 Dd8IpRS++35iBoQs8N3N9/8AucrBNLrQj1Xd6bULhfue2trlWpCPCQwMQLB+fGuB3jyq suPFC8e3esP/swNtvXuaUpmRlMQS63yH16DqIXyJVtIt5yyj6FNGnCxUAG8E+4NCkgib 655fSO+fLyl7QXXjRAaCB7rblwWgqJ0Ckggt/D4a2KjjGhFH2+lKLchMD+XmW9x9UwNd nwEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EQIPckFZ; 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.24.02; Mon, 12 Jul 2021 00:24:02 -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=EQIPckFZ; 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 S243688AbhGLH0L (ORCPT + 12 others); Mon, 12 Jul 2021 03:26:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:35054 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242923AbhGLHX0 (ORCPT ); Mon, 12 Jul 2021 03:23:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EA6126112D; Mon, 12 Jul 2021 07:20:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626074438; bh=SuJWx5aikfgjLPsi/izRltDjym6hqrl6MuXVSfVMQVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EQIPckFZpI1KjEgWi8iKJalPP81IpOqxwAf3v2LC0vuqW7U/VrWhMgW0L/kpgZdYB R5C7MKIfIB58tifL26UkaNewIzJSQnG+0cKIluSXIvhl8ePsussYel/DnUwH4RwlQt s8JBTdrtb7Vk0oQa6zNjXB1KHodErhmWVf+hadAE= 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.12 537/700] iio: accel: stk8312: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:20 +0200 Message-Id: <20210712061033.551440363@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 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 3b59887a8581..7d24801e8aa7 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);