* [PATCH v2 0/7] Add helper method hid_sensor_adjust_channel_bit_mask()
@ 2026-04-21 22:20 Natália Salvino André
2026-04-21 22:20 ` [PATCH v2 1/7] iio: HID: " Natália Salvino André
` (7 more replies)
0 siblings, 8 replies; 16+ messages in thread
From: Natália Salvino André @ 2026-04-21 22:20 UTC (permalink / raw)
To: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
srinivas.pandruvada
Cc: Natália Salvino André, linux-iio, linux-input
This patch series introduces a generic helper function to handle channel bit mask adjustments
for HID sensors. Currently, multiple drivers implement identical logic for this task
Natália Salvino André (7):
iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask()
iio: accel: HID: Replace method accel_3d_adjust_channel_bit_mask()
iio: gyro: HID: Replace method gyro_3d_adjust_channel_bit_mask()
iio: light: HID: Replace method als_adjust_channel_bit_mask()
iio: light: HID: Replace method prox_adjust_channel_bit_mask()
iio: magnetometer: HID: Replace method
magn_3d_adjust_channel_bit_mask()
iio: pressure: HID: Replace method press_adjust_channel_bit_mask()
drivers/iio/accel/hid-sensor-accel-3d.c | 17 +++--------------
.../common/hid-sensors/hid-sensor-attributes.c | 12 ++++++++++++
drivers/iio/gyro/hid-sensor-gyro-3d.c | 17 +++--------------
drivers/iio/light/hid-sensor-als.c | 13 +------------
drivers/iio/light/hid-sensor-prox.c | 15 ++-------------
drivers/iio/magnetometer/hid-sensor-magn-3d.c | 17 +++--------------
drivers/iio/pressure/hid-sensor-press.c | 15 ++-------------
include/linux/hid-sensor-hub.h | 3 +++
8 files changed, 29 insertions(+), 80 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 1/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask()
2026-04-21 22:20 [PATCH v2 0/7] Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-21 22:20 ` Natália Salvino André
2026-04-22 9:03 ` Andy Shevchenko
2026-04-21 22:20 ` [PATCH v2 2/7] iio: accel: HID: Replace method accel_3d_adjust_channel_bit_mask() Natália Salvino André
` (6 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Natália Salvino André @ 2026-04-21 22:20 UTC (permalink / raw)
To: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
srinivas.pandruvada
Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
linux-iio, linux-input
Add helper method to deduplicate code in HID sensors.
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>
---
.../iio/common/hid-sensors/hid-sensor-attributes.c | 12 ++++++++++++
include/linux/hid-sensor-hub.h | 3 +++
2 files changed, 15 insertions(+)
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
index c115a72832b2..3ee6e83c6cac 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
@@ -3,6 +3,7 @@
* HID Sensors Driver
* Copyright (c) 2012, Intel Corporation.
*/
+#include <linux/bits.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/time.h>
@@ -589,6 +590,17 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
}
EXPORT_SYMBOL_NS(hid_sensor_parse_common_attributes, "IIO_HID");
+void hid_sensor_adjust_channel_bit_mask(struct iio_chan_spec *channels,
+ int channel, int size)
+{
+ channels[channel].scan_type.format = 's';
+ /* Real storage bits will change based on the report desc. */
+ channels[channel].scan_type.realbits = size * BITS_PER_BYTE;
+ /* Maximum size of a sample to capture is u32 */
+ channels[channel].scan_type.storagebits = sizeof(u32) * BITS_PER_BYTE;
+}
+EXPORT_SYMBOL_NS(hid_sensor_adjust_channel_bit_mask, "IIO_HID");
+
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@intel.com>");
MODULE_DESCRIPTION("HID Sensor common attribute processing");
MODULE_LICENSE("GPL");
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index e71056553108..6523d46c63e0 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -281,4 +281,7 @@ bool hid_sensor_batch_mode_supported(struct hid_sensor_common *st);
int hid_sensor_set_report_latency(struct hid_sensor_common *st, int latency);
int hid_sensor_get_report_latency(struct hid_sensor_common *st);
+void hid_sensor_adjust_channel_bit_mask(struct iio_chan_spec *channels,
+ int channel, int size);
+
#endif
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 2/7] iio: accel: HID: Replace method accel_3d_adjust_channel_bit_mask()
2026-04-21 22:20 [PATCH v2 0/7] Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
2026-04-21 22:20 ` [PATCH v2 1/7] iio: HID: " Natália Salvino André
@ 2026-04-21 22:20 ` Natália Salvino André
2026-04-22 9:07 ` Andy Shevchenko
2026-04-21 22:20 ` [PATCH v2 3/7] iio: gyro: HID: Replace method gyro_3d_adjust_channel_bit_mask() Natália Salvino André
` (5 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Natália Salvino André @ 2026-04-21 22:20 UTC (permalink / raw)
To: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
srinivas.pandruvada
Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
linux-iio, linux-input
Replace method accel_3d_adjust_channel_bit_mask()
with helper method hid_sensor_adjust_channel_bit_mask().
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 | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 2ff591b3458f..ac4ab69f80b9 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -119,17 +119,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,
@@ -307,9 +296,9 @@ static int accel_3d_parse_report(struct platform_device *pdev,
&st->accel[CHANNEL_SCAN_INDEX_X + i]);
if (ret < 0)
break;
- accel_3d_adjust_channel_bit_mask(channels,
- CHANNEL_SCAN_INDEX_X + i,
- st->accel[CHANNEL_SCAN_INDEX_X + i].size);
+ hid_sensor_adjust_channel_bit_mask(channels,
+ CHANNEL_SCAN_INDEX_X + i,
+ st->accel[CHANNEL_SCAN_INDEX_X + i].size);
}
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] 16+ messages in thread
* [PATCH v2 3/7] iio: gyro: HID: Replace method gyro_3d_adjust_channel_bit_mask()
2026-04-21 22:20 [PATCH v2 0/7] Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
2026-04-21 22:20 ` [PATCH v2 1/7] iio: HID: " Natália Salvino André
2026-04-21 22:20 ` [PATCH v2 2/7] iio: accel: HID: Replace method accel_3d_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-21 22:20 ` Natália Salvino André
2026-04-22 9:14 ` Andy Shevchenko
2026-04-21 22:20 ` [PATCH v2 4/7] iio: light: HID: Replace method als_adjust_channel_bit_mask() Natália Salvino André
` (4 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Natália Salvino André @ 2026-04-21 22:20 UTC (permalink / raw)
To: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
srinivas.pandruvada
Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
linux-iio, linux-input
Replace method gyro_3d_adjust_channel_bit_mask()
with helper method hid_sensor_adjust_channel_bit_mask().
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 | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index c340cc899a7c..e8d8ad884fcb 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -82,17 +82,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,
@@ -258,9 +247,9 @@ static int gyro_3d_parse_report(struct platform_device *pdev,
&st->gyro[CHANNEL_SCAN_INDEX_X + i]);
if (ret < 0)
break;
- gyro_3d_adjust_channel_bit_mask(channels,
- CHANNEL_SCAN_INDEX_X + i,
- st->gyro[CHANNEL_SCAN_INDEX_X + i].size);
+ hid_sensor_adjust_channel_bit_mask(channels,
+ CHANNEL_SCAN_INDEX_X + i,
+ st->gyro[CHANNEL_SCAN_INDEX_X + i].size);
}
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] 16+ messages in thread
* [PATCH v2 4/7] iio: light: HID: Replace method als_adjust_channel_bit_mask()
2026-04-21 22:20 [PATCH v2 0/7] Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
` (2 preceding siblings ...)
2026-04-21 22:20 ` [PATCH v2 3/7] iio: gyro: HID: Replace method gyro_3d_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-21 22:20 ` Natália Salvino André
2026-04-22 9:17 ` Andy Shevchenko
2026-04-21 22:20 ` [PATCH v2 5/7] iio: light: HID: Replace method prox_adjust_channel_bit_mask() Natália Salvino André
` (3 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Natália Salvino André @ 2026-04-21 22:20 UTC (permalink / raw)
To: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
srinivas.pandruvada
Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
linux-iio, linux-input
Replace method als_adjust_channel_bit_mask()
with helper method hid_sensor_adjust_channel_bit_mask().
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 | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 384572844162..16ef9a37aeae 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -117,17 +117,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 +324,7 @@ 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);
+ hid_sensor_adjust_channel_bit_mask(channels, index, st->als[i].size);
++index;
dev_dbg(&pdev->dev, "als %x:%x\n", st->als[i].index,
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 5/7] iio: light: HID: Replace method prox_adjust_channel_bit_mask()
2026-04-21 22:20 [PATCH v2 0/7] Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
` (3 preceding siblings ...)
2026-04-21 22:20 ` [PATCH v2 4/7] iio: light: HID: Replace method als_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-21 22:20 ` Natália Salvino André
2026-04-22 9:16 ` Andy Shevchenko
2026-04-21 22:20 ` [PATCH v2 6/7] iio: magnetometer: HID: Replace method magn_3d_adjust_channel_bit_mask() Natália Salvino André
` (2 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Natália Salvino André @ 2026-04-21 22:20 UTC (permalink / raw)
To: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
srinivas.pandruvada
Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
linux-iio, linux-input
Replace method prox_adjust_channel_bit_mask()
with helper method hid_sensor_adjust_channel_bit_mask().
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 | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index efa904a70d0e..edf76af76dfd 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -67,17 +67,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 +239,8 @@ 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);
+ hid_sensor_adjust_channel_bit_mask(channels, index,
+ st->prox_attr[index].size);
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] 16+ messages in thread
* [PATCH v2 6/7] iio: magnetometer: HID: Replace method magn_3d_adjust_channel_bit_mask()
2026-04-21 22:20 [PATCH v2 0/7] Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
` (4 preceding siblings ...)
2026-04-21 22:20 ` [PATCH v2 5/7] iio: light: HID: Replace method prox_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-21 22:20 ` Natália Salvino André
2026-04-22 9:18 ` Andy Shevchenko
2026-04-21 22:20 ` [PATCH v2 7/7] iio: pressure: HID: Replace method press_adjust_channel_bit_mask() Natália Salvino André
2026-04-22 9:21 ` [PATCH v2 0/7] Add helper method hid_sensor_adjust_channel_bit_mask() Andy Shevchenko
7 siblings, 1 reply; 16+ messages in thread
From: Natália Salvino André @ 2026-04-21 22:20 UTC (permalink / raw)
To: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
srinivas.pandruvada
Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
linux-iio, linux-input
Replace method magn_3d_adjust_channel_bit_mask()
with helper method hid_sensor_adjust_channel_bit_mask().
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 | 17 +++--------------
1 file changed, 3 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..f1939da22e0d 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -132,17 +132,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 +407,9 @@ 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);
+ hid_sensor_adjust_channel_bit_mask(_channels,
+ *chan_count,
+ st->magn[i].size);
}
(*chan_count)++;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 7/7] iio: pressure: HID: Replace method press_adjust_channel_bit_mask()
2026-04-21 22:20 [PATCH v2 0/7] Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
` (5 preceding siblings ...)
2026-04-21 22:20 ` [PATCH v2 6/7] iio: magnetometer: HID: Replace method magn_3d_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-21 22:20 ` Natália Salvino André
2026-04-22 9:18 ` Andy Shevchenko
2026-04-22 9:21 ` [PATCH v2 0/7] Add helper method hid_sensor_adjust_channel_bit_mask() Andy Shevchenko
7 siblings, 1 reply; 16+ messages in thread
From: Natália Salvino André @ 2026-04-21 22:20 UTC (permalink / raw)
To: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
srinivas.pandruvada
Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
linux-iio, linux-input
Replace method press_adjust_channel_bit_mask()
with helper method hid_sensor_adjust_channel_bit_mask().
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 | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
index 5f1d6abda3e4..fd9dafe4945a 100644
--- a/drivers/iio/pressure/hid-sensor-press.c
+++ b/drivers/iio/pressure/hid-sensor-press.c
@@ -53,17 +53,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 +214,8 @@ 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);
+ hid_sensor_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_PRESSURE,
+ st->press_attr.size);
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] 16+ messages in thread
* Re: [PATCH v2 1/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask()
2026-04-21 22:20 ` [PATCH v2 1/7] iio: HID: " Natália Salvino André
@ 2026-04-22 9:03 ` Andy Shevchenko
0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2026-04-22 9:03 UTC (permalink / raw)
To: Natália Salvino André
Cc: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
srinivas.pandruvada, Pietro Di Consolo Gregorio, linux-iio,
linux-input
On Tue, Apr 21, 2026 at 07:20:33PM -0300, Natália Salvino André wrote:
> Add helper method to deduplicate code in HID sensors.
...
> +#include <linux/bits.h>
Will need bitops.h instead (see below why).
...
> +void hid_sensor_adjust_channel_bit_mask(struct iio_chan_spec *channels,
> + int channel, int size)
> +{
> + channels[channel].scan_type.format = 's';
> + /* Real storage bits will change based on the report desc. */
> + channels[channel].scan_type.realbits = size * BITS_PER_BYTE;
BITS_TO_BYTES(size)
> + /* Maximum size of a sample to capture is u32 */
> + channels[channel].scan_type.storagebits = sizeof(u32) * BITS_PER_BYTE;
BITS_PER_TYPE(u32)
> +}
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 2/7] iio: accel: HID: Replace method accel_3d_adjust_channel_bit_mask()
2026-04-21 22:20 ` [PATCH v2 2/7] iio: accel: HID: Replace method accel_3d_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-22 9:07 ` Andy Shevchenko
0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2026-04-22 9:07 UTC (permalink / raw)
To: Natália Salvino André
Cc: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
srinivas.pandruvada, Pietro Di Consolo Gregorio, linux-iio,
linux-input
On Tue, Apr 21, 2026 at 07:20:34PM -0300, Natália Salvino André wrote:
> Replace method accel_3d_adjust_channel_bit_mask()
> with helper method hid_sensor_adjust_channel_bit_mask().
...
> - accel_3d_adjust_channel_bit_mask(channels,
> - CHANNEL_SCAN_INDEX_X + i,
> - st->accel[CHANNEL_SCAN_INDEX_X + i].size);
> + hid_sensor_adjust_channel_bit_mask(channels,
> + CHANNEL_SCAN_INDEX_X + i,
> + st->accel[CHANNEL_SCAN_INDEX_X + i].size);
Indentation is broken. Taking into account that the last line is too long when
properly indented, perhaps
hid_sensor_adjust_channel_bit_mask(channels,
CHANNEL_SCAN_INDEX_X + i,
st->accel[CHANNEL_SCAN_INDEX_X + i].size);
Which makes it most right and under 80 limit.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 3/7] iio: gyro: HID: Replace method gyro_3d_adjust_channel_bit_mask()
2026-04-21 22:20 ` [PATCH v2 3/7] iio: gyro: HID: Replace method gyro_3d_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-22 9:14 ` Andy Shevchenko
0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2026-04-22 9:14 UTC (permalink / raw)
To: Natália Salvino André
Cc: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
srinivas.pandruvada, Pietro Di Consolo Gregorio, linux-iio,
linux-input
On Tue, Apr 21, 2026 at 07:20:35PM -0300, Natália Salvino André wrote:
> Replace method gyro_3d_adjust_channel_bit_mask()
> with helper method hid_sensor_adjust_channel_bit_mask().
...
> + hid_sensor_adjust_channel_bit_mask(channels,
> + CHANNEL_SCAN_INDEX_X + i,
> + st->gyro[CHANNEL_SCAN_INDEX_X + i].size);
Same, at least one more tab for indentation.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 5/7] iio: light: HID: Replace method prox_adjust_channel_bit_mask()
2026-04-21 22:20 ` [PATCH v2 5/7] iio: light: HID: Replace method prox_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-22 9:16 ` Andy Shevchenko
0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2026-04-22 9:16 UTC (permalink / raw)
To: Natália Salvino André
Cc: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
srinivas.pandruvada, Pietro Di Consolo Gregorio, linux-iio,
linux-input
On Tue, Apr 21, 2026 at 07:20:37PM -0300, Natália Salvino André wrote:
> Replace method prox_adjust_channel_bit_mask()
> with helper method hid_sensor_adjust_channel_bit_mask().
...
> + hid_sensor_adjust_channel_bit_mask(channels, index,
> + st->prox_attr[index].size);
This fits 80 when indented properly.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 4/7] iio: light: HID: Replace method als_adjust_channel_bit_mask()
2026-04-21 22:20 ` [PATCH v2 4/7] iio: light: HID: Replace method als_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-22 9:17 ` Andy Shevchenko
0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2026-04-22 9:17 UTC (permalink / raw)
To: Natália Salvino André
Cc: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
srinivas.pandruvada, Pietro Di Consolo Gregorio, linux-iio,
linux-input
On Tue, Apr 21, 2026 at 07:20:36PM -0300, Natália Salvino André wrote:
> Replace method als_adjust_channel_bit_mask()
> with helper method hid_sensor_adjust_channel_bit_mask().
...
> - als_adjust_channel_bit_mask(channels, index, st->als[i].size);
> + hid_sensor_adjust_channel_bit_mask(channels, index, st->als[i].size);
Indent to next line
hid_sensor_adjust_channel_bit_mask(channels, index,
st->als[i].size);
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 6/7] iio: magnetometer: HID: Replace method magn_3d_adjust_channel_bit_mask()
2026-04-21 22:20 ` [PATCH v2 6/7] iio: magnetometer: HID: Replace method magn_3d_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-22 9:18 ` Andy Shevchenko
0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2026-04-22 9:18 UTC (permalink / raw)
To: Natália Salvino André
Cc: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
srinivas.pandruvada, Pietro Di Consolo Gregorio, linux-iio,
linux-input
On Tue, Apr 21, 2026 at 07:20:38PM -0300, Natália Salvino André wrote:
> Replace method magn_3d_adjust_channel_bit_mask()
> with helper method hid_sensor_adjust_channel_bit_mask().
...
> - magn_3d_adjust_channel_bit_mask(_channels,
> - *chan_count,
> - st->magn[i].size);
> + hid_sensor_adjust_channel_bit_mask(_channels,
> + *chan_count,
> + st->magn[i].size);
Fix the indentation accordingly.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 7/7] iio: pressure: HID: Replace method press_adjust_channel_bit_mask()
2026-04-21 22:20 ` [PATCH v2 7/7] iio: pressure: HID: Replace method press_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-22 9:18 ` Andy Shevchenko
0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2026-04-22 9:18 UTC (permalink / raw)
To: Natália Salvino André
Cc: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
srinivas.pandruvada, Pietro Di Consolo Gregorio, linux-iio,
linux-input
On Tue, Apr 21, 2026 at 07:20:39PM -0300, Natália Salvino André wrote:
> Replace method press_adjust_channel_bit_mask()
> with helper method hid_sensor_adjust_channel_bit_mask().
...
> - press_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_PRESSURE,
> - st->press_attr.size);
> + hid_sensor_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_PRESSURE,
> + st->press_attr.size);
Ouch!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 0/7] Add helper method hid_sensor_adjust_channel_bit_mask()
2026-04-21 22:20 [PATCH v2 0/7] Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
` (6 preceding siblings ...)
2026-04-21 22:20 ` [PATCH v2 7/7] iio: pressure: HID: Replace method press_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-22 9:21 ` Andy Shevchenko
7 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2026-04-22 9:21 UTC (permalink / raw)
To: Natália Salvino André
Cc: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
srinivas.pandruvada, linux-iio, linux-input
On Tue, Apr 21, 2026 at 07:20:32PM -0300, Natália Salvino André wrote:
> This patch series introduces a generic helper function to handle channel bit mask adjustments
> for HID sensors. Currently, multiple drivers implement identical logic for this task
This message should be wrapped on ~72 characters. Some of the maintainers may
use cover letter as fake-merge commit message. And even if not, the standards
in the kernel for the cover letter and commit messages are the same in terms of
writing rules.
Basically this is the biggest issue in the whole series: missed proper
indentation / wrapping.
Code wise looks good, thanks for doing this!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2026-04-22 9:21 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-21 22:20 [PATCH v2 0/7] Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
2026-04-21 22:20 ` [PATCH v2 1/7] iio: HID: " Natália Salvino André
2026-04-22 9:03 ` Andy Shevchenko
2026-04-21 22:20 ` [PATCH v2 2/7] iio: accel: HID: Replace method accel_3d_adjust_channel_bit_mask() Natália Salvino André
2026-04-22 9:07 ` Andy Shevchenko
2026-04-21 22:20 ` [PATCH v2 3/7] iio: gyro: HID: Replace method gyro_3d_adjust_channel_bit_mask() Natália Salvino André
2026-04-22 9:14 ` Andy Shevchenko
2026-04-21 22:20 ` [PATCH v2 4/7] iio: light: HID: Replace method als_adjust_channel_bit_mask() Natália Salvino André
2026-04-22 9:17 ` Andy Shevchenko
2026-04-21 22:20 ` [PATCH v2 5/7] iio: light: HID: Replace method prox_adjust_channel_bit_mask() Natália Salvino André
2026-04-22 9:16 ` Andy Shevchenko
2026-04-21 22:20 ` [PATCH v2 6/7] iio: magnetometer: HID: Replace method magn_3d_adjust_channel_bit_mask() Natália Salvino André
2026-04-22 9:18 ` Andy Shevchenko
2026-04-21 22:20 ` [PATCH v2 7/7] iio: pressure: HID: Replace method press_adjust_channel_bit_mask() Natália Salvino André
2026-04-22 9:18 ` Andy Shevchenko
2026-04-22 9:21 ` [PATCH v2 0/7] Add helper method hid_sensor_adjust_channel_bit_mask() Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox