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

Andy Shevchenko <[email protected]>
Newsgroups org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Organization Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.