Re: [PATCH v2] iio: accel: bmc150: use IIO_DECLARE_BUFFER_WITH_TS

Yash Suthar <[email protected]>
Newsgroups org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Mon, Aug 10, 2026 at 12:00:05PM +0300, Andy Shevchenko wrote:
> > So what is going on here?
>
> AI slop?

No. I only intended to convert buffer to IIO_DECLARE_BUFFER_WITH_TS() and dont
want to mix it with the existing scan member. Really sorry for that i should 
have asked.

On Mon, Aug 10, 2026 at 12:18:52AM +0100, Jonathan Cameron wrote:
> Given the data alignment is fixed, if we were going to do this it would
> be clearer as
> struct {
> 	s16 chans[3]; //see later, I believe this should be __le16
> 	aligned_s64 timestamp;
> };
>
> But that is very similar to the structure that follows immediately after
> this, but that has __le16 chans[]
>
> So what is going on here?
> ...
> The chan spec is little endian so the scan one is more correct.
>
> So I think the fix for this issue is move the scan element to the end of
> struct bmc150_accel_data and mark it with __aligned(IIO_DMA_MINALIGN);
>
> Then use that for both the bmc150_accel_trigger_handler() and
> __bmc150_accel_fifo_flush() paths.  A second fix will resolve the local
> buffer in __bmc150_accel_fifo_flush() that is being used for a bulk
> regmap transfer that may need a dma safe buffer.
>
> Please combine these two fixes (if you agree with my analysis) with a
> follow up to do the iio_push_to_buffers_with_ts() all in one series
> as they will be touching the same code.

Thanks, Jonathan.
I agree with your analysis.

On type, kept s16 because that was the originally used.
I'll keep __le16 and will merge buffer and scan together as you suggested.
Will move scan to the end with __aligned(IIO_DMA_MINALIGN) and use it for both
trigger handler and fifo flush.
A separate patch for the FIFO stack buffer and keep the
iio_push_to_buffers_with_ts() change in the same.

Yash Suthar
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.