Re: [PATCH 4/4] iio: buffer: fix timestamp alignment when quaternion in scan

From: Andy Shevchenko

Date: Mon Mar 02 2026 - 03:49:39 EST


On Sun, Mar 01, 2026 at 02:24:53PM -0600, David Lechner wrote:
> Fix timestamp alignment when a scan buffer contains an element larger
> than sizeof(int64_t). Currently s32 quaternions are the only such
> element, and the one driver that has this (hid-sensor-rotation) has a
> workaround in place already so this change does not affect it.
>
> Previously, we assumed that the timestamp would always be 8-byte aligned
> relative to the end of the scan buffer, but in the case of a scan buffer
> a 16-byte quaternion vector, scan_bytes == 32, but the timestamp needs
> to be placed at offset 16, not 24.

...

> - ((int64_t *)data)[ts_offset] = timestamp;

> + *(int64_t *)(data + ts_offset) = timestamp;

What's the point in modifying this? The comment you added suffice for
the original line.

--
With Best Regards,
Andy Shevchenko