Re: [PATCH v3 2/3] iio: accel: bmc150: use DMA-safe buffers for regmap bulk reads

From: Jonathan Cameron

Date: Sun Aug 30 2026 - 20:25:03 EST


On Thu, 27 Aug 2026 10:05:19 +0300
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:

> On Tue, Aug 25, 2026 at 02:21:55PM +0530, Yash Suthar wrote:
> > The FIFO and read_raw buffers are passed to regmap bulk/raw reads,
> > which is not DMA-safe. Moved them into struct bmc150_accel_data
> > after scan, each buffer are protected by mutex, placing them
> > after ensure DMA safety.
>
> ...
>
> > j = 0;
> > iio_for_each_active_channel(indio_dev, bit)
> > - memcpy(&data->scan.channels[j++], &buffer[i * 3 + bit],
> > + memcpy(&data->scan.channels[j++],
> > + &data->fifo_buff[i * 3 + bit],
> > sizeof(data->scan.channels[0]));
>
> While this works, I find a bit confusing usage of [j++] and [0] together.
>
> IIUC the below is an equivalent
>
> iio_for_each_active_channel(indio_dev, bit) {
> __le16 *val = &data->scan.channels[j++];
>
> memcpy(val, &data->fifo_buff[i * 3 + bit], sizeof(val));
> }

This bit I fully agree with. Much more readable.
>
> and if go further we may use asm/byteorder.h macros instead of plain memcpy().
>
Here I'm lost. We are just moving little endian values around.

For that matter if it is a single value, why can't see just assign it?

iio_for_each_active_channel(indio_dev, bit)
data->scan.channels[j++] = data->fifo_buf[i * 3 + bit];




> ...
>
> Maybe this is for a separate change, I dunno. I leave it to others to decide.
>