* [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization
@ 2026-05-12 1:16 Natália Salvino André
2026-05-12 1:16 ` [PATCH v3 1/6] iio: accel: HID: hid-sensor-accel-3d: Refactor channel initialization Natália Salvino André
` (8 more replies)
0 siblings, 9 replies; 20+ messages in thread
From: Natália Salvino André @ 2026-05-12 1:16 UTC (permalink / raw)
To: andy, dlechner, jic23, jikos, nuno.sa, srinivas.pandruvada
Cc: Natália Salvino André, linux-iio, linux-input
This series refactors the HID sensor drivers to standardize the
initialization of the iio_chan_spec scan_type structure.
Direct initialization using compound literals was used.
This change improves code readability and ensures that all fields
of the scan_type structure are properly zero-initialized.
Additionally, for the hid-sensor-accel-3d driver, the channel
initialization loop was refactored to iterate directly over the
scan indices, eliminating redundant logic.
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 | 24 +++++++----------
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(+), 85 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v3 1/6] iio: accel: HID: hid-sensor-accel-3d: Refactor channel initialization
2026-05-12 1:16 [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization Natália Salvino André
@ 2026-05-12 1:16 ` Natália Salvino André
2026-05-13 2:21 ` sashiko-bot
2026-05-12 1:16 ` [PATCH v3 2/6] iio: gyro: HID: hid-sensor-gyro-3d: " Natália Salvino André
` (7 subsequent siblings)
8 siblings, 1 reply; 20+ messages in thread
From: Natália Salvino André @ 2026-05-12 1:16 UTC (permalink / raw)
To: andy, dlechner, jic23, jikos, nuno.sa, srinivas.pandruvada
Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
linux-iio, linux-input
Clean up the channel initialization loop and replace the local
accel_3d_adjust_channel_bit_mask() function with a compound literal
to improve code readability.
Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br>
Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
---
drivers/iio/accel/hid-sensor-accel-3d.c | 27 +++++++++----------------
1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 2ff591b3458f..99ca67732bbe 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -3,6 +3,7 @@
* HID Sensors Driver
* Copyright (c) 2012, Intel Corporation.
*/
+#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/module.h>
@@ -119,17 +120,6 @@ static const struct iio_chan_spec gravity_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP),
};
-/* Adjust channel real bits based on report descriptor */
-static void accel_3d_adjust_channel_bit_mask(struct iio_chan_spec *channels,
- int channel, int size)
-{
- channels[channel].scan_type.sign = 's';
- /* Real storage bits will change based on the report desc. */
- channels[channel].scan_type.realbits = size * 8;
- /* Maximum size of a sample to capture is u32 */
- channels[channel].scan_type.storagebits = sizeof(u32) * 8;
-}
-
/* Channel read_raw handler */
static int accel_3d_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
@@ -297,19 +287,20 @@ static int accel_3d_parse_report(struct platform_device *pdev,
struct accel_3d_state *st)
{
int ret;
- int i;
- for (i = 0; i <= CHANNEL_SCAN_INDEX_Z; ++i) {
+ for (unsigned int ch = CHANNEL_SCAN_INDEX_X; ch <= CHANNEL_SCAN_INDEX_Z; ch++) {
ret = sensor_hub_input_get_attribute_info(hsdev,
HID_INPUT_REPORT,
usage_id,
- HID_USAGE_SENSOR_ACCEL_X_AXIS + i,
- &st->accel[CHANNEL_SCAN_INDEX_X + i]);
+ ch,
+ &st->accel[ch]);
if (ret < 0)
break;
- accel_3d_adjust_channel_bit_mask(channels,
- CHANNEL_SCAN_INDEX_X + i,
- st->accel[CHANNEL_SCAN_INDEX_X + i].size);
+ channels[ch].scan_type = (struct iio_scan_type) {
+ .format = 's',
+ .realbits = BYTES_TO_BITS(st->accel[ch].size),
+ .storagebits = BITS_PER_TYPE(u32),
+ };
}
dev_dbg(&pdev->dev, "accel_3d %x:%x, %x:%x, %x:%x\n",
st->accel[0].index,
--
2.51.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v3 2/6] iio: gyro: HID: hid-sensor-gyro-3d: Refactor channel initialization
2026-05-12 1:16 [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization Natália Salvino André
2026-05-12 1:16 ` [PATCH v3 1/6] iio: accel: HID: hid-sensor-accel-3d: Refactor channel initialization Natália Salvino André
@ 2026-05-12 1:16 ` Natália Salvino André
2026-05-13 2:50 ` sashiko-bot
2026-05-15 16:48 ` srinivas pandruvada
2026-05-12 1:16 ` [PATCH v3 3/6] iio: light: HID: hid-sensor-als: " Natália Salvino André
` (6 subsequent siblings)
8 siblings, 2 replies; 20+ messages in thread
From: Natália Salvino André @ 2026-05-12 1:16 UTC (permalink / raw)
To: andy, dlechner, jic23, jikos, nuno.sa, srinivas.pandruvada
Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
linux-iio, linux-input
Replace the local gyro_3d_adjust_channel_bit_mask() function with a
compound literal for scan_type initialization to improve code
readability.
Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br>
Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
---
drivers/iio/gyro/hid-sensor-gyro-3d.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index c340cc899a7c..4cbe4d93a0a1 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -3,6 +3,7 @@
* HID Sensors Driver
* Copyright (c) 2012, Intel Corporation.
*/
+#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/module.h>
@@ -82,17 +83,6 @@ static const struct iio_chan_spec gyro_3d_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP)
};
-/* Adjust channel real bits based on report descriptor */
-static void gyro_3d_adjust_channel_bit_mask(struct iio_chan_spec *channels,
- int channel, int size)
-{
- channels[channel].scan_type.sign = 's';
- /* Real storage bits will change based on the report desc. */
- channels[channel].scan_type.realbits = size * 8;
- /* Maximum size of a sample to capture is u32 */
- channels[channel].scan_type.storagebits = sizeof(u32) * 8;
-}
-
/* Channel read_raw handler */
static int gyro_3d_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
@@ -251,16 +241,20 @@ static int gyro_3d_parse_report(struct platform_device *pdev,
int i;
for (i = 0; i <= CHANNEL_SCAN_INDEX_Z; ++i) {
+ unsigned int ch = CHANNEL_SCAN_INDEX_X + i;
+
ret = sensor_hub_input_get_attribute_info(hsdev,
HID_INPUT_REPORT,
usage_id,
HID_USAGE_SENSOR_ANGL_VELOCITY_X_AXIS + i,
- &st->gyro[CHANNEL_SCAN_INDEX_X + i]);
+ &st->gyro[ch]);
if (ret < 0)
break;
- gyro_3d_adjust_channel_bit_mask(channels,
- CHANNEL_SCAN_INDEX_X + i,
- st->gyro[CHANNEL_SCAN_INDEX_X + i].size);
+ channels[ch].scan_type = (struct iio_scan_type) {
+ .format = 's',
+ .realbits = BYTES_TO_BITS(st->gyro[ch].size),
+ .storagebits = BITS_PER_TYPE(u32),
+ };
}
dev_dbg(&pdev->dev, "gyro_3d %x:%x, %x:%x, %x:%x\n",
st->gyro[0].index,
--
2.51.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v3 3/6] iio: light: HID: hid-sensor-als: Refactor channel initialization
2026-05-12 1:16 [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization Natália Salvino André
2026-05-12 1:16 ` [PATCH v3 1/6] iio: accel: HID: hid-sensor-accel-3d: Refactor channel initialization Natália Salvino André
2026-05-12 1:16 ` [PATCH v3 2/6] iio: gyro: HID: hid-sensor-gyro-3d: " Natália Salvino André
@ 2026-05-12 1:16 ` Natália Salvino André
2026-05-13 3:00 ` sashiko-bot
2026-05-12 1:16 ` [PATCH v3 4/6] iio: light: HID: hid-sensor-prox: " Natália Salvino André
` (5 subsequent siblings)
8 siblings, 1 reply; 20+ messages in thread
From: Natália Salvino André @ 2026-05-12 1:16 UTC (permalink / raw)
To: andy, dlechner, jic23, jikos, nuno.sa, srinivas.pandruvada
Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
linux-iio, linux-input
Replace the local als_adjust_channel_bit_mask() function with a
compound literal for scan_type initialization to improve code
readability.
Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br>
Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
---
drivers/iio/light/hid-sensor-als.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 384572844162..d72e260b8266 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -3,6 +3,7 @@
* HID Sensors Driver
* Copyright (c) 2012, Intel Corporation.
*/
+#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/module.h>
@@ -117,17 +118,6 @@ static const struct iio_chan_spec als_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP)
};
-/* Adjust channel real bits based on report descriptor */
-static void als_adjust_channel_bit_mask(struct iio_chan_spec *channels,
- int channel, int size)
-{
- channels[channel].scan_type.sign = 's';
- /* Real storage bits will change based on the report desc. */
- channels[channel].scan_type.realbits = size * 8;
- /* Maximum size of a sample to capture is u32 */
- channels[channel].scan_type.storagebits = sizeof(u32) * 8;
-}
-
/* Channel read_raw handler */
static int als_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
@@ -335,7 +325,11 @@ static int als_parse_report(struct platform_device *pdev,
channels[index] = als_channels[i];
st->als_scan_mask[0] |= BIT(i);
- als_adjust_channel_bit_mask(channels, index, st->als[i].size);
+ channels[index].scan_type = (struct iio_scan_type) {
+ .format = 's',
+ .realbits = BYTES_TO_BITS(st->als[i].size),
+ .storagebits = BITS_PER_TYPE(u32),
+ };
++index;
dev_dbg(&pdev->dev, "als %x:%x\n", st->als[i].index,
--
2.51.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v3 4/6] iio: light: HID: hid-sensor-prox: Refactor channel initialization
2026-05-12 1:16 [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization Natália Salvino André
` (2 preceding siblings ...)
2026-05-12 1:16 ` [PATCH v3 3/6] iio: light: HID: hid-sensor-als: " Natália Salvino André
@ 2026-05-12 1:16 ` Natália Salvino André
2026-05-13 3:10 ` sashiko-bot
2026-05-12 1:16 ` [PATCH v3 5/6] iio: magnetometer: HID: hid-sensor-magn-3d: " Natália Salvino André
` (4 subsequent siblings)
8 siblings, 1 reply; 20+ messages in thread
From: Natália Salvino André @ 2026-05-12 1:16 UTC (permalink / raw)
To: andy, dlechner, jic23, jikos, nuno.sa, srinivas.pandruvada
Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
linux-iio, linux-input
Replace the local prox_adjust_channel_bit_mask() function with a
compound literal for scan_type initialization to improve code
readability.
Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br>
Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
---
drivers/iio/light/hid-sensor-prox.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index efa904a70d0e..edc9274a2c07 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -3,6 +3,7 @@
* HID Sensors Driver
* Copyright (c) 2014, Intel Corporation.
*/
+#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/module.h>
@@ -67,17 +68,6 @@ static const struct iio_chan_spec prox_channels[] = {
PROX_CHANNEL(false, 0),
};
-/* Adjust channel real bits based on report descriptor */
-static void prox_adjust_channel_bit_mask(struct iio_chan_spec *channels,
- int channel, int size)
-{
- channels[channel].scan_type.sign = 's';
- /* Real storage bits will change based on the report desc. */
- channels[channel].scan_type.realbits = size * 8;
- /* Maximum size of a sample to capture is u32 */
- channels[channel].scan_type.storagebits = sizeof(u32) * 8;
-}
-
/* Channel read_raw handler */
static int prox_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
@@ -250,8 +240,11 @@ static int prox_parse_report(struct platform_device *pdev,
st->scan_mask[0] |= BIT(index);
channels[index] = prox_channels[i];
channels[index].scan_index = index;
- prox_adjust_channel_bit_mask(channels, index,
- st->prox_attr[index].size);
+ channels[index].scan_type = (struct iio_scan_type) {
+ .format = 's',
+ .realbits = BYTES_TO_BITS(st->prox_attr[index].size),
+ .storagebits = BITS_PER_TYPE(u32),
+ };
dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr[index].index,
st->prox_attr[index].report_id);
st->scale_precision[index] =
--
2.51.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v3 5/6] iio: magnetometer: HID: hid-sensor-magn-3d: Refactor channel initialization
2026-05-12 1:16 [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization Natália Salvino André
` (3 preceding siblings ...)
2026-05-12 1:16 ` [PATCH v3 4/6] iio: light: HID: hid-sensor-prox: " Natália Salvino André
@ 2026-05-12 1:16 ` Natália Salvino André
2026-05-13 3:19 ` sashiko-bot
2026-05-12 1:16 ` [PATCH v3 6/6] iio: pressure: HID: hid-sensor-press: " Natália Salvino André
` (3 subsequent siblings)
8 siblings, 1 reply; 20+ messages in thread
From: Natália Salvino André @ 2026-05-12 1:16 UTC (permalink / raw)
To: andy, dlechner, jic23, jikos, nuno.sa, srinivas.pandruvada
Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
linux-iio, linux-input
Replace the local magn_3d_adjust_channel_bit_mask() function with a
compound literal for scan_type initialization to improve code
readability.
Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br>
Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
---
drivers/iio/magnetometer/hid-sensor-magn-3d.c | 20 ++++++-------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index c673f9323e47..3b26dc41dd4c 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -3,6 +3,7 @@
* HID Sensors Driver
* Copyright (c) 2012, Intel Corporation.
*/
+#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/module.h>
@@ -132,17 +133,6 @@ static const struct iio_chan_spec magn_3d_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(7)
};
-/* Adjust channel real bits based on report descriptor */
-static void magn_3d_adjust_channel_bit_mask(struct iio_chan_spec *channels,
- int channel, int size)
-{
- channels[channel].scan_type.sign = 's';
- /* Real storage bits will change based on the report desc. */
- channels[channel].scan_type.realbits = size * 8;
- /* Maximum size of a sample to capture is u32 */
- channels[channel].scan_type.storagebits = sizeof(u32) * 8;
-}
-
/* Channel read_raw handler */
static int magn_3d_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
@@ -418,9 +408,11 @@ static int magn_3d_parse_report(struct platform_device *pdev,
if (i != CHANNEL_SCAN_INDEX_TIMESTAMP) {
/* Set magn_val_addr to iio value address */
st->magn_val_addr[i] = &st->iio_vals[*chan_count];
- magn_3d_adjust_channel_bit_mask(_channels,
- *chan_count,
- st->magn[i].size);
+ _channels[*chan_count].scan_type = (struct iio_scan_type) {
+ .format = 's',
+ .realbits = BYTES_TO_BITS(st->magn[i].size),
+ .storagebits = BITS_PER_TYPE(u32),
+ };
}
(*chan_count)++;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v3 6/6] iio: pressure: HID: hid-sensor-press: Refactor channel initialization
2026-05-12 1:16 [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization Natália Salvino André
` (4 preceding siblings ...)
2026-05-12 1:16 ` [PATCH v3 5/6] iio: magnetometer: HID: hid-sensor-magn-3d: " Natália Salvino André
@ 2026-05-12 1:16 ` Natália Salvino André
2026-05-13 3:30 ` sashiko-bot
2026-05-12 14:42 ` [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization Jonathan Cameron
` (2 subsequent siblings)
8 siblings, 1 reply; 20+ messages in thread
From: Natália Salvino André @ 2026-05-12 1:16 UTC (permalink / raw)
To: andy, dlechner, jic23, jikos, nuno.sa, srinivas.pandruvada
Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
linux-iio, linux-input
Replace the local press_adjust_channel_bit_mask() function with a
compound literal for scan_type initialization to improve code
readability.
Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br>
Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
---
drivers/iio/pressure/hid-sensor-press.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
index 5f1d6abda3e4..a039b99d9851 100644
--- a/drivers/iio/pressure/hid-sensor-press.c
+++ b/drivers/iio/pressure/hid-sensor-press.c
@@ -3,6 +3,7 @@
* HID Sensors Driver
* Copyright (c) 2014, Intel Corporation.
*/
+#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/module.h>
@@ -53,17 +54,6 @@ static const struct iio_chan_spec press_channels[] = {
};
-/* Adjust channel real bits based on report descriptor */
-static void press_adjust_channel_bit_mask(struct iio_chan_spec *channels,
- int channel, int size)
-{
- channels[channel].scan_type.sign = 's';
- /* Real storage bits will change based on the report desc. */
- channels[channel].scan_type.realbits = size * 8;
- /* Maximum size of a sample to capture is u32 */
- channels[channel].scan_type.storagebits = sizeof(u32) * 8;
-}
-
/* Channel read_raw handler */
static int press_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
@@ -225,8 +215,11 @@ static int press_parse_report(struct platform_device *pdev,
&st->press_attr);
if (ret < 0)
return ret;
- press_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_PRESSURE,
- st->press_attr.size);
+ channels[CHANNEL_SCAN_INDEX_PRESSURE].scan_type = (struct iio_scan_type) {
+ .format = 's',
+ .realbits = BYTES_TO_BITS(st->press_attr.size),
+ .storagebits = BITS_PER_TYPE(u32),
+ };
dev_dbg(&pdev->dev, "press %x:%x\n", st->press_attr.index,
st->press_attr.report_id);
--
2.51.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization
2026-05-12 1:16 [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization Natália Salvino André
` (5 preceding siblings ...)
2026-05-12 1:16 ` [PATCH v3 6/6] iio: pressure: HID: hid-sensor-press: " Natália Salvino André
@ 2026-05-12 14:42 ` Jonathan Cameron
2026-05-12 20:21 ` Andy Shevchenko
2026-05-12 14:48 ` Jonathan Cameron
2026-05-15 16:50 ` srinivas pandruvada
8 siblings, 1 reply; 20+ messages in thread
From: Jonathan Cameron @ 2026-05-12 14:42 UTC (permalink / raw)
To: Natália Salvino André
Cc: andy, dlechner, jikos, nuno.sa, srinivas.pandruvada, linux-iio,
linux-input
On Mon, 11 May 2026 22:16:16 -0300
Natália Salvino André <natalia.andre@ime.usp.br> wrote:
> This series refactors the HID sensor drivers to standardize the
> initialization of the iio_chan_spec scan_type structure.
> Direct initialization using compound literals was used.
>
> This change improves code readability and ensures that all fields
> of the scan_type structure are properly zero-initialized.
> Additionally, for the hid-sensor-accel-3d driver, the channel
> initialization loop was refactored to iterate directly over the
> scan indices, eliminating redundant logic.
Hi Natália,
I'm a little confused. How is this v3? Where is the change log?
I'll review it as a fresh series.
thanks
Jonathan
>
> 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 | 24 +++++++----------
> 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(+), 85 deletions(-)
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization
2026-05-12 1:16 [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization Natália Salvino André
` (6 preceding siblings ...)
2026-05-12 14:42 ` [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization Jonathan Cameron
@ 2026-05-12 14:48 ` Jonathan Cameron
2026-05-13 3:27 ` Zhang, Lixu
2026-05-14 2:44 ` Zhang, Lixu
2026-05-15 16:50 ` srinivas pandruvada
8 siblings, 2 replies; 20+ messages in thread
From: Jonathan Cameron @ 2026-05-12 14:48 UTC (permalink / raw)
To: Natália Salvino André
Cc: andy, dlechner, jikos, nuno.sa, srinivas.pandruvada, linux-iio,
linux-input, Zhang, Lixu
On Mon, 11 May 2026 22:16:16 -0300
Natália Salvino André <natalia.andre@ime.usp.br> wrote:
> This series refactors the HID sensor drivers to standardize the
> initialization of the iio_chan_spec scan_type structure.
> Direct initialization using compound literals was used.
>
> This change improves code readability and ensures that all fields
> of the scan_type structure are properly zero-initialized.
> Additionally, for the hid-sensor-accel-3d driver, the channel
> initialization loop was refactored to iterate directly over the
> scan indices, eliminating redundant logic.
Series looks good to me but I'll leave it on the list a while to
both let sashiko catch up and anyone else who wants to can have time
to look. Also ideally get some testing.
Lixu, if you don't mind, please can you give this a test on top
of the more radical refactor patches?
To me it looks safe enough but this is the sort of series that subtle
typos can hide in!
Thanks,
Jonathan
>
> 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 | 24 +++++++----------
> 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(+), 85 deletions(-)
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization
2026-05-12 14:42 ` [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization Jonathan Cameron
@ 2026-05-12 20:21 ` Andy Shevchenko
0 siblings, 0 replies; 20+ messages in thread
From: Andy Shevchenko @ 2026-05-12 20:21 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Natália Salvino André, andy, dlechner, jikos, nuno.sa,
srinivas.pandruvada, linux-iio, linux-input
On Tue, May 12, 2026 at 03:42:04PM +0100, Jonathan Cameron wrote:
> On Mon, 11 May 2026 22:16:16 -0300
> Natália Salvino André <natalia.andre@ime.usp.br> wrote:
>
> > This series refactors the HID sensor drivers to standardize the
> > initialization of the iio_chan_spec scan_type structure.
> > Direct initialization using compound literals was used.
> >
> > This change improves code readability and ensures that all fields
> > of the scan_type structure are properly zero-initialized.
> > Additionally, for the hid-sensor-accel-3d driver, the channel
> > initialization loop was refactored to iterate directly over the
> > scan indices, eliminating redundant logic.
> I'm a little confused. How is this v3? Where is the change log?
>
> I'll review it as a fresh series.
I remember seeing this series at least twice, so changelog is missing for sure.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v3 1/6] iio: accel: HID: hid-sensor-accel-3d: Refactor channel initialization
2026-05-12 1:16 ` [PATCH v3 1/6] iio: accel: HID: hid-sensor-accel-3d: Refactor channel initialization Natália Salvino André
@ 2026-05-13 2:21 ` sashiko-bot
0 siblings, 0 replies; 20+ messages in thread
From: sashiko-bot @ 2026-05-13 2:21 UTC (permalink / raw)
To: Natália Salvino André; +Cc: linux-input, dmitry.torokhov
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Incorrect HID attribute usage ID passed to `sensor_hub_input_get_attribute_info()`, breaking device initialization.
- [Low] Invalid struct member `.format` used in `struct iio_scan_type` initialization.
--
commit b8c3d6dce107c50c4bd37c0ec71526208891109a
Author: Natália Salvino André <natalia.andre@ime.usp.br>
iio: accel: HID: hid-sensor-accel-3d: Refactor channel initialization
This commit cleans up the channel initialization loop in the HID 3D
accelerometer driver. It replaces a local helper function with a compound
literal to directly initialize the channel scan type configuration.
> diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
> index 2ff591b3458f7..99ca67732bbe2 100644
> --- a/drivers/iio/accel/hid-sensor-accel-3d.c
> +++ b/drivers/iio/accel/hid-sensor-accel-3d.c
[ ... ]
> @@ -297,19 +287,20 @@ static int accel_3d_parse_report(struct platform_device *pdev,
> struct accel_3d_state *st)
> {
> int ret;
> - int i;
>
> - for (i = 0; i <= CHANNEL_SCAN_INDEX_Z; ++i) {
> + for (unsigned int ch = CHANNEL_SCAN_INDEX_X; ch <= CHANNEL_SCAN_INDEX_Z; ch++) {
> ret = sensor_hub_input_get_attribute_info(hsdev,
> HID_INPUT_REPORT,
> usage_id,
> - HID_USAGE_SENSOR_ACCEL_X_AXIS + i,
> - &st->accel[CHANNEL_SCAN_INDEX_X + i]);
> + ch,
The fourth argument to sensor_hub_input_get_attribute_info() is the
attribute usage ID. Previously, this passed HID_USAGE_SENSOR_ACCEL_X_AXIS + i.
Does passing the loop variable ch (which represents internal index values
like 0, 1, 2) prevent the driver from finding the accelerometer fields in
the HID report descriptor?
> + &st->accel[ch]);
> if (ret < 0)
> break;
> - accel_3d_adjust_channel_bit_mask(channels,
> - CHANNEL_SCAN_INDEX_X + i,
> - st->accel[CHANNEL_SCAN_INDEX_X + i].size);
> + channels[ch].scan_type = (struct iio_scan_type) {
> + .format = 's',
Does struct iio_scan_type have a format member? Looking at
include/linux/iio/iio.h, it appears the correct member name for this
field is sign.
> + .realbits = BYTES_TO_BITS(st->accel[ch].size),
> + .storagebits = BITS_PER_TYPE(u32),
> + };
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260512012302.20883-1-natalia.andre@ime.usp.br?part=1
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v3 2/6] iio: gyro: HID: hid-sensor-gyro-3d: Refactor channel initialization
2026-05-12 1:16 ` [PATCH v3 2/6] iio: gyro: HID: hid-sensor-gyro-3d: " Natália Salvino André
@ 2026-05-13 2:50 ` sashiko-bot
2026-05-15 16:48 ` srinivas pandruvada
1 sibling, 0 replies; 20+ messages in thread
From: sashiko-bot @ 2026-05-13 2:50 UTC (permalink / raw)
To: Natália Salvino André; +Cc: dmitry.torokhov, linux-input
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The struct iio_scan_type does not have a member named 'format', which causes a build failure.
--
commit 8a26f68e644f245021a8896a54c6e164b2d81277
Author: Natália Salvino André <natalia.andre@ime.usp.br>
iio: gyro: HID: hid-sensor-gyro-3d: Refactor channel initialization
This commit refactors the channel initialization in the hid-sensor-gyro-3d
driver by replacing the local gyro_3d_adjust_channel_bit_mask function with
a compound literal for scan_type initialization to improve readability.
> diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> index c43990c518f77..be8406da32f0e 100644
> --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
> +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
[ ... ]
> -/* Adjust channel real bits based on report descriptor */
> -static void gyro_3d_adjust_channel_bit_mask(struct iio_chan_spec *channels,
> - int channel, int size)
> -{
> - channels[channel].scan_type.sign = 's';
> - /* Real storage bits will change based on the report desc. */
> - channels[channel].scan_type.realbits = size * 8;
> - /* Maximum size of a sample to capture is u32 */
> - channels[channel].scan_type.storagebits = sizeof(u32) * 8;
> -}
> -
[ ... ]
> @@ -251,16 +241,20 @@ static int gyro_3d_parse_report(struct platform_device *pdev,
> int i;
>
> for (i = 0; i <= CHANNEL_SCAN_INDEX_Z; ++i) {
[ ... ]
> - gyro_3d_adjust_channel_bit_mask(channels,
> - CHANNEL_SCAN_INDEX_X + i,
> - st->gyro[CHANNEL_SCAN_INDEX_X + i].size);
> + channels[ch].scan_type = (struct iio_scan_type) {
> + .format = 's',
Will this cause a build failure?
Struct iio_scan_type defines the field as sign, not format. The original
code being replaced here correctly assigned the value using
channels[channel].scan_type.sign = 's'.
> + .realbits = BYTES_TO_BITS(st->gyro[ch].size),
> + .storagebits = BITS_PER_TYPE(u32),
> + };
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260512012302.20883-1-natalia.andre@ime.usp.br?part=2
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v3 3/6] iio: light: HID: hid-sensor-als: Refactor channel initialization
2026-05-12 1:16 ` [PATCH v3 3/6] iio: light: HID: hid-sensor-als: " Natália Salvino André
@ 2026-05-13 3:00 ` sashiko-bot
0 siblings, 0 replies; 20+ messages in thread
From: sashiko-bot @ 2026-05-13 3:00 UTC (permalink / raw)
To: Natália Salvino André; +Cc: dmitry.torokhov, linux-input
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The patch introduces a build error by initializing a non-existent `.format` field in `struct iio_scan_type`.
--
commit 0b0eb5f75d5c3745616a7e7de9ace24a35760cff
Author: Natália Salvino André <natalia.andre@ime.usp.br>
iio: light: HID: hid-sensor-als: Refactor channel initialization
This commit replaces the local als_adjust_channel_bit_mask() function
with a compound literal for scan_type initialization to improve code
readability.
> diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
> index 830e5ae7f34a7..e5b4c5e80f1cf 100644
> --- a/drivers/iio/light/hid-sensor-als.c
> +++ b/drivers/iio/light/hid-sensor-als.c
[ ... ]
> @@ -334,7 +324,11 @@ static int als_parse_report(struct platform_device *pdev,
>
> channels[index] = als_channels[i];
> st->als_scan_mask[0] |= BIT(i);
> - als_adjust_channel_bit_mask(channels, index, st->als[i].size);
> + channels[index].scan_type = (struct iio_scan_type) {
> + .format = 's',
Does this cause a build failure? Looking at struct iio_scan_type in
include/linux/iio/iio.h, there is no field named format.
The removed code assigned this value to the sign field:
channels[channel].scan_type.sign = 's';
Should this compound literal initialize .sign instead of .format?
> + .realbits = BYTES_TO_BITS(st->als[i].size),
> + .storagebits = BITS_PER_TYPE(u32),
> + };
> ++index;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260512012302.20883-1-natalia.andre@ime.usp.br?part=3
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v3 4/6] iio: light: HID: hid-sensor-prox: Refactor channel initialization
2026-05-12 1:16 ` [PATCH v3 4/6] iio: light: HID: hid-sensor-prox: " Natália Salvino André
@ 2026-05-13 3:10 ` sashiko-bot
0 siblings, 0 replies; 20+ messages in thread
From: sashiko-bot @ 2026-05-13 3:10 UTC (permalink / raw)
To: Natália Salvino André; +Cc: dmitry.torokhov, linux-input
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The patch introduces a compilation error by incorrectly initializing a non-existent '.format' field in `struct iio_scan_type`.
--
commit b9cbff53934f8976c34e3030a4b171bfc276e140
Author: Natália Salvino André <natalia.andre@ime.usp.br>
iio: light: HID: hid-sensor-prox: Refactor channel initialization
This commit refactors the initialization of the scan_type field for proximity
sensor channels by replacing the prox_adjust_channel_bit_mask() function with
a compound literal.
> diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
> index efa904a70d0ef..edc9274a2c076 100644
> --- a/drivers/iio/light/hid-sensor-prox.c
> +++ b/drivers/iio/light/hid-sensor-prox.c
[ ... ]
> @@ -250,8 +240,11 @@ static int prox_parse_report(struct platform_device *pdev,
> st->scan_mask[0] |= BIT(index);
> channels[index] = prox_channels[i];
> channels[index].scan_index = index;
> - prox_adjust_channel_bit_mask(channels, index,
> - st->prox_attr[index].size);
> + channels[index].scan_type = (struct iio_scan_type) {
> + .format = 's',
Will this cause a compilation error? struct iio_scan_type does not have a
member named format. The previous code set the sign member to 's'. Should
this be .sign instead of .format?
> + .realbits = BYTES_TO_BITS(st->prox_attr[index].size),
> + .storagebits = BITS_PER_TYPE(u32),
> + };
> dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr[index].index,
> st->prox_attr[index].report_id);
> st->scale_precision[index] =
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260512012302.20883-1-natalia.andre@ime.usp.br?part=4
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v3 5/6] iio: magnetometer: HID: hid-sensor-magn-3d: Refactor channel initialization
2026-05-12 1:16 ` [PATCH v3 5/6] iio: magnetometer: HID: hid-sensor-magn-3d: " Natália Salvino André
@ 2026-05-13 3:19 ` sashiko-bot
0 siblings, 0 replies; 20+ messages in thread
From: sashiko-bot @ 2026-05-13 3:19 UTC (permalink / raw)
To: Natália Salvino André; +Cc: dmitry.torokhov, linux-input
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The refactored code uses a non-existent member `.format` in `struct iio_scan_type` instead of `.sign`, leading to a compilation error.
--
commit 579bb9f2450aced0e3f18e7e7316e70845e6e72b
Author: Natália Salvino André <natalia.andre@ime.usp.br>
iio: magnetometer: HID: hid-sensor-magn-3d: Refactor channel initialization
This commit replaces the local magn_3d_adjust_channel_bit_mask() function
with a compound literal for scan_type initialization to improve code
readability.
> diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
> index c673f9323e476..3b26dc41dd4cf 100644
> --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
> +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
[ ... ]
> @@ -418,9 +408,11 @@ static int magn_3d_parse_report(struct platform_device *pdev,
> if (i != CHANNEL_SCAN_INDEX_TIMESTAMP) {
> /* Set magn_val_addr to iio value address */
> st->magn_val_addr[i] = &st->iio_vals[*chan_count];
> - magn_3d_adjust_channel_bit_mask(_channels,
> - *chan_count,
> - st->magn[i].size);
> + _channels[*chan_count].scan_type = (struct iio_scan_type) {
> + .format = 's',
Will this regression cause a compilation error?
Looking at struct iio_scan_type in include/linux/iio/iio.h, there is a member
named sign, but no member named format.
For example, other channel setups use sign:
include/linux/iio/iio.h:
#define IIO_CHAN_SOFT_TIMESTAMP(_si) { \
... \
.scan_type = { \
.sign = 's', \
.realbits = 64, \
.storagebits = 64, \
}, \
}
Should this compound literal be updated to use .sign = 's' instead?
> + .realbits = BYTES_TO_BITS(st->magn[i].size),
> + .storagebits = BITS_PER_TYPE(u32),
> + };
> }
> (*chan_count)++;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260512012302.20883-1-natalia.andre@ime.usp.br?part=5
^ permalink raw reply [flat|nested] 20+ messages in thread
* RE: [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization
2026-05-12 14:48 ` Jonathan Cameron
@ 2026-05-13 3:27 ` Zhang, Lixu
2026-05-14 2:44 ` Zhang, Lixu
1 sibling, 0 replies; 20+ messages in thread
From: Zhang, Lixu @ 2026-05-13 3:27 UTC (permalink / raw)
To: Jonathan Cameron, Natália Salvino André
Cc: andy@kernel.org, Lechner, David, jikos@kernel.org,
nuno.sa@analog.com, srinivas.pandruvada@linux.intel.com,
linux-iio@vger.kernel.org, linux-input@vger.kernel.org
>-----Original Message-----
>From: Jonathan Cameron <jic23@kernel.org>
>Sent: Tuesday, May 12, 2026 10:49 PM
>To: Natália Salvino André <natalia.andre@ime.usp.br>
>Cc: andy@kernel.org; Lechner, David <dlechner@baylibre.com>;
>jikos@kernel.org; nuno.sa@analog.com; srinivas.pandruvada@linux.intel.com;
>linux-iio@vger.kernel.org; linux-input@vger.kernel.org; Zhang, Lixu
><lixu.zhang@intel.com>
>Subject: Re: [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization
>
>On Mon, 11 May 2026 22:16:16 -0300
>Natália Salvino André <natalia.andre@ime.usp.br> wrote:
>
>> This series refactors the HID sensor drivers to standardize the
>> initialization of the iio_chan_spec scan_type structure.
>> Direct initialization using compound literals was used.
>>
>> This change improves code readability and ensures that all fields of
>> the scan_type structure are properly zero-initialized.
>> Additionally, for the hid-sensor-accel-3d driver, the channel
>> initialization loop was refactored to iterate directly over the scan
>> indices, eliminating redundant logic.
>
>Series looks good to me but I'll leave it on the list a while to both let sashiko catch
>up and anyone else who wants to can have time to look. Also ideally get some
>testing.
>
>Lixu, if you don't mind, please can you give this a test on top of the more radical
>refactor patches?
Sure, I'll test this series on top of the refactor patches when I have some time.
Thanks,
Lixu
>
>To me it looks safe enough but this is the sort of series that subtle typos can hide
>in!
>
>Thanks,
>
>Jonathan
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v3 6/6] iio: pressure: HID: hid-sensor-press: Refactor channel initialization
2026-05-12 1:16 ` [PATCH v3 6/6] iio: pressure: HID: hid-sensor-press: " Natália Salvino André
@ 2026-05-13 3:30 ` sashiko-bot
0 siblings, 0 replies; 20+ messages in thread
From: sashiko-bot @ 2026-05-13 3:30 UTC (permalink / raw)
To: Natália Salvino André; +Cc: dmitry.torokhov, linux-input
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The struct iio_scan_type compound literal uses a non-existent field `.format` instead of `.sign`.
--
commit a042b8c22df5e0522e82213c0d6f025b115babe7
Author: Natália Salvino André <natalia.andre@ime.usp.br>
iio: pressure: HID: hid-sensor-press: Refactor channel initialization
This commit refactors the initialization of the pressure sensor's scan_type
by replacing a local helper function with a compound literal to improve
code readability.
> diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
> index 5f1d6abda3e40..a039b99d9851d 100644
> --- a/drivers/iio/pressure/hid-sensor-press.c
> +++ b/drivers/iio/pressure/hid-sensor-press.c
[ ... ]
> @@ -225,8 +215,11 @@ static int press_parse_report(struct platform_device *pdev,
> &st->press_attr);
> if (ret < 0)
> return ret;
> - press_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_PRESSURE,
> - st->press_attr.size);
> + channels[CHANNEL_SCAN_INDEX_PRESSURE].scan_type = (struct iio_scan_type) {
> + .format = 's',
Is .format correct here? Looking at struct iio_scan_type in
include/linux/iio/iio.h, it appears the member for indicating the sign is
named .sign, not .format.
Could this assignment cause a compilation error due to a missing member?
> + .realbits = BYTES_TO_BITS(st->press_attr.size),
> + .storagebits = BITS_PER_TYPE(u32),
> + };
>
> dev_dbg(&pdev->dev, "press %x:%x\n", st->press_attr.index,
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260512012302.20883-1-natalia.andre@ime.usp.br?part=6
^ permalink raw reply [flat|nested] 20+ messages in thread
* RE: [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization
2026-05-12 14:48 ` Jonathan Cameron
2026-05-13 3:27 ` Zhang, Lixu
@ 2026-05-14 2:44 ` Zhang, Lixu
1 sibling, 0 replies; 20+ messages in thread
From: Zhang, Lixu @ 2026-05-14 2:44 UTC (permalink / raw)
To: Jonathan Cameron, Natália Salvino André
Cc: andy@kernel.org, Lechner, David, jikos@kernel.org,
nuno.sa@analog.com, srinivas.pandruvada@linux.intel.com,
linux-iio@vger.kernel.org, linux-input@vger.kernel.org
>-----Original Message-----
>From: Zhang, Lixu
>Sent: Wednesday, May 13, 2026 11:27 AM
>To: Jonathan Cameron <jic23@kernel.org>; Natália Salvino André
><natalia.andre@ime.usp.br>
>Cc: andy@kernel.org; Lechner, David <dlechner@baylibre.com>;
>jikos@kernel.org; nuno.sa@analog.com; srinivas.pandruvada@linux.intel.com;
>linux-iio@vger.kernel.org; linux-input@vger.kernel.org
>Subject: RE: [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization
>
>>-----Original Message-----
>>From: Jonathan Cameron <jic23@kernel.org>
>>Sent: Tuesday, May 12, 2026 10:49 PM
>>To: Natália Salvino André <natalia.andre@ime.usp.br>
>>Cc: andy@kernel.org; Lechner, David <dlechner@baylibre.com>;
>>jikos@kernel.org; nuno.sa@analog.com;
>>srinivas.pandruvada@linux.intel.com;
>>linux-iio@vger.kernel.org; linux-input@vger.kernel.org; Zhang, Lixu
>><lixu.zhang@intel.com>
>>Subject: Re: [PATCH v3 0/6] iio: hid-sensor: standardize scan_type
>>initialization
>>
>>On Mon, 11 May 2026 22:16:16 -0300
>>Natália Salvino André <natalia.andre@ime.usp.br> wrote:
>>
>>> This series refactors the HID sensor drivers to standardize the
>>> initialization of the iio_chan_spec scan_type structure.
>>> Direct initialization using compound literals was used.
>>>
>>> This change improves code readability and ensures that all fields of
>>> the scan_type structure are properly zero-initialized.
>>> Additionally, for the hid-sensor-accel-3d driver, the channel
>>> initialization loop was refactored to iterate directly over the scan
>>> indices, eliminating redundant logic.
>>
>>Series looks good to me but I'll leave it on the list a while to both
>>let sashiko catch up and anyone else who wants to can have time to
>>look. Also ideally get some testing.
>>
>>Lixu, if you don't mind, please can you give this a test on top of the
>>more radical refactor patches?
>
>Sure, I'll test this series on top of the refactor patches when I have some time.
Hi Jonathan,
I've done some basic testing on this series. Here are the results:
1. No issues seen for hid-sensor-gyro-3d, hid-sensor-als, hid-sensor-prox, hid-sensor-magn-3d.
2. Didn't test hid-sensor-press as I couldn't find a platform with the corresponding device.
3. There's an issue with hid-sensor-accel-3d. Sashiko AI review has already identified the problem and provided review comments.
Thanks,
Lixu
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v3 2/6] iio: gyro: HID: hid-sensor-gyro-3d: Refactor channel initialization
2026-05-12 1:16 ` [PATCH v3 2/6] iio: gyro: HID: hid-sensor-gyro-3d: " Natália Salvino André
2026-05-13 2:50 ` sashiko-bot
@ 2026-05-15 16:48 ` srinivas pandruvada
1 sibling, 0 replies; 20+ messages in thread
From: srinivas pandruvada @ 2026-05-15 16:48 UTC (permalink / raw)
To: Natália Salvino André, andy, dlechner, jic23, jikos,
nuno.sa
Cc: Pietro Di Consolo Gregorio, linux-iio, linux-input
On Mon, 2026-05-11 at 22:16 -0300, Natália Salvino André wrote:
> Replace the local gyro_3d_adjust_channel_bit_mask() function with a
> compound literal for scan_type initialization to improve code
> readability.
>
> Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br>
> Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
> Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
> ---
> drivers/iio/gyro/hid-sensor-gyro-3d.c | 24 +++++++++---------------
> 1 file changed, 9 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c
> b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> index c340cc899a7c..4cbe4d93a0a1 100644
> --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
> +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> @@ -3,6 +3,7 @@
> * HID Sensors Driver
> * Copyright (c) 2012, Intel Corporation.
> */
> +#include <linux/bitops.h>
> #include <linux/device.h>
> #include <linux/platform_device.h>
> #include <linux/module.h>
> @@ -82,17 +83,6 @@ static const struct iio_chan_spec
> gyro_3d_channels[] = {
> IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP)
> };
>
> -/* Adjust channel real bits based on report descriptor */
> -static void gyro_3d_adjust_channel_bit_mask(struct iio_chan_spec
> *channels,
> - int channel, int
> size)
> -{
> - channels[channel].scan_type.sign = 's';
> - /* Real storage bits will change based on the report desc.
> */
> - channels[channel].scan_type.realbits = size * 8;
> - /* Maximum size of a sample to capture is u32 */
> - channels[channel].scan_type.storagebits = sizeof(u32) * 8;
> -}
> -
> /* Channel read_raw handler */
> static int gyro_3d_read_raw(struct iio_dev *indio_dev,
> struct iio_chan_spec const *chan,
> @@ -251,16 +241,20 @@ static int gyro_3d_parse_report(struct
> platform_device *pdev,
> int i;
>
> for (i = 0; i <= CHANNEL_SCAN_INDEX_Z; ++i) {
> + unsigned int ch = CHANNEL_SCAN_INDEX_X + i;
> +
When you do code change more than what you described, then you should
add to commit description that you are also doing this at the same
time.
Thanks,
Srinivas
> ret = sensor_hub_input_get_attribute_info(hsdev,
> HID_INPUT_REPORT,
> usage_id,
> HID_USAGE_SENSOR_ANGL_VELOCITY_X_AXI
> S + i,
> - &st->gyro[CHANNEL_SCAN_INDEX_X +
> i]);
> + &st->gyro[ch]);
> if (ret < 0)
> break;
> - gyro_3d_adjust_channel_bit_mask(channels,
> - CHANNEL_SCAN_INDEX_X + i,
> - st->gyro[CHANNEL_SCAN_INDEX_X +
> i].size);
> + channels[ch].scan_type = (struct iio_scan_type) {
> + .format = 's',
> + .realbits = BYTES_TO_BITS(st-
> >gyro[ch].size),
> + .storagebits = BITS_PER_TYPE(u32),
> + };
> }
> dev_dbg(&pdev->dev, "gyro_3d %x:%x, %x:%x, %x:%x\n",
> st->gyro[0].index,
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization
2026-05-12 1:16 [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization Natália Salvino André
` (7 preceding siblings ...)
2026-05-12 14:48 ` Jonathan Cameron
@ 2026-05-15 16:50 ` srinivas pandruvada
8 siblings, 0 replies; 20+ messages in thread
From: srinivas pandruvada @ 2026-05-15 16:50 UTC (permalink / raw)
To: Natália Salvino André, andy, dlechner, jic23, jikos,
nuno.sa
Cc: linux-iio, linux-input
On Mon, 2026-05-11 at 22:16 -0300, Natália Salvino André wrote:
> This series refactors the HID sensor drivers to standardize the
> initialization of the iio_chan_spec scan_type structure.
> Direct initialization using compound literals was used.
>
> This change improves code readability and ensures that all fields
> of the scan_type structure are properly zero-initialized.
> Additionally, for the hid-sensor-accel-3d driver, the channel
> initialization loop was refactored to iterate directly over the
> scan indices, eliminating redundant logic.
>
From manual check the change looks good, with some minor comment.
Thanks,
Srinivas
> 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 | 24 +++++++----------
> 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(+), 85 deletions(-)
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2026-05-15 16:50 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-12 1:16 [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization Natália Salvino André
2026-05-12 1:16 ` [PATCH v3 1/6] iio: accel: HID: hid-sensor-accel-3d: Refactor channel initialization Natália Salvino André
2026-05-13 2:21 ` sashiko-bot
2026-05-12 1:16 ` [PATCH v3 2/6] iio: gyro: HID: hid-sensor-gyro-3d: " Natália Salvino André
2026-05-13 2:50 ` sashiko-bot
2026-05-15 16:48 ` srinivas pandruvada
2026-05-12 1:16 ` [PATCH v3 3/6] iio: light: HID: hid-sensor-als: " Natália Salvino André
2026-05-13 3:00 ` sashiko-bot
2026-05-12 1:16 ` [PATCH v3 4/6] iio: light: HID: hid-sensor-prox: " Natália Salvino André
2026-05-13 3:10 ` sashiko-bot
2026-05-12 1:16 ` [PATCH v3 5/6] iio: magnetometer: HID: hid-sensor-magn-3d: " Natália Salvino André
2026-05-13 3:19 ` sashiko-bot
2026-05-12 1:16 ` [PATCH v3 6/6] iio: pressure: HID: hid-sensor-press: " Natália Salvino André
2026-05-13 3:30 ` sashiko-bot
2026-05-12 14:42 ` [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization Jonathan Cameron
2026-05-12 20:21 ` Andy Shevchenko
2026-05-12 14:48 ` Jonathan Cameron
2026-05-13 3:27 ` Zhang, Lixu
2026-05-14 2:44 ` Zhang, Lixu
2026-05-15 16:50 ` srinivas pandruvada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox