From patchwork Mon Jul 12 06:11:00 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: 472866 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2648515jao; Sun, 11 Jul 2021 23:30:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLW4/yHSxK/Spws7RDfPlWPqdt3Z/96bU63xy48IPZkIoZcWE+CsGTB0HE8ysI1d0el3fw X-Received: by 2002:a05:6402:17d3:: with SMTP id s19mr16720106edy.49.1626071452307; Sun, 11 Jul 2021 23:30:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071452; cv=none; d=google.com; s=arc-20160816; b=BdbNlweNN5U2s1QJmIXs6Q5wJXlkVe+LZUj3wD2/zE0ZA45PYDOczxhFHk0DT0vWCZ RPnFpyJBWMyEiIHgDPrW/Pxy9MsJS0Ugg5Lf/y5NwLgB2jmabSNyLYAZGlkeASwcpfOk v0EkdTeG0Gq/U0gXUTr48hiJ8uxcwS6VsHu49fvaubUnBS6+1+Q/7lXA6J8jdb/a3Znd 2ZEWOM2pr3UOeUHsSVgkJvu8w0k5i7PgIf24Ara/YmF6bxdotwqkVbrzrsCqprxtM+lD q/Ja7V0t/7c8SYK57O7Rm8pPvVa3QTVB28WCiIyE6XmFP0pcSIU/OS6xjQk3C95AeuFH Kn1w== 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=9MvIi3f9JJy3ixho8iKpMHJQE0QwFAE+cP9DnwnIycc=; b=CuB1epj12x0Z6aQ/TF3FqV65ZAczXxCDKoIktbUdllzb23aT5lCo80+sJUqbB70WpZ +wUhw859Hajmvn3u90ztvp8L4STYnCc1CW+kpq9s/YHP7vFGERDZwMBGnxZcbX6T+dxS NZAbB30Ch1/9dyDoExdRbv1EgS07K7WS83NnMQBPbKMByemfNgmgGDF66cFcPXdvf13P K4VhuUsbft5AQxfFVBZEjNZe6cgtbiKoshwBVk+uWaqaRjENCPqWC8+0joyuFJACUtoI SVfqSTKqO1b3kG44iQH2hwBqLWvF1N46ZXXgmmwa6wTA1zRkFmPZ4PLX3KYAoQ/yaA4u nbLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=o77sj4Ln; 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 hp31si2068187ejc.73.2021.07.11.23.30.52; Sun, 11 Jul 2021 23:30:52 -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=o77sj4Ln; 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 S236906AbhGLGdd (ORCPT + 12 others); Mon, 12 Jul 2021 02:33:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:47330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234358AbhGLG2t (ORCPT ); Mon, 12 Jul 2021 02:28:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9DE2E61132; Mon, 12 Jul 2021 06:25:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071105; bh=AvI1aRMuo0bOxm25MY/yj9UICvpmGY3V91Y2xmlZuv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o77sj4LnnnN2Ibe6+KgbRkLEQ2E6SDmghgrI6q9QBGUD0r/sDBdWwhK1OUtIL1sz9 kAQYBDxy7Y23K/wxiy6lCvscYI0AkAiYkXLQwLpN+RaQvxFa4hIxmwe4xYRIlCuJJ+ 5llpJat5YPipzf1KY0RwSKsvn9W3WVV2lnM6zUfI= 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.4 276/348] iio: magn: bmc150: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:11:00 +0200 Message-Id: <20210712060740.318884709@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 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 d4de16750b10..48685d785c1b 100644 --- a/drivers/iio/magnetometer/bmc150_magn.c +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -136,8 +136,11 @@ struct bmc150_magn_data { struct mutex mutex; struct regmap *regmap; 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; @@ -673,11 +676,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: