From: Jonathan Cameron <jic23@kernel.org>
To: Yash Suthar <yashsuthar983@gmail.com>
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
andriy.shevchenko@intel.com, grondon@gmail.com,
linusw@kernel.org, hexlabsecurity@proton.me,
sakari.ailus@linux.intel.com,
srinivas.pandruvada@linux.intel.com, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/3] iio: accel: bmc150: use aligned scan buffer for both trigger and fifo
Date: Sat, 22 Aug 2026 23:02:27 +0100 [thread overview]
Message-ID: <20260822230227.6fafb565@jic23-huawei> (raw)
In-Reply-To: <20260815175728.99541-2-yashsuthar983@gmail.com>
On Sat, 15 Aug 2026 23:27:26 +0530
Yash Suthar <yashsuthar983@gmail.com> wrote:
> Drop buffer as duplicate and s16 is not correct we needed __le16 as little
> endian, keep scan at the end of the bmc150_accel_data struct with
> IIO_DMA_MINALIGN, and use it for both paths.
>
> Fixes: bd7fe5b71918 ("iio: accel: BMC150 accel support")
> Suggested-by: Jonathan Cameron <jic23@kernel.org>
> Signed-off-by: Yash Suthar <yashsuthar983@gmail.com>
> ---
> drivers/iio/accel/bmc150-accel-core.c | 4 ++--
> drivers/iio/accel/bmc150-accel.h | 14 +++++---------
> 2 files changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
> index dc8a6285cf3d..89a475ef9a9b 100644
> --- a/drivers/iio/accel/bmc150-accel-core.c
> +++ b/drivers/iio/accel/bmc150-accel-core.c
> @@ -1191,12 +1191,12 @@ static irqreturn_t bmc150_accel_trigger_handler(int irq, void *p)
>
> mutex_lock(&data->mutex);
Relevant to the next patch - what is this lock actually protecting?
At first glance I'd assume the buffer, but then we drop the lock before
we are done with that.
> ret = regmap_bulk_read(data->regmap, BMC150_ACCEL_REG_XOUT_L,
> - data->buffer, AXIS_MAX * 2);
> + data->scan.channels, AXIS_MAX * 2);
> mutex_unlock(&data->mutex);
> if (ret < 0)
> goto err_read;
>
> - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
> + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
This is still using scan, but the lock has been released.
> pf->timestamp);
> err_read:
> iio_trigger_notify_done(indio_dev->trig);
> diff --git a/drivers/iio/accel/bmc150-accel.h b/drivers/iio/accel/bmc150-accel.h
> index e8f26198359f..9deff256aed5 100644
> --- a/drivers/iio/accel/bmc150-accel.h
> +++ b/drivers/iio/accel/bmc150-accel.h
> @@ -64,15 +64,6 @@ struct bmc150_accel_data {
> struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS];
> struct mutex mutex;
> u8 fifo_mode, watermark;
> - s16 buffer[8];
> - /*
> - * Ensure there is sufficient space and correct alignment for
> - * the timestamp if enabled
> - */
> - struct {
> - __le16 channels[3];
> - aligned_s64 ts;
> - } scan;
> u8 bw_bits;
> u32 slope_dur;
> u32 slope_thres;
> @@ -85,6 +76,11 @@ struct bmc150_accel_data {
> void (*resume_callback)(struct device *dev);
> struct delayed_work resume_work;
> struct iio_mount_matrix orientation;
> + /* Ensure correct alignment of timestamp and DMA safety */
> + struct {
> + __le16 channels[3];
> + aligned_s64 ts;
> + } scan __aligned(IIO_DMA_MINALIGN);
> };
>
> int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
next prev parent reply other threads:[~2026-08-22 22:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-15 17:57 [PATCH v2 0/3] iio: accel: bmc150: DMA-safe buffers and use iio_push_to_buffers_with_ts() Yash Suthar
2026-08-15 17:57 ` [PATCH v2 1/3] iio: accel: bmc150: use aligned scan buffer for both trigger and fifo Yash Suthar
2026-08-17 12:15 ` Linus Walleij
2026-08-22 21:55 ` Jonathan Cameron
2026-08-22 22:02 ` Jonathan Cameron [this message]
2026-08-15 17:57 ` [PATCH v2 2/3] iio: accel: bmc150: use DMA-safe buffers for regmap bulk reads Yash Suthar
2026-08-17 12:15 ` Linus Walleij
2026-08-22 22:06 ` Jonathan Cameron
2026-08-24 19:36 ` Yash Suthar
2026-08-15 17:57 ` [PATCH v2 3/3] iio: accel: bmc150: use iio_push_to_buffers_with_ts() Yash Suthar
2026-08-17 12:15 ` Linus Walleij
2026-08-16 23:46 ` [PATCH v2 0/3] iio: accel: bmc150: DMA-safe buffers and " Gabriel Rondon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260822230227.6fafb565@jic23-huawei \
--to=jic23@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=grondon@gmail.com \
--cc=hexlabsecurity@proton.me \
--cc=linusw@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=sakari.ailus@linux.intel.com \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=yashsuthar983@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox