From patchwork Mon Jul 19 14:50:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 479873 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4217843jao; Mon, 19 Jul 2021 08:12:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7kdaPidoPpVksqY3TQ9lI59QyrQIuDUMVD9MUKoSe2dqaXin5yRgNEif5Uj2KFciiwcvk X-Received: by 2002:a05:6402:34c:: with SMTP id r12mr34554353edw.278.1626707543696; Mon, 19 Jul 2021 08:12:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626707543; cv=none; d=google.com; s=arc-20160816; b=PsGO2H18Ehtv2XsWBksj2nN9sHA1jaMa2RmHdFIJikwX6meRt3P6JItjgGaEWWkQMS oAKf9x0e8E4XSTljX6Iz7Ukp1rCJH7ltIkW3GXBKJqSqvJXPuKYqoa0jkCQ6DTCslQys JF1GtB70Q1cyoggQcPdQL3DMQY/SVNi6GH02cIy0CkK/CJcjWMJVWU7XlArQtdL5YDbG Hd+8idf2hb/0T+GUthWfv/8bd0kBXbrhUyHk8P0t1tAWfGC/u6nFalf4vKDRT+IH5UwX goBA5uMx1UzObu72i4sWwOnDzR37X0rp21CYXGw4RLhy3Xk7z8idoVbn4e/s3Wwgm63t uWew== 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=toegSEpeqwD16kNlO63evrExqPbjw8jJX0J48i8/97M=; b=0Asj38fbVlDG+Sd7qks7geo2Ziy7nIR0alf4uHi/JdV7ouiXDMzF4vhqCL6mArLVDu 64zKsm42hvRYTvFlVdcOzffpv10OmbzFj41aFKcU6Aj/xDNeb/JeHh9NvTMevYDa2aSG RLP1wptkLUkpyinFzsGzGhvEncKp15b1NMuyHHcsXMM+oiwL6tg7ruBuA4Mt/uNN6K2z e/Ht21HLBsjq5CJS+qOP5a72REzXTlg6f5qtmfeNo/1SzqK1xt9DMYTIAWOebBrvB8zQ bpKt4uCBBE67+XN/5DUI3m47bxM99HdojE/PZzOQet25VpY83HMXdn1CneNnGwO4q5qX s/rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="buE9Dw/N"; 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.12.23; Mon, 19 Jul 2021 08:12:23 -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="buE9Dw/N"; 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 S242108AbhGSObR (ORCPT + 12 others); Mon, 19 Jul 2021 10:31:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:40508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242199AbhGSO2E (ORCPT ); Mon, 19 Jul 2021 10:28:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CD07C610D2; Mon, 19 Jul 2021 15:08:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707281; bh=2aeO2OEW6Q48RL6xvdkJ+CUiTcH+mq4a+HfUmlOIEjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=buE9Dw/N1z4/cdsr1bCs4P3daC3edAosuipaZQFOCE9LPbiVLpfHJNHalTpZxT/zS 6r2h8F2uvb/hqNIckj3HDJukKvAQa92rRAmpRuOtJYvSFJhTMBjhONy+MAllK2Lac9 RLltwSfPSr8/aPdZCtFwpYWHhavyQ9pOtWxPwOqo= 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 4.9 096/245] iio: accel: kxcjk-1013: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 19 Jul 2021 16:50:38 +0200 Message-Id: <20210719144943.518372801@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 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 261fbdb88fe1..626a605a0c0e 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -96,12 +96,23 @@ enum kx_acpi_type { ACPI_SMO8500, }; +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; @@ -115,13 +126,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, @@ -971,12 +975,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);