Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH 0/2] HID: iio: Fix stale or zero quaternion reads with multi-byte read helper
@ 2026-06-10  8:29 Zhang Lixu
  2026-06-10  8:29 ` [PATCH 1/2] HID: sensor-hub: Add sensor_hub_input_attr_read_values() for multi-byte reads Zhang Lixu
  2026-06-10  8:29 ` [PATCH 2/2] iio: hid-sensor-rotation: Fix stale or zero output when reading raw values Zhang Lixu
  0 siblings, 2 replies; 7+ messages in thread
From: Zhang Lixu @ 2026-06-10  8:29 UTC (permalink / raw)
  To: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada,
	Benjamin Tissoires
  Cc: David Lechner, Nuno Sá, Andy Shevchenko, linux-input,
	linux-iio, linux-kernel, lixu.zhang

When reading in_rot_quaternion_raw from hid-sensor-rotation, the driver
returns either all zeros (if the sensor was never enabled) or stale data
(if previously enabled), because it reads from an internal buffer without
requesting a fresh sample from the device.

This series fixes the issue in two steps:

1. Add sensor_hub_input_attr_read_values() to the HID sensor hub core.
   Unlike sensor_hub_input_attr_get_raw_value(), which is limited to a
   single 32-bit value, the new helper accepts a caller-provided buffer
   and accumulates incoming input report data until the buffer is full.
   The two code paths are distinguished in sensor_hub_raw_event() by
   pending.max_raw_size being non-zero, preserving backward compatibility.

2. Switch hid-sensor-rotation to use the new helper for raw quaternion
   reads. It now powers up the sensor, issues a synchronous GET_REPORT,
   and receives all four quaternion components directly into a local
   buffer before decoding them, eliminating stale or zero output.

Srinivas Pandruvada (1):
  HID: sensor-hub: Add sensor_hub_input_attr_read_values() for
    multi-byte reads

Zhang Lixu (1):
  iio: hid-sensor-rotation: Fix stale or zero output when reading raw
    values

 drivers/hid/hid-sensor-hub.c                  | 77 +++++++++++++++++--
 drivers/iio/orientation/hid-sensor-rotation.c | 40 +++++++++-
 include/linux/hid-sensor-hub.h                | 25 ++++++
 3 files changed, 134 insertions(+), 8 deletions(-)


base-commit: 49e02880ec0a8c378e811bc9d85da188d7c6204c
-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-06-10 10:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-10  8:29 [PATCH 0/2] HID: iio: Fix stale or zero quaternion reads with multi-byte read helper Zhang Lixu
2026-06-10  8:29 ` [PATCH 1/2] HID: sensor-hub: Add sensor_hub_input_attr_read_values() for multi-byte reads Zhang Lixu
2026-06-10  8:38   ` sashiko-bot
2026-06-10 10:52   ` Andy Shevchenko
2026-06-10  8:29 ` [PATCH 2/2] iio: hid-sensor-rotation: Fix stale or zero output when reading raw values Zhang Lixu
2026-06-10  8:40   ` sashiko-bot
2026-06-10 10:53   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox