Linux IIO development
 help / color / mirror / Atom feed
* [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é
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ 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] 11+ 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-12  1:16 ` [PATCH v3 2/6] iio: gyro: HID: hid-sensor-gyro-3d: " Natália Salvino André
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ 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] 11+ 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-12  1:16 ` [PATCH v3 3/6] iio: light: HID: hid-sensor-als: " Natália Salvino André
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ 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] 11+ 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-12  1:16 ` [PATCH v3 4/6] iio: light: HID: hid-sensor-prox: " Natália Salvino André
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ 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] 11+ 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-12  1:16 ` [PATCH v3 5/6] iio: magnetometer: HID: hid-sensor-magn-3d: " Natália Salvino André
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ 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] 11+ 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-12  1:16 ` [PATCH v3 6/6] iio: pressure: HID: hid-sensor-press: " Natália Salvino André
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 11+ 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] 11+ 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-12 14:42 ` [PATCH v3 0/6] iio: hid-sensor: standardize scan_type initialization Jonathan Cameron
  2026-05-12 14:48 ` Jonathan Cameron
  7 siblings, 0 replies; 11+ 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] 11+ 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
  7 siblings, 1 reply; 11+ 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] 11+ 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
  7 siblings, 1 reply; 11+ 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] 11+ 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; 11+ 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] 11+ 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
  0 siblings, 0 replies; 11+ 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] 11+ messages in thread

end of thread, other threads:[~2026-05-13  3:27 UTC | newest]

Thread overview: 11+ 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-12  1:16 ` [PATCH v3 2/6] iio: gyro: HID: hid-sensor-gyro-3d: " Natália Salvino André
2026-05-12  1:16 ` [PATCH v3 3/6] iio: light: HID: hid-sensor-als: " Natália Salvino André
2026-05-12  1:16 ` [PATCH v3 4/6] iio: light: HID: hid-sensor-prox: " Natália Salvino André
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 ` [PATCH v3 6/6] iio: pressure: HID: hid-sensor-press: " Natália Salvino André
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

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