* [PATCH 1/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask()
2026-04-17 22:58 [PATCH 0/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-17 22:58 ` Natália Salvino André
2026-04-18 16:32 ` David Lechner
2026-04-17 22:58 ` [PATCH 2/7] iio: accel: HID: Replace method accel_3d_adjust_channel_bit_mask() Natália Salvino André
` (6 subsequent siblings)
7 siblings, 1 reply; 12+ messages in thread
From: Natália Salvino André @ 2026-04-17 22:58 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 | 11 +++++++++++
include/linux/hid-sensor-hub.h | 3 +++
2 files changed, 14 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..12728cfa5d44 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
@@ -589,6 +589,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.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;
+}
+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] 12+ messages in thread* Re: [PATCH 1/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask()
2026-04-17 22:58 ` [PATCH 1/7] " Natália Salvino André
@ 2026-04-18 16:32 ` David Lechner
2026-04-20 7:36 ` Andy Shevchenko
0 siblings, 1 reply; 12+ messages in thread
From: David Lechner @ 2026-04-18 16:32 UTC (permalink / raw)
To: Natália Salvino André, andy, bentiss, jic23, jikos,
nuno.sa, srinivas.pandruvada
Cc: Pietro Di Consolo Gregorio, linux-iio, linux-input
On 4/17/26 5:58 PM, Natália Salvino André wrote:
> 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 | 11 +++++++++++
> include/linux/hid-sensor-hub.h | 3 +++
> 2 files changed, 14 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..12728cfa5d44 100644
> --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
> +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
> @@ -589,6 +589,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.sign = 's';
We recently renamed the `sign` field to `format`, so it would be nice
to use the new name in new code. (If it is already used in this file,
make a precursor patch to do the rename of existing ones first.)
> + /* Real storage bits will change based on the report desc. */
> + channels[channel].scan_type.realbits = size * 8;
There is a BITS_PER_BYTE macro that would make sense here.
> + /* Maximum size of a sample to capture is u32 */
> + channels[channel].scan_type.storagebits = sizeof(u32) * 8;
and here.
> +}
> +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
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 1/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask()
2026-04-18 16:32 ` David Lechner
@ 2026-04-20 7:36 ` Andy Shevchenko
0 siblings, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2026-04-20 7:36 UTC (permalink / raw)
To: David Lechner
Cc: Natália Salvino André, andy, bentiss, jic23, jikos,
nuno.sa, srinivas.pandruvada, Pietro Di Consolo Gregorio,
linux-iio, linux-input
On Sat, Apr 18, 2026 at 11:32:13AM -0500, David Lechner wrote:
> On 4/17/26 5:58 PM, Natália Salvino André wrote:
> > Add helper method to deduplicate code in HID sensors.
...
> > + /* Real storage bits will change based on the report desc. */
> > + channels[channel].scan_type.realbits = size * 8;
>
> There is a BITS_PER_BYTE macro that would make sense here.
> > + /* Maximum size of a sample to capture is u32 */
> > + channels[channel].scan_type.storagebits = sizeof(u32) * 8;
>
> and here.
FWIW, we have BYTES_TO_BITS().
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/7] iio: accel: HID: Replace method accel_3d_adjust_channel_bit_mask()
2026-04-17 22:58 [PATCH 0/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
2026-04-17 22:58 ` [PATCH 1/7] " Natália Salvino André
@ 2026-04-17 22:58 ` Natália Salvino André
2026-04-17 22:58 ` [PATCH 3/7] iio: gyro: HID: Replace method gyro_3d_adjust_channel_bit_mask() Natália Salvino André
` (5 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Natália Salvino André @ 2026-04-17 22:58 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 | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 2ff591b3458f..75f93b52a926 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,7 +296,7 @@ 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,
+ hid_sensor_adjust_channel_bit_mask(channels,
CHANNEL_SCAN_INDEX_X + i,
st->accel[CHANNEL_SCAN_INDEX_X + i].size);
}
--
2.51.0
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 3/7] iio: gyro: HID: Replace method gyro_3d_adjust_channel_bit_mask()
2026-04-17 22:58 [PATCH 0/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
2026-04-17 22:58 ` [PATCH 1/7] " Natália Salvino André
2026-04-17 22:58 ` [PATCH 2/7] iio: accel: HID: Replace method accel_3d_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-17 22:58 ` Natália Salvino André
2026-04-17 22:58 ` [PATCH 4/7] iio: light: HID: Replace method als_adjust_channel_bit_mask() Natália Salvino André
` (4 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Natália Salvino André @ 2026-04-17 22:58 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 | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index c340cc899a7c..15704e05ad32 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,7 +247,7 @@ 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,
+ hid_sensor_adjust_channel_bit_mask(channels,
CHANNEL_SCAN_INDEX_X + i,
st->gyro[CHANNEL_SCAN_INDEX_X + i].size);
}
--
2.51.0
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 4/7] iio: light: HID: Replace method als_adjust_channel_bit_mask()
2026-04-17 22:58 [PATCH 0/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
` (2 preceding siblings ...)
2026-04-17 22:58 ` [PATCH 3/7] iio: gyro: HID: Replace method gyro_3d_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-17 22:58 ` Natália Salvino André
2026-04-17 22:58 ` [PATCH 5/7] iio: light: HID: Replace method prox_adjust_channel_bit_mask() Natália Salvino André
` (3 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Natália Salvino André @ 2026-04-17 22:58 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] 12+ messages in thread* [PATCH 5/7] iio: light: HID: Replace method prox_adjust_channel_bit_mask()
2026-04-17 22:58 [PATCH 0/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
` (3 preceding siblings ...)
2026-04-17 22:58 ` [PATCH 4/7] iio: light: HID: Replace method als_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-17 22:58 ` Natália Salvino André
2026-04-18 16:34 ` David Lechner
2026-04-17 22:58 ` [PATCH 6/7] iio: magnetometer: HID: Replace method magn_3d_adjust_channel_bit_mask() Natália Salvino André
` (2 subsequent siblings)
7 siblings, 1 reply; 12+ messages in thread
From: Natália Salvino André @ 2026-04-17 22:58 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 | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index efa904a70d0e..61f4627cffab 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,7 +239,7 @@ 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,
+ 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);
--
2.51.0
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 5/7] iio: light: HID: Replace method prox_adjust_channel_bit_mask()
2026-04-17 22:58 ` [PATCH 5/7] iio: light: HID: Replace method prox_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-18 16:34 ` David Lechner
0 siblings, 0 replies; 12+ messages in thread
From: David Lechner @ 2026-04-18 16:34 UTC (permalink / raw)
To: Natália Salvino André, andy, bentiss, jic23, jikos,
nuno.sa, srinivas.pandruvada
Cc: Pietro Di Consolo Gregorio, linux-iio, linux-input
On 4/17/26 5:58 PM, Natália Salvino André wrote:
> 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 | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
> index efa904a70d0e..61f4627cffab 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,7 +239,7 @@ 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,
> + hid_sensor_adjust_channel_bit_mask(channels, index,
> st->prox_attr[index].size);
Make sure to fix the alignment with `(`. Check the other patches too.
If it makes the line too long, just use one tab indent more than the previous line.
> dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr[index].index,
> st->prox_attr[index].report_id);
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 6/7] iio: magnetometer: HID: Replace method magn_3d_adjust_channel_bit_mask()
2026-04-17 22:58 [PATCH 0/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
` (4 preceding siblings ...)
2026-04-17 22:58 ` [PATCH 5/7] iio: light: HID: Replace method prox_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-17 22:58 ` Natália Salvino André
2026-04-17 22:58 ` [PATCH 7/7] iio: pressure: HID: Replace method press_adjust_channel_bit_mask() Natália Salvino André
2026-04-19 13:10 ` [PATCH 0/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask() Jonathan Cameron
7 siblings, 0 replies; 12+ messages in thread
From: Natália Salvino André @ 2026-04-17 22:58 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 | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index c673f9323e47..48a968b3aebb 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,7 +407,7 @@ 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,
+ hid_sensor_adjust_channel_bit_mask(_channels,
*chan_count,
st->magn[i].size);
}
--
2.51.0
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 7/7] iio: pressure: HID: Replace method press_adjust_channel_bit_mask()
2026-04-17 22:58 [PATCH 0/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
` (5 preceding siblings ...)
2026-04-17 22:58 ` [PATCH 6/7] iio: magnetometer: HID: Replace method magn_3d_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-17 22:58 ` Natália Salvino André
2026-04-19 13:10 ` [PATCH 0/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask() Jonathan Cameron
7 siblings, 0 replies; 12+ messages in thread
From: Natália Salvino André @ 2026-04-17 22:58 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 | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
index 5f1d6abda3e4..3d609436a85a 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,7 +214,7 @@ 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,
+ 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,
--
2.51.0
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 0/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask()
2026-04-17 22:58 [PATCH 0/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask() Natália Salvino André
` (6 preceding siblings ...)
2026-04-17 22:58 ` [PATCH 7/7] iio: pressure: HID: Replace method press_adjust_channel_bit_mask() Natália Salvino André
@ 2026-04-19 13:10 ` Jonathan Cameron
7 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2026-04-19 13:10 UTC (permalink / raw)
To: Natália Salvino André
Cc: andy, bentiss, dlechner, jikos, nuno.sa, srinivas.pandruvada,
linux-iio, linux-input
On Fri, 17 Apr 2026 19:58:43 -0300
Natália Salvino André <natalia.andre@ime.usp.br> 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
>
Other than the stuff David already raised, all looks fine to me.
> 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 | 13 +------------
> .../iio/common/hid-sensors/hid-sensor-attributes.c | 11 +++++++++++
> drivers/iio/gyro/hid-sensor-gyro-3d.c | 13 +------------
> drivers/iio/light/hid-sensor-als.c | 13 +------------
> drivers/iio/light/hid-sensor-prox.c | 13 +------------
> drivers/iio/magnetometer/hid-sensor-magn-3d.c | 13 +------------
> drivers/iio/pressure/hid-sensor-press.c | 13 +------------
> include/linux/hid-sensor-hub.h | 3 +++
> 8 files changed, 20 insertions(+), 72 deletions(-)
>
^ permalink raw reply [flat|nested] 12+ messages in thread