From patchwork Mon Jul 12 06:10:18 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: 472969 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2683299jao; Mon, 12 Jul 2021 00:23:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhHsn5VS1PbEjs/qqHMDmV9UjVlGqI+qdNpSa4G7IEPESiJogzYIOiUvsSk33lUjIM0kUj X-Received: by 2002:a17:906:4b46:: with SMTP id j6mr1852364ejv.247.1626074637134; Mon, 12 Jul 2021 00:23:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626074637; cv=none; d=google.com; s=arc-20160816; b=b8S6a2pIVHFskPLmejkKJ2owsP3q/xZS3plcGYLPbGE0lBBGbbJkaSzxfZVLHNS17k FRu38SCHcekrpnRbJYTcWh5p+7dTc9+nRchhcz5GQSvVpeA4HP0IFz+nzK5fGM9T1GXM NEesRv82FZBl7GdcWktL4LpNtpsXfEVaQJAdHkd0xOL4WnJTm26iwR3G/1WDXu8wyZfR R/XXTwMClp6hWVuys+Y6iU0YFeBS03I5YBxY3CaEMS4DMIyvWSBRXF4uQTX5mNSoufqD TOqEZ9NSZmqT9UWZX4M4CeFWnYjcMiIrZL0SlgLGE8lyJ3burQe6TWBgHPjHuAVAIj4k Q7vg== 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=lQDWhafEjZ7T3UkNGKei9dedcqLPc/6B+cXk8gBomr8=; b=r4xtwnyBlEIYbzlzkSahTGH/97GRSKU6l4IwUNBvchshdN4Dz3xYIUsH031PZnGjTX AcQ++AlsvYh6rlhb7AblIjjSsEToycxJUAt53STVPoNTBZ3x+UHoHrsmWzHlraHXO3gJ kyplbXhaKQ1DvKqZAcOcPigLJDsszTz3XMxU8FktXX6ck4I9fnGJ1Uv58tXNxLD5LBw3 O+/5kUYYYX2kCH4D9u1PLeHJtQuB9R0gBevw52lfvsJDFRaL8IAhEJvJI82cHpjF1GZb UHngWVG4/SUAyCoM8xsk4SRWtrQcpZkKGUvYbhlvGH2g74cCZn4QRb2m7y44j5eUMjQm mDjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="JA/OHgZj"; 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.23.56; Mon, 12 Jul 2021 00:23:57 -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="JA/OHgZj"; 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 S243255AbhGLH0D (ORCPT + 12 others); Mon, 12 Jul 2021 03:26:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:32988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244849AbhGLHXC (ORCPT ); Mon, 12 Jul 2021 03:23:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5D998610D0; Mon, 12 Jul 2021 07:20:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626074413; bh=VXHNpa0DIna+CtM2nDV4dIAglrYxx4J4Gk0eC6pCLhw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JA/OHgZjIASMoLGtOWq6aOGlwhyerY40N/3czMzLnr8pFDy8ZI6whbgLYcGl9PNn2 i7tnvdCzjAA4uxZunES98AXWvI/EKcAye1FrgubYY19v+BumqFErcor1elskEvR2yx Idgl4T1TzyZOjES3V/sqk69bkVxbx6muqHqeiQnw= 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.12 535/700] iio: accel: kxcjk-1013: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:18 +0200 Message-Id: <20210712061033.360891218@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 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 2fadafc860fd..5a19b5041e28 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -133,6 +133,13 @@ enum kx_acpi_type { ACPI_KIOX010A, }; +enum kxcjk1013_axis { + AXIS_X, + AXIS_Y, + AXIS_Z, + AXIS_MAX +}; + struct kxcjk1013_data { struct regulator_bulk_data regulators[2]; struct i2c_client *client; @@ -140,7 +147,11 @@ struct kxcjk1013_data { struct iio_trigger *motion_trig; struct iio_mount_matrix orientation; 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; @@ -154,13 +165,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, @@ -1094,12 +1098,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);