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

David Lechner posted 4 patches 1 month, 2 weeks ago
There is a newer version of this series
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(-)
[PATCH 0/4] iio: buffer: fix timestamp alignment (in rare case)
Posted by David Lechner 1 month, 2 weeks ago
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@baylibre.com>
---
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@baylibre.com>