Re: [PATCH v2] iio: accel: adxl372: Add timestamp to FIFO data
From: Stepan Ionichev
Date: Sun May 17 2026 - 03:15:04 EST
On Sat, May 16, 2026, Md Shofiqul Islam wrote:
> + iio_push_to_buffers_with_ts(indio_dev, &st->fifo_buf[i],
> + st->fifo_set_size * sizeof(__be16),
> + ts);
On top of David's note about the size argument, the bigger issue is
that iio_push_to_buffers_with_ts() writes the timestamp into the
buffer it was given, at offset (scan_bytes - sizeof(s64)) from the
passed pointer. For the 3-channel scan here scan_bytes is 16, so the
s64 lands at &fifo_buf[i + 4]. With fifo_set_size == 3 that overlaps
the next iteration's samples in the same array, so the following
push reads partially overwritten data.
iio_push_to_buffers_with_ts_unaligned() copies into an internal
aligned bounce buffer instead and does not touch the caller's data,
which fits this looped FIFO-drain pattern. Alternatively, the v1
shape with a small local scan struct and a memcpy per iteration
works too.
Stepan