Skip to content

iio: hid-sensor: standardize scan_type initialization

Natália Salvino André linux-iio linux-input 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest6 patches 1 replyIn review
  2. v36 patches 8 repliesSuperseded

Changes in v4 from the cover letter

- Fixed a bug in the sensor_hub_input_get_attribute_info() call where passing the raw loop index 'ch' broke the HID report field lookup in hid-sensor-accel-3d. Restored the proper HID usage ID offset calculation using HID_USAGE_SENSOR_ACCEL_X_AXIS + ch
- Cleaned up the channel initialization loop to iterate directly over the scan indices in hid-sensor-gyro-3d for consistency

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6iio: accel: HID: hid-sensor-accel-3d: Refactor channel initializationdrivers/iio/accel/hid-sensor-accel-3d.c+9 -180 replies
2/6iio: gyro: HID: hid-sensor-gyro-3d: Refactor channel initializationdrivers/iio/gyro/hid-sensor-gyro-3d.c+9 -180 replies
3/6iio: light: HID: hid-sensor-als: Refactor channel initializationdrivers/iio/light/hid-sensor-als.c+6 -120 replies
4/6iio: light: HID: hid-sensor-prox: Refactor channel initializationdrivers/iio/light/hid-sensor-prox.c+6 -130 replies
5/6iio: magnetometer: HID: hid-sensor-magn-3d: Refactor channel initializationdrivers/iio/magnetometer/hid-sensor-magn-3d.c+6 -140 replies
6/6iio: pressure: HID: hid-sensor-press: Refactor channel initializationdrivers/iio/pressure/hid-sensor-press.c+6 -130 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH v4 0/6] iio: hid-sensor: standardize scan_type initialization

This series refactors the HID sensor drivers to standardize the initialization of the iio_chan_spec scan_type structure using compound literals.

This change improves code readability and ensures that all fields of the scan_type structure are properly zero-initialized, allowing the removal of local helper functions.

Additionally, the channel initialization loops for hid-sensor-accel-3d and hid-sensor-gyro-3d were cleaned up to iterate directly over the scan indices, eliminating redundant index-offset logic.

---

Changes in v4:

- Fixed a bug in the sensor_hub_input_get_attribute_info() call where passing the raw loop index 'ch' broke the HID report field lookup in hid-sensor-accel-3d. Restored the proper HID usage ID offset calculation using HID_USAGE_SENSOR_ACCEL_X_AXIS + ch
- Cleaned up the channel initialization loop to iterate directly over the scan indices in hid-sensor-gyro-3d for consistency

Changes in v3:

- Dropped the global helper function implementation from
hid-sensor-attributes.c following maintainer feedback.
- Shifted to local refactoring inside the drivers using compound
literals and the macros BYTES_TO_BITS() and BITS_PER_TYPE()
- Refactored the channel initialization loop in hid-sensor-accel-3d to
iterate directly over the scan enums instead of using 0-based
index offsets
- v3 link: https://lore.kernel.org/linux-iio/[email protected]/T/#t

Changes in v2:

- Modified the helper function to use the BITS_PER_BYTE macro instead of magic numbers for bit calculations
- Updated the scan_type structure field assignment from '.sign' to '.format' based on recent subsystem renaming feedback

Natália Salvino André (6):
iio: accel: HID: hid-sensor-accel-3d: Refactor channel initialization
iio: gyro: HID: hid-sensor-gyro-3d: Refactor channel initialization
iio: light: HID: hid-sensor-als: Refactor channel initialization
iio: light: HID: hid-sensor-prox: Refactor channel initialization
iio: magnetometer: HID: hid-sensor-magn-3d: Refactor channel
initialization
iio: pressure: HID: hid-sensor-press: Refactor channel initialization

 drivers/iio/accel/hid-sensor-accel-3d.c       | 27 +++++++------------
 drivers/iio/gyro/hid-sensor-gyro-3d.c         | 27 +++++++------------
 drivers/iio/light/hid-sensor-als.c            | 18 +++++--------
 drivers/iio/light/hid-sensor-prox.c           | 19 +++++--------
 drivers/iio/magnetometer/hid-sensor-magn-3d.c | 20 +++++---------
 drivers/iio/pressure/hid-sensor-press.c       | 19 +++++--------
 6 files changed, 42 insertions(+), 88 deletions(-)
Signature · 1 line
2.51.0