[PATCH 0/4] iio: buffer: fix timestamp alignment (in rare case)

From: David Lechner

Date: Sun Mar 01 2026 - 15:25:44 EST


In [1], it was pointed out that the iio_push_to_buffers_with_timestamp()
function is not putting the timestamp at the correct offset in the scan
buffer in rare cases where the largest scan element size is larger than
sizeof(int64_t).

[1]: https://lore.kernel.org/linux-iio/20260215162351.79f40b32@jic23-huawei/

This only affected one driver, namely hid-sensor-rotation since it is
the only driver that meets the condition. To fix things up, first we
fix the hid-sensor-rotation driver in a way that preserves compatibility
with the broken timestamp alignment. Then we are free to fix the core
IIO code without affecting any users.

Signed-off-by: David Lechner <dlechner@xxxxxxxxxxxx>
---
David Lechner (4):
iio: orientation: hid-sensor-rotation: add timestamp hack to not break userspace
iio: buffer: check return value of iio_compute_scan_bytes()
iio: buffer: cache largest scan element size
iio: buffer: fix timestamp alignment when quaternion in scan

drivers/iio/industrialio-buffer.c | 44 ++++++++++++++++++++-------
drivers/iio/orientation/hid-sensor-rotation.c | 20 ++++++++++--
include/linux/iio/buffer.h | 12 ++++++--
include/linux/iio/iio.h | 3 ++
4 files changed, 63 insertions(+), 16 deletions(-)
---
base-commit: 3fa5e5702a82d259897bd7e209469bc06368bf31
change-id: 20260228-iio-fix-timestamp-alignment-89ade1af458b

Best regards,
--
David Lechner <dlechner@xxxxxxxxxxxx>