From patchwork Mon Jul 12 06:10:47 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: 472871 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2648676jao; Sun, 11 Jul 2021 23:31:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLtcQdltYvec9SDIjJ60GGgOnRi4OFH07EiQ98JNYvA/sLHhZvBKaveh+Q1jXPGyypFmaA X-Received: by 2002:a17:906:2bdb:: with SMTP id n27mr51324808ejg.312.1626071350806; Sun, 11 Jul 2021 23:29:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071350; cv=none; d=google.com; s=arc-20160816; b=naxnu4E9U+JV0VKwnpVbdKGmPuhF0q4Z7Cx5JWlEqzdHR+CV3AoqriGtu2Qw/Eh1ET /QhYKb1r4E+O+R6qw4CRfGVJ83yAYuqsy0woaiPjxcDoQO2y9rsXbmYc0kr172g2b22S 6ayUviSN6ix1D4TnRJUFh34XooXx3glr5XPsZdtmWoCcSCSbFPl2vbiLPaK0SIWCRnKy QDEnhNdZdvWRVIIzQOoPD3EtnhBgrprvqnRbfqI+VoQmb3BmuTWqYqE/po6u3AsmfNfU C1GZ3NCvb/62ins5y+pPftkFAU39J+eMEnUxnVmQKEoZlh1eDgfxUAIHwzqpVQtLZ7XB LD5Q== 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=WF6YtQQBneQCNErYlvmx5qgCDP1+moJmLxtCv4mtX1Y=; b=e1bLHhaayqBTowFQ0+ArJyRVBjYOTbp45kLQECdJ1Vj+GoJO7ugvt7CGF2eKxSBPMa qkfw4tRQ/AuszBx4+yGjt3PBkpsLeLPjpqST4T84JALLlnIMPKFpEYMClUSP46TL0O6q a+xvs5wrd21NGYjUCH3NJjdIAlYw85mlMIvLU28ZANePId9bzjrSA//PpsfVUwTzTPgy qMWiuW8MbjkT0HWm1/5xWHChbCHef4xPVXH9eqgv6QKo8NyGxk2YXYMF9sfQ6OaLw1P+ nfenpKg5nqQBnyA5piJNx/1EMFoHpTezoIKXwT7iAu9bslJqezYYbuCuj9bpdD+QOLtX 3j5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="PYf/RgwW"; 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 bz6si16420285ejc.610.2021.07.11.23.29.10; Sun, 11 Jul 2021 23:29:10 -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="PYf/RgwW"; 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 S234814AbhGLGbS (ORCPT + 12 others); Mon, 12 Jul 2021 02:31:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:47906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234948AbhGLG2Z (ORCPT ); Mon, 12 Jul 2021 02:28:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 831FC60234; Mon, 12 Jul 2021 06:24:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071072; bh=4Tz8qtGnjkoUQY2eInev98DKc+Fug3EPmfeGPJxXEP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PYf/RgwWdt3zT26xeSsMRRzxk6ngYJ3mPSI3eh7V4eramXkhL0aAAsvnUqD7fRLaG ra3tRdsVQPgo+GUM5i7jur1qjb69XBAOJiX1koqE8zW7AxERDa9YfdtamV+zDHaac4 2cF9qCm3EDC2t83JhtKtQdctoX9xx9LkqpEm2IvA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Srinivas Pandruvada , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.4 263/348] iio: accel: kxcjk-1013: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:47 +0200 Message-Id: <20210712060738.308449933@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 3ab3aa2e7bd57497f9a7c6275c00dce237d2c9ba ] 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: 1a4fbf6a9286 ("iio: accel: kxcjk1013 3-axis accelerometer driver") Signed-off-by: Jonathan Cameron Cc: Srinivas Pandruvada Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-5-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/accel/kxcjk-1013.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) -- 2.30.2 diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index da9452e81105..57db60bf2d4c 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -132,12 +132,23 @@ enum kx_acpi_type { ACPI_KIOX010A, }; +enum kxcjk1013_axis { + AXIS_X, + AXIS_Y, + AXIS_Z, + AXIS_MAX +}; + struct kxcjk1013_data { struct i2c_client *client; struct iio_trigger *dready_trig; struct iio_trigger *motion_trig; struct mutex mutex; - s16 buffer[8]; + /* Ensure timestamp naturally aligned */ + struct { + s16 chans[AXIS_MAX]; + s64 timestamp __aligned(8); + } scan; u8 odr_bits; u8 range; int wake_thres; @@ -151,13 +162,6 @@ struct kxcjk1013_data { enum kx_acpi_type acpi_type; }; -enum kxcjk1013_axis { - AXIS_X, - AXIS_Y, - AXIS_Z, - AXIS_MAX, -}; - enum kxcjk1013_mode { STANDBY, OPERATION, @@ -1078,12 +1082,12 @@ static irqreturn_t kxcjk1013_trigger_handler(int irq, void *p) ret = i2c_smbus_read_i2c_block_data_or_emulated(data->client, KXCJK1013_REG_XOUT_L, AXIS_MAX * 2, - (u8 *)data->buffer); + (u8 *)data->scan.chans); mutex_unlock(&data->mutex); if (ret < 0) goto err; - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, data->timestamp); err: iio_trigger_notify_done(indio_dev->trig);