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

From: Andy Shevchenko

Date: Thu Aug 27 2026 - 03:09:29 EST


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));
}

and if go further we may use asm/byteorder.h macros instead of plain memcpy().

...

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

--
With Best Regards,
Andy Shevchenko