* [PATCH v4 20/36] iio: magnetometer: hid-sensor-magn-3d: use local struct device
@ 2026-05-24 19:28 Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 21/36] iio: orientation: hid-sensor-incl-3d: " Sanjay Chitroda
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Sanjay Chitroda @ 2026-05-24 19:28 UTC (permalink / raw)
To: jikos, jic23, srinivas.pandruvada
Cc: dlechner, nuno.sa, andy, sanjayembeddedse, sakari.ailus,
linux-input, linux-iio, linux-kernel
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Introduce a local struct device pointer derived from &pdev->dev.
This avoids repeated &pdev->dev usage and improves readability.
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
---
drivers/iio/magnetometer/hid-sensor-magn-3d.c | 36 ++++++++++---------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index 73dd2e7768db..cf08503ff1ef 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -352,6 +352,7 @@ static int magn_3d_parse_report(struct platform_device *pdev,
u32 usage_id,
struct magn_3d_state *st)
{
+ struct device *dev = &pdev->dev;
int i;
int attr_count = 0;
struct iio_chan_spec *_channels;
@@ -373,34 +374,34 @@ static int magn_3d_parse_report(struct platform_device *pdev,
}
if (attr_count <= 0) {
- dev_err(&pdev->dev,
+ dev_err(dev,
"failed to find any supported usage attributes in report\n");
return -EINVAL;
}
- dev_dbg(&pdev->dev, "magn_3d Found %d usage attributes\n", attr_count);
- dev_dbg(&pdev->dev, "magn_3d X: %x:%x Y: %x:%x Z: %x:%x\n",
+ dev_dbg(dev, "magn_3d Found %d usage attributes\n", attr_count);
+ dev_dbg(dev, "magn_3d X: %x:%x Y: %x:%x Z: %x:%x\n",
st->magn[0].index,
st->magn[0].report_id,
st->magn[1].index, st->magn[1].report_id,
st->magn[2].index, st->magn[2].report_id);
/* Setup IIO channel array */
- _channels = devm_kcalloc(&pdev->dev, attr_count,
+ _channels = devm_kcalloc(dev, attr_count,
sizeof(struct iio_chan_spec),
GFP_KERNEL);
if (!_channels) {
- dev_err(&pdev->dev,
+ dev_err(dev,
"failed to allocate space for iio channels\n");
return -ENOMEM;
}
/* attr_count include timestamp channel, and the iio_vals should be aligned to 8byte */
- st->iio_vals = devm_kcalloc(&pdev->dev,
+ st->iio_vals = devm_kcalloc(dev,
((attr_count + 1) % 2 + (attr_count + 1) / 2) * 2,
sizeof(u32), GFP_KERNEL);
if (!st->iio_vals) {
- dev_err(&pdev->dev,
+ dev_err(dev,
"failed to allocate space for iio values array\n");
return -ENOMEM;
}
@@ -426,14 +427,14 @@ static int magn_3d_parse_report(struct platform_device *pdev,
}
if (*chan_count <= 0) {
- dev_err(&pdev->dev,
+ dev_err(dev,
"failed to find any magnetic channels setup\n");
return -EINVAL;
}
*channels = _channels;
- dev_dbg(&pdev->dev, "magn_3d Setup %d IIO channels\n", *chan_count);
+ dev_dbg(dev, "magn_3d Setup %d IIO channels\n", *chan_count);
st->magn_flux_attr.scale_precision = hid_sensor_format_scale(
HID_USAGE_SENSOR_COMPASS_3D,
@@ -454,7 +455,7 @@ static int magn_3d_parse_report(struct platform_device *pdev,
HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
HID_USAGE_SENSOR_ORIENT_COMP_MAGN_NORTH,
&st->rot_attributes.sensitivity);
- dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
+ dev_dbg(dev, "Sensitivity index:report %d:%d\n",
st->rot_attributes.sensitivity.index,
st->rot_attributes.sensitivity.report_id);
}
@@ -465,7 +466,8 @@ static int magn_3d_parse_report(struct platform_device *pdev,
/* Function to initialize the processing for usage id */
static int hid_magn_3d_probe(struct platform_device *pdev)
{
- struct hid_sensor_hub_device *hsdev = dev_get_platdata(&pdev->dev);
+ struct device *dev = &pdev->dev;
+ struct hid_sensor_hub_device *hsdev = dev_get_platdata(dev);
int ret = 0;
static char *name = "magn_3d";
struct iio_dev *indio_dev;
@@ -473,7 +475,7 @@ static int hid_magn_3d_probe(struct platform_device *pdev)
struct iio_chan_spec *channels;
int chan_count = 0;
- indio_dev = devm_iio_device_alloc(&pdev->dev,
+ indio_dev = devm_iio_device_alloc(dev,
sizeof(struct magn_3d_state));
if (indio_dev == NULL)
return -ENOMEM;
@@ -491,7 +493,7 @@ static int hid_magn_3d_probe(struct platform_device *pdev)
magn_3d_sensitivity_addresses,
ARRAY_SIZE(magn_3d_sensitivity_addresses));
if (ret) {
- dev_err(&pdev->dev, "failed to setup common attributes\n");
+ dev_err(dev, "failed to setup common attributes\n");
return ret;
}
magn_state->rot_attributes = magn_state->magn_flux_attributes;
@@ -502,7 +504,7 @@ static int hid_magn_3d_probe(struct platform_device *pdev)
&channels, &chan_count,
HID_USAGE_SENSOR_COMPASS_3D, magn_state);
if (ret) {
- dev_err(&pdev->dev, "failed to parse report\n");
+ dev_err(dev, "failed to parse report\n");
return ret;
}
@@ -517,13 +519,13 @@ static int hid_magn_3d_probe(struct platform_device *pdev)
ret = hid_sensor_setup_trigger(indio_dev, name,
&magn_state->magn_flux_attributes);
if (ret < 0) {
- dev_err(&pdev->dev, "trigger setup failed\n");
+ dev_err(dev, "trigger setup failed\n");
return ret;
}
ret = iio_device_register(indio_dev);
if (ret) {
- dev_err(&pdev->dev, "device register failed\n");
+ dev_err(dev, "device register failed\n");
goto error_remove_trigger;
}
@@ -533,7 +535,7 @@ static int hid_magn_3d_probe(struct platform_device *pdev)
ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_COMPASS_3D,
&magn_state->callbacks);
if (ret < 0) {
- dev_err(&pdev->dev, "callback reg failed\n");
+ dev_err(dev, "callback reg failed\n");
goto error_iio_unreg;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 21/36] iio: orientation: hid-sensor-incl-3d: use local struct device
2026-05-24 19:28 [PATCH v4 20/36] iio: magnetometer: hid-sensor-magn-3d: use local struct device Sanjay Chitroda
@ 2026-05-24 19:28 ` Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 22/36] iio: orientation: hid-sensor-rotation: " Sanjay Chitroda
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sanjay Chitroda @ 2026-05-24 19:28 UTC (permalink / raw)
To: jikos, jic23, srinivas.pandruvada
Cc: dlechner, nuno.sa, andy, sanjayembeddedse, sakari.ailus,
linux-input, linux-iio, linux-kernel
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Introduce a local struct device pointer derived from &pdev->dev.
This avoids repeated &pdev->dev usage and improves readability.
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
---
drivers/iio/orientation/hid-sensor-incl-3d.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c
index c7fbff498be7..93fce8510468 100644
--- a/drivers/iio/orientation/hid-sensor-incl-3d.c
+++ b/drivers/iio/orientation/hid-sensor-incl-3d.c
@@ -299,14 +299,14 @@ static int incl_3d_parse_report(struct platform_device *pdev,
/* Function to initialize the processing for usage id */
static int hid_incl_3d_probe(struct platform_device *pdev)
{
- struct hid_sensor_hub_device *hsdev = dev_get_platdata(&pdev->dev);
+ struct device *dev = &pdev->dev;
+ struct hid_sensor_hub_device *hsdev = dev_get_platdata(dev);
int ret;
static char *name = "incli_3d";
struct iio_dev *indio_dev;
struct incl_3d_state *incl_state;
- indio_dev = devm_iio_device_alloc(&pdev->dev,
- sizeof(struct incl_3d_state));
+ indio_dev = devm_iio_device_alloc(dev, sizeof(struct incl_3d_state));
if (indio_dev == NULL)
return -ENOMEM;
@@ -322,14 +322,14 @@ static int hid_incl_3d_probe(struct platform_device *pdev)
incl_3d_sensitivity_addresses,
ARRAY_SIZE(incl_3d_sensitivity_addresses));
if (ret) {
- dev_err(&pdev->dev, "failed to setup common attributes\n");
+ dev_err(dev, "failed to setup common attributes\n");
return ret;
}
- indio_dev->channels = devm_kmemdup(&pdev->dev, incl_3d_channels,
+ indio_dev->channels = devm_kmemdup(dev, incl_3d_channels,
sizeof(incl_3d_channels), GFP_KERNEL);
if (!indio_dev->channels) {
- dev_err(&pdev->dev, "failed to duplicate channels\n");
+ dev_err(dev, "failed to duplicate channels\n");
return -ENOMEM;
}
@@ -338,7 +338,7 @@ static int hid_incl_3d_probe(struct platform_device *pdev)
HID_USAGE_SENSOR_INCLINOMETER_3D,
incl_state);
if (ret) {
- dev_err(&pdev->dev, "failed to setup attributes\n");
+ dev_err(dev, "failed to setup attributes\n");
return ret;
}
@@ -352,13 +352,13 @@ static int hid_incl_3d_probe(struct platform_device *pdev)
ret = hid_sensor_setup_trigger(indio_dev, name,
&incl_state->common_attributes);
if (ret) {
- dev_err(&pdev->dev, "trigger setup failed\n");
+ dev_err(dev, "trigger setup failed\n");
return ret;
}
ret = iio_device_register(indio_dev);
if (ret) {
- dev_err(&pdev->dev, "device register failed\n");
+ dev_err(dev, "device register failed\n");
goto error_remove_trigger;
}
@@ -369,7 +369,7 @@ static int hid_incl_3d_probe(struct platform_device *pdev)
HID_USAGE_SENSOR_INCLINOMETER_3D,
&incl_state->callbacks);
if (ret) {
- dev_err(&pdev->dev, "callback reg failed\n");
+ dev_err(dev, "callback reg failed\n");
goto error_iio_unreg;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 22/36] iio: orientation: hid-sensor-rotation: use local struct device
2026-05-24 19:28 [PATCH v4 20/36] iio: magnetometer: hid-sensor-magn-3d: use local struct device Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 21/36] iio: orientation: hid-sensor-incl-3d: " Sanjay Chitroda
@ 2026-05-24 19:28 ` Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 23/36] iio: position: hid-sensor-custom-intel-hinge: " Sanjay Chitroda
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sanjay Chitroda @ 2026-05-24 19:28 UTC (permalink / raw)
To: jikos, jic23, srinivas.pandruvada
Cc: dlechner, nuno.sa, andy, sanjayembeddedse, sakari.ailus,
linux-input, linux-iio, linux-kernel
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Introduce a local struct device pointer derived from &pdev->dev.
This avoids repeated &pdev->dev usage and improves readability.
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
---
drivers/iio/orientation/hid-sensor-rotation.c | 22 +++++++++----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c
index 20563d8efaf6..332d56757679 100644
--- a/drivers/iio/orientation/hid-sensor-rotation.c
+++ b/drivers/iio/orientation/hid-sensor-rotation.c
@@ -243,6 +243,7 @@ static int dev_rot_parse_report(struct platform_device *pdev,
u32 usage_id,
struct dev_rot_state *st)
{
+ struct device *dev = &pdev->dev;
int ret;
ret = sensor_hub_input_get_attribute_info(hsdev,
@@ -253,11 +254,10 @@ static int dev_rot_parse_report(struct platform_device *pdev,
if (ret)
return ret;
- dev_dbg(&pdev->dev, "dev_rot %x:%x\n", st->quaternion.index,
+ dev_dbg(dev, "dev_rot %x:%x\n", st->quaternion.index,
st->quaternion.report_id);
- dev_dbg(&pdev->dev, "dev_rot: attrib size %d\n",
- st->quaternion.size);
+ dev_dbg(dev, "dev_rot: attrib size %d\n", st->quaternion.size);
st->scale_precision = hid_sensor_format_scale(
hsdev->usage,
@@ -270,14 +270,14 @@ static int dev_rot_parse_report(struct platform_device *pdev,
/* Function to initialize the processing for usage id */
static int hid_dev_rot_probe(struct platform_device *pdev)
{
- struct hid_sensor_hub_device *hsdev = dev_get_platdata(&pdev->dev);
+ struct device *dev = &pdev->dev;
+ struct hid_sensor_hub_device *hsdev = dev_get_platdata(dev);
int ret;
char *name;
struct iio_dev *indio_dev;
struct dev_rot_state *rot_state;
- indio_dev = devm_iio_device_alloc(&pdev->dev,
- sizeof(struct dev_rot_state));
+ indio_dev = devm_iio_device_alloc(dev, sizeof(struct dev_rot_state));
if (indio_dev == NULL)
return -ENOMEM;
@@ -307,13 +307,13 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
rotation_sensitivity_addresses,
ARRAY_SIZE(rotation_sensitivity_addresses));
if (ret) {
- dev_err(&pdev->dev, "failed to setup common attributes\n");
+ dev_err(dev, "failed to setup common attributes\n");
return ret;
}
ret = dev_rot_parse_report(pdev, hsdev, hsdev->usage, rot_state);
if (ret) {
- dev_err(&pdev->dev, "failed to setup attributes\n");
+ dev_err(dev, "failed to setup attributes\n");
return ret;
}
@@ -328,13 +328,13 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
ret = hid_sensor_setup_trigger(indio_dev, name,
&rot_state->common_attributes);
if (ret) {
- dev_err(&pdev->dev, "trigger setup failed\n");
+ dev_err(dev, "trigger setup failed\n");
return ret;
}
ret = iio_device_register(indio_dev);
if (ret) {
- dev_err(&pdev->dev, "device register failed\n");
+ dev_err(dev, "device register failed\n");
goto error_remove_trigger;
}
@@ -344,7 +344,7 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
ret = sensor_hub_register_callback(hsdev, hsdev->usage,
&rot_state->callbacks);
if (ret) {
- dev_err(&pdev->dev, "callback reg failed\n");
+ dev_err(dev, "callback reg failed\n");
goto error_iio_unreg;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 23/36] iio: position: hid-sensor-custom-intel-hinge: use local struct device
2026-05-24 19:28 [PATCH v4 20/36] iio: magnetometer: hid-sensor-magn-3d: use local struct device Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 21/36] iio: orientation: hid-sensor-incl-3d: " Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 22/36] iio: orientation: hid-sensor-rotation: " Sanjay Chitroda
@ 2026-05-24 19:28 ` Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 24/36] iio: pressure: hid-sensor-press: " Sanjay Chitroda
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sanjay Chitroda @ 2026-05-24 19:28 UTC (permalink / raw)
To: jikos, jic23, srinivas.pandruvada
Cc: dlechner, nuno.sa, andy, sanjayembeddedse, sakari.ailus,
linux-input, linux-iio, linux-kernel
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Introduce a local struct device pointer derived from &pdev->dev.
This avoids repeated &pdev->dev usage and improves readability.
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
---
.../position/hid-sensor-custom-intel-hinge.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/position/hid-sensor-custom-intel-hinge.c b/drivers/iio/position/hid-sensor-custom-intel-hinge.c
index 0ba9d2d43913..34c7cf734018 100644
--- a/drivers/iio/position/hid-sensor-custom-intel-hinge.c
+++ b/drivers/iio/position/hid-sensor-custom-intel-hinge.c
@@ -263,13 +263,14 @@ static int hinge_parse_report(struct platform_device *pdev,
/* Function to initialize the processing for usage id */
static int hid_hinge_probe(struct platform_device *pdev)
{
- struct hid_sensor_hub_device *hsdev = dev_get_platdata(&pdev->dev);
+ struct device *dev = &pdev->dev;
+ struct hid_sensor_hub_device *hsdev = dev_get_platdata(dev);
struct hinge_state *st;
struct iio_dev *indio_dev;
int ret;
int i;
- indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*st));
+ indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
if (!indio_dev)
return -ENOMEM;
@@ -287,12 +288,12 @@ static int hid_hinge_probe(struct platform_device *pdev)
hinge_sensitivity_addresses,
ARRAY_SIZE(hinge_sensitivity_addresses));
if (ret) {
- dev_err(&pdev->dev, "failed to setup common attributes\n");
+ dev_err(dev, "failed to setup common attributes\n");
return ret;
}
indio_dev->num_channels = ARRAY_SIZE(hinge_channels);
- indio_dev->channels = devm_kmemdup(&pdev->dev, hinge_channels,
+ indio_dev->channels = devm_kmemdup(dev, hinge_channels,
sizeof(hinge_channels), GFP_KERNEL);
if (!indio_dev->channels)
return -ENOMEM;
@@ -301,7 +302,7 @@ static int hid_hinge_probe(struct platform_device *pdev)
(struct iio_chan_spec *)indio_dev->channels,
hsdev->usage, st);
if (ret) {
- dev_err(&pdev->dev, "failed to setup attributes\n");
+ dev_err(dev, "failed to setup attributes\n");
return ret;
}
@@ -313,7 +314,7 @@ static int hid_hinge_probe(struct platform_device *pdev)
ret = hid_sensor_setup_trigger(indio_dev, indio_dev->name,
&st->common_attributes);
if (ret < 0) {
- dev_err(&pdev->dev, "trigger setup failed\n");
+ dev_err(dev, "trigger setup failed\n");
return ret;
}
@@ -322,13 +323,13 @@ static int hid_hinge_probe(struct platform_device *pdev)
st->callbacks.pdev = pdev;
ret = sensor_hub_register_callback(hsdev, hsdev->usage, &st->callbacks);
if (ret < 0) {
- dev_err(&pdev->dev, "callback reg failed\n");
+ dev_err(dev, "callback reg failed\n");
goto error_remove_trigger;
}
ret = iio_device_register(indio_dev);
if (ret) {
- dev_err(&pdev->dev, "device register failed\n");
+ dev_err(dev, "device register failed\n");
goto error_remove_callback;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 24/36] iio: pressure: hid-sensor-press: use local struct device
2026-05-24 19:28 [PATCH v4 20/36] iio: magnetometer: hid-sensor-magn-3d: use local struct device Sanjay Chitroda
` (2 preceding siblings ...)
2026-05-24 19:28 ` [PATCH v4 23/36] iio: position: hid-sensor-custom-intel-hinge: " Sanjay Chitroda
@ 2026-05-24 19:28 ` Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 25/36] iio: hid-sensors: remove unused iio_dev argument Sanjay Chitroda
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sanjay Chitroda @ 2026-05-24 19:28 UTC (permalink / raw)
To: jikos, jic23, srinivas.pandruvada
Cc: dlechner, nuno.sa, andy, sanjayembeddedse, sakari.ailus,
linux-input, linux-iio, linux-kernel
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Introduce a local struct device pointer derived from &pdev->dev.
This avoids repeated &pdev->dev usage and improves readability.
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
---
drivers/iio/pressure/hid-sensor-press.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
index a5db5220d3d5..d85f6247d8ab 100644
--- a/drivers/iio/pressure/hid-sensor-press.c
+++ b/drivers/iio/pressure/hid-sensor-press.c
@@ -242,14 +242,14 @@ static int press_parse_report(struct platform_device *pdev,
/* Function to initialize the processing for usage id */
static int hid_press_probe(struct platform_device *pdev)
{
- struct hid_sensor_hub_device *hsdev = dev_get_platdata(&pdev->dev);
+ struct device *dev = &pdev->dev;
+ struct hid_sensor_hub_device *hsdev = dev_get_platdata(dev);
int ret = 0;
static const char *name = "press";
struct iio_dev *indio_dev;
struct press_state *press_state;
- indio_dev = devm_iio_device_alloc(&pdev->dev,
- sizeof(struct press_state));
+ indio_dev = devm_iio_device_alloc(dev, sizeof(struct press_state));
if (!indio_dev)
return -ENOMEM;
platform_set_drvdata(pdev, indio_dev);
@@ -264,14 +264,14 @@ static int hid_press_probe(struct platform_device *pdev)
press_sensitivity_addresses,
ARRAY_SIZE(press_sensitivity_addresses));
if (ret) {
- dev_err(&pdev->dev, "failed to setup common attributes\n");
+ dev_err(dev, "failed to setup common attributes\n");
return ret;
}
- indio_dev->channels = devm_kmemdup(&pdev->dev, press_channels,
+ indio_dev->channels = devm_kmemdup(dev, press_channels,
sizeof(press_channels), GFP_KERNEL);
if (!indio_dev->channels) {
- dev_err(&pdev->dev, "failed to duplicate channels\n");
+ dev_err(dev, "failed to duplicate channels\n");
return -ENOMEM;
}
@@ -279,7 +279,7 @@ static int hid_press_probe(struct platform_device *pdev)
(struct iio_chan_spec *)indio_dev->channels,
HID_USAGE_SENSOR_PRESSURE, press_state);
if (ret) {
- dev_err(&pdev->dev, "failed to setup attributes\n");
+ dev_err(dev, "failed to setup attributes\n");
return ret;
}
@@ -294,13 +294,13 @@ static int hid_press_probe(struct platform_device *pdev)
ret = hid_sensor_setup_trigger(indio_dev, name,
&press_state->common_attributes);
if (ret) {
- dev_err(&pdev->dev, "trigger setup failed\n");
+ dev_err(dev, "trigger setup failed\n");
return ret;
}
ret = iio_device_register(indio_dev);
if (ret) {
- dev_err(&pdev->dev, "device register failed\n");
+ dev_err(dev, "device register failed\n");
goto error_remove_trigger;
}
@@ -310,7 +310,7 @@ static int hid_press_probe(struct platform_device *pdev)
ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_PRESSURE,
&press_state->callbacks);
if (ret < 0) {
- dev_err(&pdev->dev, "callback reg failed\n");
+ dev_err(dev, "callback reg failed\n");
goto error_iio_unreg;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 25/36] iio: hid-sensors: remove unused iio_dev argument
2026-05-24 19:28 [PATCH v4 20/36] iio: magnetometer: hid-sensor-magn-3d: use local struct device Sanjay Chitroda
` (3 preceding siblings ...)
2026-05-24 19:28 ` [PATCH v4 24/36] iio: pressure: hid-sensor-press: " Sanjay Chitroda
@ 2026-05-24 19:28 ` Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 26/36] iio: hid-sensors: introduce device managed API Sanjay Chitroda
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sanjay Chitroda @ 2026-05-24 19:28 UTC (permalink / raw)
To: jikos, jic23, srinivas.pandruvada
Cc: dlechner, nuno.sa, andy, sanjayembeddedse, sakari.ailus,
linux-input, linux-iio, linux-kernel
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
hid_sensor_remove_trigger() no longer uses the iio_dev argument.
Remove the unused argument from all HID IIO drivers to match
updated function prototype.
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
---
Changes in v4:
- Rectify commit message with input from David
---
drivers/iio/accel/hid-sensor-accel-3d.c | 4 ++--
drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 3 +--
drivers/iio/common/hid-sensors/hid-sensor-trigger.h | 3 +--
drivers/iio/gyro/hid-sensor-gyro-3d.c | 4 ++--
drivers/iio/humidity/hid-sensor-humidity.c | 4 ++--
drivers/iio/light/hid-sensor-als.c | 4 ++--
drivers/iio/light/hid-sensor-prox.c | 4 ++--
drivers/iio/magnetometer/hid-sensor-magn-3d.c | 4 ++--
drivers/iio/orientation/hid-sensor-incl-3d.c | 4 ++--
drivers/iio/orientation/hid-sensor-rotation.c | 4 ++--
drivers/iio/position/hid-sensor-custom-intel-hinge.c | 4 ++--
drivers/iio/pressure/hid-sensor-press.c | 4 ++--
drivers/iio/temperature/hid-sensor-temperature.c | 4 ++--
13 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 561d9784d936..5b0978955f09 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -416,7 +416,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
error_iio_unreg:
iio_device_unregister(indio_dev);
error_remove_trigger:
- hid_sensor_remove_trigger(indio_dev, &accel_state->common_attributes);
+ hid_sensor_remove_trigger(&accel_state->common_attributes);
return ret;
}
@@ -429,7 +429,7 @@ static void hid_accel_3d_remove(struct platform_device *pdev)
sensor_hub_remove_callback(hsdev, hsdev->usage);
iio_device_unregister(indio_dev);
- hid_sensor_remove_trigger(indio_dev, &accel_state->common_attributes);
+ hid_sensor_remove_trigger(&accel_state->common_attributes);
}
static const struct platform_device_id hid_accel_3d_ids[] = {
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index c8ccf96f3d03..98fadc61a68a 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -218,8 +218,7 @@ static const struct iio_buffer_setup_ops hid_sensor_buffer_ops = {
.predisable = buffer_predisable,
};
-void hid_sensor_remove_trigger(struct iio_dev *indio_dev,
- struct hid_sensor_common *attrb)
+void hid_sensor_remove_trigger(struct hid_sensor_common *attrb)
{
if (atomic_read(&attrb->runtime_pm_enable))
pm_runtime_disable(&attrb->pdev->dev);
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
index f94fca4f1edf..afec46ecbe71 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
@@ -16,8 +16,7 @@ extern const struct dev_pm_ops hid_sensor_pm_ops;
int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
struct hid_sensor_common *attrb);
-void hid_sensor_remove_trigger(struct iio_dev *indio_dev,
- struct hid_sensor_common *attrb);
+void hid_sensor_remove_trigger(struct hid_sensor_common *attrb);
int hid_sensor_power_state(struct hid_sensor_common *st, bool state);
#endif
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index c891b1bb09dd..f611a10b92c5 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -356,7 +356,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
error_iio_unreg:
iio_device_unregister(indio_dev);
error_remove_trigger:
- hid_sensor_remove_trigger(indio_dev, &gyro_state->common_attributes);
+ hid_sensor_remove_trigger(&gyro_state->common_attributes);
return ret;
}
@@ -369,7 +369,7 @@ static void hid_gyro_3d_remove(struct platform_device *pdev)
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_GYRO_3D);
iio_device_unregister(indio_dev);
- hid_sensor_remove_trigger(indio_dev, &gyro_state->common_attributes);
+ hid_sensor_remove_trigger(&gyro_state->common_attributes);
}
static const struct platform_device_id hid_gyro_3d_ids[] = {
diff --git a/drivers/iio/humidity/hid-sensor-humidity.c b/drivers/iio/humidity/hid-sensor-humidity.c
index ea6f66ce0f8e..d310ec43a118 100644
--- a/drivers/iio/humidity/hid-sensor-humidity.c
+++ b/drivers/iio/humidity/hid-sensor-humidity.c
@@ -256,7 +256,7 @@ static int hid_humidity_probe(struct platform_device *pdev)
error_remove_callback:
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_HUMIDITY);
error_remove_trigger:
- hid_sensor_remove_trigger(indio_dev, &humid_st->common_attributes);
+ hid_sensor_remove_trigger(&humid_st->common_attributes);
return ret;
}
@@ -269,7 +269,7 @@ static void hid_humidity_remove(struct platform_device *pdev)
iio_device_unregister(indio_dev);
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_HUMIDITY);
- hid_sensor_remove_trigger(indio_dev, &humid_st->common_attributes);
+ hid_sensor_remove_trigger(&humid_st->common_attributes);
}
static const struct platform_device_id hid_humidity_ids[] = {
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index c84fb4cc5105..0af235d30800 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -433,7 +433,7 @@ static int hid_als_probe(struct platform_device *pdev)
error_iio_unreg:
iio_device_unregister(indio_dev);
error_remove_trigger:
- hid_sensor_remove_trigger(indio_dev, &als_state->common_attributes);
+ hid_sensor_remove_trigger(&als_state->common_attributes);
return ret;
}
@@ -446,7 +446,7 @@ static void hid_als_remove(struct platform_device *pdev)
sensor_hub_remove_callback(hsdev, hsdev->usage);
iio_device_unregister(indio_dev);
- hid_sensor_remove_trigger(indio_dev, &als_state->common_attributes);
+ hid_sensor_remove_trigger(&als_state->common_attributes);
}
static const struct platform_device_id hid_als_ids[] = {
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index 033dace06681..eff206d7b812 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -340,7 +340,7 @@ static int hid_prox_probe(struct platform_device *pdev)
error_iio_unreg:
iio_device_unregister(indio_dev);
error_remove_trigger:
- hid_sensor_remove_trigger(indio_dev, &prox_state->common_attributes);
+ hid_sensor_remove_trigger(&prox_state->common_attributes);
return ret;
}
@@ -353,7 +353,7 @@ static void hid_prox_remove(struct platform_device *pdev)
sensor_hub_remove_callback(hsdev, hsdev->usage);
iio_device_unregister(indio_dev);
- hid_sensor_remove_trigger(indio_dev, &prox_state->common_attributes);
+ hid_sensor_remove_trigger(&prox_state->common_attributes);
}
static const struct platform_device_id hid_prox_ids[] = {
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index cf08503ff1ef..22c7b24e2e3a 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -544,7 +544,7 @@ static int hid_magn_3d_probe(struct platform_device *pdev)
error_iio_unreg:
iio_device_unregister(indio_dev);
error_remove_trigger:
- hid_sensor_remove_trigger(indio_dev, &magn_state->magn_flux_attributes);
+ hid_sensor_remove_trigger(&magn_state->magn_flux_attributes);
return ret;
}
@@ -557,7 +557,7 @@ static void hid_magn_3d_remove(struct platform_device *pdev)
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_COMPASS_3D);
iio_device_unregister(indio_dev);
- hid_sensor_remove_trigger(indio_dev, &magn_state->magn_flux_attributes);
+ hid_sensor_remove_trigger(&magn_state->magn_flux_attributes);
}
static const struct platform_device_id hid_magn_3d_ids[] = {
diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c
index 93fce8510468..21a32f506046 100644
--- a/drivers/iio/orientation/hid-sensor-incl-3d.c
+++ b/drivers/iio/orientation/hid-sensor-incl-3d.c
@@ -378,7 +378,7 @@ static int hid_incl_3d_probe(struct platform_device *pdev)
error_iio_unreg:
iio_device_unregister(indio_dev);
error_remove_trigger:
- hid_sensor_remove_trigger(indio_dev, &incl_state->common_attributes);
+ hid_sensor_remove_trigger(&incl_state->common_attributes);
return ret;
}
@@ -391,7 +391,7 @@ static void hid_incl_3d_remove(struct platform_device *pdev)
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_INCLINOMETER_3D);
iio_device_unregister(indio_dev);
- hid_sensor_remove_trigger(indio_dev, &incl_state->common_attributes);
+ hid_sensor_remove_trigger(&incl_state->common_attributes);
}
static const struct platform_device_id hid_incl_3d_ids[] = {
diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c
index 332d56757679..cd9fe74b5b30 100644
--- a/drivers/iio/orientation/hid-sensor-rotation.c
+++ b/drivers/iio/orientation/hid-sensor-rotation.c
@@ -353,7 +353,7 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
error_iio_unreg:
iio_device_unregister(indio_dev);
error_remove_trigger:
- hid_sensor_remove_trigger(indio_dev, &rot_state->common_attributes);
+ hid_sensor_remove_trigger(&rot_state->common_attributes);
return ret;
}
@@ -366,7 +366,7 @@ static void hid_dev_rot_remove(struct platform_device *pdev)
sensor_hub_remove_callback(hsdev, hsdev->usage);
iio_device_unregister(indio_dev);
- hid_sensor_remove_trigger(indio_dev, &rot_state->common_attributes);
+ hid_sensor_remove_trigger(&rot_state->common_attributes);
}
static const struct platform_device_id hid_dev_rot_ids[] = {
diff --git a/drivers/iio/position/hid-sensor-custom-intel-hinge.c b/drivers/iio/position/hid-sensor-custom-intel-hinge.c
index 34c7cf734018..e616988fe9f4 100644
--- a/drivers/iio/position/hid-sensor-custom-intel-hinge.c
+++ b/drivers/iio/position/hid-sensor-custom-intel-hinge.c
@@ -338,7 +338,7 @@ static int hid_hinge_probe(struct platform_device *pdev)
error_remove_callback:
sensor_hub_remove_callback(hsdev, hsdev->usage);
error_remove_trigger:
- hid_sensor_remove_trigger(indio_dev, &st->common_attributes);
+ hid_sensor_remove_trigger(&st->common_attributes);
return ret;
}
@@ -351,7 +351,7 @@ static void hid_hinge_remove(struct platform_device *pdev)
iio_device_unregister(indio_dev);
sensor_hub_remove_callback(hsdev, hsdev->usage);
- hid_sensor_remove_trigger(indio_dev, &st->common_attributes);
+ hid_sensor_remove_trigger(&st->common_attributes);
}
static const struct platform_device_id hid_hinge_ids[] = {
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
index d85f6247d8ab..fee7dcb86801 100644
--- a/drivers/iio/pressure/hid-sensor-press.c
+++ b/drivers/iio/pressure/hid-sensor-press.c
@@ -319,7 +319,7 @@ static int hid_press_probe(struct platform_device *pdev)
error_iio_unreg:
iio_device_unregister(indio_dev);
error_remove_trigger:
- hid_sensor_remove_trigger(indio_dev, &press_state->common_attributes);
+ hid_sensor_remove_trigger(&press_state->common_attributes);
return ret;
}
@@ -332,7 +332,7 @@ static void hid_press_remove(struct platform_device *pdev)
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_PRESSURE);
iio_device_unregister(indio_dev);
- hid_sensor_remove_trigger(indio_dev, &press_state->common_attributes);
+ hid_sensor_remove_trigger(&press_state->common_attributes);
}
static const struct platform_device_id hid_press_ids[] = {
diff --git a/drivers/iio/temperature/hid-sensor-temperature.c b/drivers/iio/temperature/hid-sensor-temperature.c
index 31ebfd1a1fe2..1ff0233d7ab0 100644
--- a/drivers/iio/temperature/hid-sensor-temperature.c
+++ b/drivers/iio/temperature/hid-sensor-temperature.c
@@ -253,7 +253,7 @@ static int hid_temperature_probe(struct platform_device *pdev)
error_remove_callback:
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TEMPERATURE);
error_remove_trigger:
- hid_sensor_remove_trigger(indio_dev, &temp_st->common_attributes);
+ hid_sensor_remove_trigger(&temp_st->common_attributes);
return ret;
}
@@ -265,7 +265,7 @@ static void hid_temperature_remove(struct platform_device *pdev)
struct temperature_state *temp_st = iio_priv(indio_dev);
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TEMPERATURE);
- hid_sensor_remove_trigger(indio_dev, &temp_st->common_attributes);
+ hid_sensor_remove_trigger(&temp_st->common_attributes);
}
static const struct platform_device_id hid_temperature_ids[] = {
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 26/36] iio: hid-sensors: introduce device managed API
2026-05-24 19:28 [PATCH v4 20/36] iio: magnetometer: hid-sensor-magn-3d: use local struct device Sanjay Chitroda
` (4 preceding siblings ...)
2026-05-24 19:28 ` [PATCH v4 25/36] iio: hid-sensors: remove unused iio_dev argument Sanjay Chitroda
@ 2026-05-24 19:28 ` Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 27/36] iio: gyro: hid-sensor-gyro-3d: drop hid_sensor_remove_trigger() using devm API Sanjay Chitroda
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sanjay Chitroda @ 2026-05-24 19:28 UTC (permalink / raw)
To: jikos, jic23, srinivas.pandruvada
Cc: dlechner, nuno.sa, andy, sanjayembeddedse, sakari.ailus,
linux-input, linux-iio, linux-kernel
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
hid_sensor_setup_trigger() is common API used for the HID IIO drivers,
prepare devm API devm_hid_sensor_setup_trigger() to acquire resource
during setup and release using device managed framework during drivers
fail, unbind or remove path.
Register action with devm_add_action_or_reset() to release resource with
devres framework.
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
---
Changes in v4:
- No updated in change, added Tested-by tag.
Changes in v3:
- Remove cast and update function based on review comment from Andy
- v2 link -> https://lore.kernel.org/all/20260429175918.2541914-3-sanjayembedded@gmail.com/
---
.../common/hid-sensors/hid-sensor-trigger.c | 18 ++++++++++++++++++
.../common/hid-sensors/hid-sensor-trigger.h | 2 ++
2 files changed, 20 insertions(+)
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index 98fadc61a68a..fb6a4587ae03 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -301,6 +301,24 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
}
EXPORT_SYMBOL_NS(hid_sensor_setup_trigger, "IIO_HID");
+static void hid_sensor_remove_trigger_action(void *attrb)
+{
+ hid_sensor_remove_trigger(attrb);
+}
+
+int devm_hid_sensor_setup_trigger(struct device *dev, struct iio_dev *indio_dev,
+ const char *name, struct hid_sensor_common *attrb)
+{
+ int ret;
+
+ ret = hid_sensor_setup_trigger(indio_dev, name, attrb);
+ if (ret)
+ return ret;
+
+ return devm_add_action_or_reset(dev, hid_sensor_remove_trigger_action, attrb);
+}
+EXPORT_SYMBOL_NS(devm_hid_sensor_setup_trigger, "IIO_HID");
+
static int __maybe_unused hid_sensor_suspend(struct device *dev)
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
index afec46ecbe71..6fd7c39a240d 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
@@ -17,6 +17,8 @@ extern const struct dev_pm_ops hid_sensor_pm_ops;
int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
struct hid_sensor_common *attrb);
void hid_sensor_remove_trigger(struct hid_sensor_common *attrb);
+int devm_hid_sensor_setup_trigger(struct device *dev, struct iio_dev *indio_dev,
+ const char *name, struct hid_sensor_common *attrb);
int hid_sensor_power_state(struct hid_sensor_common *st, bool state);
#endif
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 27/36] iio: gyro: hid-sensor-gyro-3d: drop hid_sensor_remove_trigger() using devm API
2026-05-24 19:28 [PATCH v4 20/36] iio: magnetometer: hid-sensor-magn-3d: use local struct device Sanjay Chitroda
` (5 preceding siblings ...)
2026-05-24 19:28 ` [PATCH v4 26/36] iio: hid-sensors: introduce device managed API Sanjay Chitroda
@ 2026-05-24 19:28 ` Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 28/36] iio: humidity: hid-sensor-humidity: " Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 29/36] iio: light: hid-sensor-prox: " Sanjay Chitroda
8 siblings, 0 replies; 10+ messages in thread
From: Sanjay Chitroda @ 2026-05-24 19:28 UTC (permalink / raw)
To: jikos, jic23, srinivas.pandruvada
Cc: dlechner, nuno.sa, andy, sanjayembeddedse, sakari.ailus,
linux-input, linux-iio, linux-kernel
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Use devm_hid_sensor_setup_trigger() to automatically release resource
during fail, unbind or removal of driver using devres framework.
This simplify the setup, remove goto, avoid manual resource cleanup in
teardown path.
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
---
drivers/iio/gyro/hid-sensor-gyro-3d.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index f611a10b92c5..157f9204f422 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -328,8 +328,8 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
atomic_set(&gyro_state->common_attributes.data_ready, 0);
- ret = hid_sensor_setup_trigger(indio_dev, name,
- &gyro_state->common_attributes);
+ ret = devm_hid_sensor_setup_trigger(dev, indio_dev, name,
+ &gyro_state->common_attributes);
if (ret < 0) {
dev_err(dev, "trigger setup failed\n");
return ret;
@@ -338,7 +338,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
ret = iio_device_register(indio_dev);
if (ret) {
dev_err(dev, "device register failed\n");
- goto error_remove_trigger;
+ return ret;
}
gyro_state->callbacks.send_event = gyro_3d_proc_event;
@@ -355,8 +355,6 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
error_iio_unreg:
iio_device_unregister(indio_dev);
-error_remove_trigger:
- hid_sensor_remove_trigger(&gyro_state->common_attributes);
return ret;
}
@@ -365,11 +363,9 @@ static void hid_gyro_3d_remove(struct platform_device *pdev)
{
struct hid_sensor_hub_device *hsdev = dev_get_platdata(&pdev->dev);
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
- struct gyro_3d_state *gyro_state = iio_priv(indio_dev);
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_GYRO_3D);
iio_device_unregister(indio_dev);
- hid_sensor_remove_trigger(&gyro_state->common_attributes);
}
static const struct platform_device_id hid_gyro_3d_ids[] = {
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 28/36] iio: humidity: hid-sensor-humidity: drop hid_sensor_remove_trigger() using devm API
2026-05-24 19:28 [PATCH v4 20/36] iio: magnetometer: hid-sensor-magn-3d: use local struct device Sanjay Chitroda
` (6 preceding siblings ...)
2026-05-24 19:28 ` [PATCH v4 27/36] iio: gyro: hid-sensor-gyro-3d: drop hid_sensor_remove_trigger() using devm API Sanjay Chitroda
@ 2026-05-24 19:28 ` Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 29/36] iio: light: hid-sensor-prox: " Sanjay Chitroda
8 siblings, 0 replies; 10+ messages in thread
From: Sanjay Chitroda @ 2026-05-24 19:28 UTC (permalink / raw)
To: jikos, jic23, srinivas.pandruvada
Cc: dlechner, nuno.sa, andy, sanjayembeddedse, sakari.ailus,
linux-input, linux-iio, linux-kernel
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Use devm_hid_sensor_setup_trigger() to automatically release resources
during failure, unbind or removal of driver using devres framework.
This is done in a way to simplify the setup, remove goto and avoid manual
resource cleanup in teardown path.
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
---
changes in v4:
- No update in change, added Tested-by tag
changes in v3:
- Update commit message based on review comment from Andy
- Based on discussion using parent device of HID platform driver used
with devres framework for this driver
- v2 link -> https://lore.kernel.org/all/20260429175918.2541914-5-sanjayembedded@gmail.com/
---
drivers/iio/humidity/hid-sensor-humidity.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/humidity/hid-sensor-humidity.c b/drivers/iio/humidity/hid-sensor-humidity.c
index d310ec43a118..4d4282e4b6e4 100644
--- a/drivers/iio/humidity/hid-sensor-humidity.c
+++ b/drivers/iio/humidity/hid-sensor-humidity.c
@@ -234,8 +234,8 @@ static int hid_humidity_probe(struct platform_device *pdev)
atomic_set(&humid_st->common_attributes.data_ready, 0);
- ret = hid_sensor_setup_trigger(indio_dev, name,
- &humid_st->common_attributes);
+ ret = devm_hid_sensor_setup_trigger(dev, indio_dev, name,
+ &humid_st->common_attributes);
if (ret)
return ret;
@@ -245,7 +245,7 @@ static int hid_humidity_probe(struct platform_device *pdev)
ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_HUMIDITY,
&humidity_callbacks);
if (ret)
- goto error_remove_trigger;
+ return ret;
ret = iio_device_register(indio_dev);
if (ret)
@@ -255,8 +255,6 @@ static int hid_humidity_probe(struct platform_device *pdev)
error_remove_callback:
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_HUMIDITY);
-error_remove_trigger:
- hid_sensor_remove_trigger(&humid_st->common_attributes);
return ret;
}
@@ -265,11 +263,9 @@ static void hid_humidity_remove(struct platform_device *pdev)
{
struct hid_sensor_hub_device *hsdev = dev_get_platdata(&pdev->dev);
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
- struct hid_humidity_state *humid_st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_HUMIDITY);
- hid_sensor_remove_trigger(&humid_st->common_attributes);
}
static const struct platform_device_id hid_humidity_ids[] = {
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 29/36] iio: light: hid-sensor-prox: drop hid_sensor_remove_trigger() using devm API
2026-05-24 19:28 [PATCH v4 20/36] iio: magnetometer: hid-sensor-magn-3d: use local struct device Sanjay Chitroda
` (7 preceding siblings ...)
2026-05-24 19:28 ` [PATCH v4 28/36] iio: humidity: hid-sensor-humidity: " Sanjay Chitroda
@ 2026-05-24 19:28 ` Sanjay Chitroda
8 siblings, 0 replies; 10+ messages in thread
From: Sanjay Chitroda @ 2026-05-24 19:28 UTC (permalink / raw)
To: jikos, jic23, srinivas.pandruvada
Cc: dlechner, nuno.sa, andy, sanjayembeddedse, sakari.ailus,
linux-input, linux-iio, linux-kernel
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Use devm_hid_sensor_setup_trigger() to automatically release resource
during fail, unbind or removal of driver using devres framework.
This simplify the setup, remove goto, avoid manual resource cleanup in
teardown path.
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
---
drivers/iio/light/hid-sensor-prox.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index eff206d7b812..85b06af67611 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -312,8 +312,8 @@ static int hid_prox_probe(struct platform_device *pdev)
atomic_set(&prox_state->common_attributes.data_ready, 0);
- ret = hid_sensor_setup_trigger(indio_dev, name,
- &prox_state->common_attributes);
+ ret = devm_hid_sensor_setup_trigger(dev, indio_dev, name,
+ &prox_state->common_attributes);
if (ret) {
dev_err(dev, "trigger setup failed\n");
return ret;
@@ -322,7 +322,7 @@ static int hid_prox_probe(struct platform_device *pdev)
ret = iio_device_register(indio_dev);
if (ret) {
dev_err(dev, "device register failed\n");
- goto error_remove_trigger;
+ return ret;
}
prox_state->callbacks.send_event = prox_proc_event;
@@ -339,8 +339,6 @@ static int hid_prox_probe(struct platform_device *pdev)
error_iio_unreg:
iio_device_unregister(indio_dev);
-error_remove_trigger:
- hid_sensor_remove_trigger(&prox_state->common_attributes);
return ret;
}
@@ -349,11 +347,9 @@ static void hid_prox_remove(struct platform_device *pdev)
{
struct hid_sensor_hub_device *hsdev = dev_get_platdata(&pdev->dev);
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
- struct prox_state *prox_state = iio_priv(indio_dev);
sensor_hub_remove_callback(hsdev, hsdev->usage);
iio_device_unregister(indio_dev);
- hid_sensor_remove_trigger(&prox_state->common_attributes);
}
static const struct platform_device_id hid_prox_ids[] = {
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-05-24 19:28 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-24 19:28 [PATCH v4 20/36] iio: magnetometer: hid-sensor-magn-3d: use local struct device Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 21/36] iio: orientation: hid-sensor-incl-3d: " Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 22/36] iio: orientation: hid-sensor-rotation: " Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 23/36] iio: position: hid-sensor-custom-intel-hinge: " Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 24/36] iio: pressure: hid-sensor-press: " Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 25/36] iio: hid-sensors: remove unused iio_dev argument Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 26/36] iio: hid-sensors: introduce device managed API Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 27/36] iio: gyro: hid-sensor-gyro-3d: drop hid_sensor_remove_trigger() using devm API Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 28/36] iio: humidity: hid-sensor-humidity: " Sanjay Chitroda
2026-05-24 19:28 ` [PATCH v4 29/36] iio: light: hid-sensor-prox: " Sanjay Chitroda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox