From patchwork Mon Jul 12 06:10:30 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: 472986 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2684070jao; Mon, 12 Jul 2021 00:25:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynoNRHHSosGG413GAZzlcjdHtakzNo8sDf/IOONY5/QJzgMysrF9cArkL1wZ0iTNv/Py+R X-Received: by 2002:aa7:c043:: with SMTP id k3mr62467831edo.160.1626074595969; Mon, 12 Jul 2021 00:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626074595; cv=none; d=google.com; s=arc-20160816; b=q4RQncyL08VR+5H4JnpkZP5nQg9/utfvqwCssBb0K7ShQPa3IqrsTgYAXwwrP/79zJ fcnhqK4ltRSqBjm5wlVkvPoza6psLASyMwhjhj0g0qjSLvqcejLArguOYOEa3bgX6Kd7 be8uw1r0nuRUeOnyZRAUi/LKN8FTRhG4K6hBp5mg6ijy2RE7wzUnlOHXcEidKjd8PGq6 v4dB490AmqtsRtvKsy0D9AdlgmhIsIBK/4vSHzFMAqcDRJja1iJejvzDvIZHiywQXZE5 n0VFzpXfSK4y7aiKH6VQ/1hX/esuJeLsf6yp/27aO46ilq/ffMusfaSYHS4bM4D2fczO yM6Q== 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=tX3Ion3KkFkIUb1NYx097CAVzXYDAXCEXdgCrG++CH4=; b=Ht20cBfppUFYKPiQOt03a7vzOPnKF+Dc92HJIfSb96pPE0uw32NOzhCh3SXLi38lQX bzx0foLUp9FyUF0G4aPtHbRzydZS7Sof6nIw0956JDsmIckyEr6bWzQnGrtaskd7GFSh sZLHo9PeCQpnLJvVGEMAyz++Hr2M16XJSlBP9olc9OgdIP+RjO595kH3AgloBj3VseB5 c3Ot87AvOuHlBz/Lq+5qINH/I9Q+BxKp0pDDizRUpdhilzCIxBaC85VL9kqQzz/X2uqL dsULZVIjo4VC5P+zH5FgOzmP8Oz3d/1/l0FFkmQNQmfztzFhWQiFV/z5SvFlzozeRwgT 0mGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yU9YqAut; 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.15; Mon, 12 Jul 2021 00:23:15 -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=yU9YqAut; 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 S239153AbhGLHX3 (ORCPT + 12 others); Mon, 12 Jul 2021 03:23:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:59870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236827AbhGLHVp (ORCPT ); Mon, 12 Jul 2021 03:21:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C343661574; Mon, 12 Jul 2021 07:18:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626074337; bh=OcI/GLSL85g/WHSSv0ySurcgmk5T2PB1xhgb3fsp4uQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yU9YqAutOZ0s1qEJga0CS0WArVLT/re1znuksG6VNxFky+lv/aN3C3O0Tc11X117L +I/gEUozwxywnIA4BITdyngXcO1b9DiJQd1k6XsGqoLVa7/cLgG5Db+m9hdXo0YTgy 8qJ2jF7BJsHhrK1DDhASktJ1GyMWNz4BmXNLCQho= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Stephan Gerhold , Linus Walleij , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.12 547/700] iio: magn: bmc150: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:30 +0200 Message-Id: <20210712061034.521341918@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 7692088f72865c41b6b531fd09486ee99a5da930 ] 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 uses of iio_push_to_buffers_with_timestamp() Fixes: c91746a2361d ("iio: magn: Add support for BMC150 magnetometer") Signed-off-by: Jonathan Cameron Cc: Stephan Gerhold Cc: Linus Walleij Reviewed-by: Linus Walleij Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-17-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/magnetometer/bmc150_magn.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) -- 2.30.2 diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c index b2f3129e1b4f..20a0842f0e3a 100644 --- a/drivers/iio/magnetometer/bmc150_magn.c +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -138,8 +138,11 @@ struct bmc150_magn_data { struct regmap *regmap; struct regulator_bulk_data regulators[2]; struct iio_mount_matrix orientation; - /* 4 x 32 bits for x, y z, 4 bytes align, 64 bits timestamp */ - s32 buffer[6]; + /* Ensure timestamp is naturally aligned */ + struct { + s32 chans[3]; + s64 timestamp __aligned(8); + } scan; struct iio_trigger *dready_trig; bool dready_trigger_on; int max_odr; @@ -675,11 +678,11 @@ static irqreturn_t bmc150_magn_trigger_handler(int irq, void *p) int ret; mutex_lock(&data->mutex); - ret = bmc150_magn_read_xyz(data, data->buffer); + ret = bmc150_magn_read_xyz(data, data->scan.chans); 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, pf->timestamp); err: