]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
iio: orientation: hid-sensor-rotation: add timestamp hack to not break userspace
authorDavid Lechner <dlechner@baylibre.com>
Sun, 8 Mar 2026 01:44:09 +0000 (19:44 -0600)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 14 Mar 2026 12:15:58 +0000 (12:15 +0000)
commit79a86a6cc3669416a21fef32d0767d39ba84b3aa
treed0c64387a5137792d42516f8dbc9a84bbda2ccfe
parent9978d74031f25fde575bef3e4e3e35c5009091ce
iio: orientation: hid-sensor-rotation: add timestamp hack to not break userspace

Add a hack to push two timestamps in the hid-sensor-rotation scan data
to avoid breaking userspace applications that depend on the timestamp
being at the incorrect location in the scan data due to unintentional
misalignment in older kernels.

When this driver was written, the timestamp was in the correct location
because of the way iio_compute_scan_bytes() was implemented at the time.
(Samples were 24 bytes each.) Then commit 883f61653069 ("iio: buffer:
align the size of scan bytes to size of the largest element") changed
the computed scan_bytes to be a different size (32 bytes), which caused
iio_push_to_buffers_with_timestamp() to place the timestamp at an
incorrect offset.

There have been long periods of time (6 years each) where the timestamp
was in either location, so to not break either case, we open-code the
timestamps to be pushed to both locations in the scan data.

Reported-by: Jonathan Cameron <jic23@kernel.org>
Closes: https://lore.kernel.org/linux-iio/20260215162351.79f40b32@jic23-huawei/
Fixes: 883f61653069 ("iio: buffer: align the size of scan bytes to size of the largest element")
Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/orientation/hid-sensor-rotation.c