public inbox for linux-input@vger.kernel.org
 help / color / mirror / Atom feed
* [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é
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ 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] 8+ 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-21 22:20 ` [PATCH v2 2/7] iio: accel: HID: Replace method accel_3d_adjust_channel_bit_mask() Natália Salvino André
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ 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] 8+ 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-21 22:20 ` [PATCH v2 3/7] iio: gyro: HID: Replace method gyro_3d_adjust_channel_bit_mask() Natália Salvino André
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ 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] 8+ 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-21 22:20 ` [PATCH v2 4/7] iio: light: HID: Replace method als_adjust_channel_bit_mask() Natália Salvino André
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ 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] 8+ 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-21 22:20 ` [PATCH v2 5/7] iio: light: HID: Replace method prox_adjust_channel_bit_mask() Natália Salvino André
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ 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] 8+ 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-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 ` [PATCH v2 7/7] iio: pressure: HID: Replace method press_adjust_channel_bit_mask() Natália Salvino André
  6 siblings, 0 replies; 8+ 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] 8+ 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-21 22:20 ` [PATCH v2 7/7] iio: pressure: HID: Replace method press_adjust_channel_bit_mask() Natália Salvino André
  6 siblings, 0 replies; 8+ 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] 8+ 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é
  6 siblings, 0 replies; 8+ 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] 8+ messages in thread

end of thread, other threads:[~2026-04-21 22:23 UTC | newest]

Thread overview: 8+ 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-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 ` [PATCH v2 3/7] iio: gyro: HID: Replace method gyro_3d_adjust_channel_bit_mask() Natália Salvino André
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 ` [PATCH v2 5/7] iio: light: HID: Replace method prox_adjust_channel_bit_mask() Natália Salvino André
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 ` [PATCH v2 7/7] iio: pressure: HID: Replace method press_adjust_channel_bit_mask() Natália Salvino André

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