Skip to content

HID: iio: Fix stale or zero quaternion reads with multi-byte read helper

Zhang Lixu linux-iio linux-input lkml 1 version Applied

Status from this message: Applied to the fixes-togreg branch of iio.git.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 7 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2HID: sensor-hub: Add sensor_hub_input_attr_read_values() for multi-byte readsdrivers/hid/hid-sensor-hub.c include/linux/hid-sensor-hub.h+96 -63 replies
2/2iio: hid-sensor-rotation: Fix stale or zero output when reading raw valuesdrivers/iio/orientation/hid-sensor-rotation.c+38 -24 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchAndy ShevchenkoJiri Kosina
1/2R-b A-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] HID: iio: Fix stale or zero quaternion reads with multi-byte read helper

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

Signature · 1 line
2.43.0