* [PATCH v2 0/2] HID: iio: gyro: hid-sensor-gyro-3d: probe cleanup
@ 2026-07-24 17:27 Sanjay Chitroda via B4 Relay
2026-07-24 17:27 ` [PATCH v2 1/2] iio: gyro: hid-sensor-gyro-3d: Remove redundant dev_err() Sanjay Chitroda via B4 Relay
2026-07-24 17:27 ` [PATCH v2 2/2] iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe() Sanjay Chitroda via B4 Relay
0 siblings, 2 replies; 5+ messages in thread
From: Sanjay Chitroda via B4 Relay @ 2026-07-24 17:27 UTC (permalink / raw)
To: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada, David Lechner,
Nuno Sá, Andy Shevchenko
Cc: linux-input, linux-iio, linux-kernel, Sanjay Chitroda
Hi all,
This series cleans up probe error handling in the hid-sensor-gyro-3d
driver by removing redundant dev_err() calls and replacing remaining
dev_err() with dev_err_probe() to simplify error handling.
Testing:
- Compiled with W=1 for each patch in series
---
Changes in v2:
- EDITME: describe what is new in this series revision.
- EDITME: use bulletpoints and terse descriptions.
- Link to v1: https://patch.msgid.link/20260724-24-july-hid-gyro-dev-log-clenaup-v1-0-0c932b77104a@gmail.com
---
Sanjay Chitroda (2):
iio: gyro: hid-sensor-gyro-3d: Remove redundant dev_err()
iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe()
drivers/iio/gyro/hid-sensor-gyro-3d.c | 35 ++++++++++++-----------------------
1 file changed, 12 insertions(+), 23 deletions(-)
---
base-commit: 36c12dbda81c284d72f3c64689461647497b643b
change-id: 20260724-24-july-hid-gyro-dev-log-clenaup-488534e25965
Best regards,
--
Sanjay Chitroda <sanjayembeddedse@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] iio: gyro: hid-sensor-gyro-3d: Remove redundant dev_err()
2026-07-24 17:27 [PATCH v2 0/2] HID: iio: gyro: hid-sensor-gyro-3d: probe cleanup Sanjay Chitroda via B4 Relay
@ 2026-07-24 17:27 ` Sanjay Chitroda via B4 Relay
2026-07-27 1:22 ` Jonathan Cameron
2026-07-24 17:27 ` [PATCH v2 2/2] iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe() Sanjay Chitroda via B4 Relay
1 sibling, 1 reply; 5+ messages in thread
From: Sanjay Chitroda via B4 Relay @ 2026-07-24 17:27 UTC (permalink / raw)
To: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada, David Lechner,
Nuno Sá, Andy Shevchenko
Cc: linux-input, linux-iio, linux-kernel, Sanjay Chitroda
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Respective APIs used during probe setup already emit detailed error
messages or return appropriate standard error codes on failure.
Remove the redundant/dead driver-specific dev_err() calls to avoid
duplicate error reporting.
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
---
drivers/iio/gyro/hid-sensor-gyro-3d.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index 58250a972567..bcf53e267701 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -291,10 +291,8 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
indio_dev->channels = devm_kmemdup(&pdev->dev, gyro_3d_channels,
sizeof(gyro_3d_channels), GFP_KERNEL);
- if (!indio_dev->channels) {
- dev_err(&pdev->dev, "failed to duplicate channels\n");
+ if (!indio_dev->channels)
return -ENOMEM;
- }
ret = gyro_3d_parse_report(pdev, hsdev,
(struct iio_chan_spec *)indio_dev->channels,
@@ -313,26 +311,20 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
ret = hid_sensor_setup_trigger(indio_dev, name,
&gyro_state->common_attributes);
- if (ret < 0) {
- dev_err(&pdev->dev, "trigger setup failed\n");
+ if (ret < 0)
return ret;
- }
gyro_state->callbacks.send_event = gyro_3d_proc_event;
gyro_state->callbacks.capture_sample = gyro_3d_capture_sample;
gyro_state->callbacks.pdev = pdev;
ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_GYRO_3D,
&gyro_state->callbacks);
- if (ret < 0) {
- dev_err(&pdev->dev, "callback reg failed\n");
+ if (ret < 0)
goto error_remove_trigger;
- }
ret = iio_device_register(indio_dev);
- if (ret) {
- dev_err(&pdev->dev, "device register failed\n");
+ if (ret)
goto error_remove_callback;
- }
return ret;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe()
2026-07-24 17:27 [PATCH v2 0/2] HID: iio: gyro: hid-sensor-gyro-3d: probe cleanup Sanjay Chitroda via B4 Relay
2026-07-24 17:27 ` [PATCH v2 1/2] iio: gyro: hid-sensor-gyro-3d: Remove redundant dev_err() Sanjay Chitroda via B4 Relay
@ 2026-07-24 17:27 ` Sanjay Chitroda via B4 Relay
2026-07-27 1:25 ` Jonathan Cameron
1 sibling, 1 reply; 5+ messages in thread
From: Sanjay Chitroda via B4 Relay @ 2026-07-24 17:27 UTC (permalink / raw)
To: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada, David Lechner,
Nuno Sá, Andy Shevchenko
Cc: linux-input, linux-iio, linux-kernel, Sanjay Chitroda
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Replace dev_err() calls with dev_err_probe() during probe.
dev_err_probe() makes error code handling simpler and handle
deferred probe nicely (avoid spamming logs).
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
---
drivers/iio/gyro/hid-sensor-gyro-3d.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index bcf53e267701..749a2ecbc2d1 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -264,13 +264,14 @@ static int gyro_3d_parse_report(struct platform_device *pdev,
/* Function to initialize the processing for usage id */
static int hid_gyro_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 const char *name = "gyro_3d";
struct iio_dev *indio_dev;
struct gyro_3d_state *gyro_state;
- indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*gyro_state));
+ indio_dev = devm_iio_device_alloc(dev, sizeof(*gyro_state));
if (!indio_dev)
return -ENOMEM;
platform_set_drvdata(pdev, indio_dev);
@@ -284,12 +285,10 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
&gyro_state->common_attributes,
gyro_3d_sensitivity_addresses,
ARRAY_SIZE(gyro_3d_sensitivity_addresses));
- if (ret) {
- dev_err(&pdev->dev, "failed to setup common attributes\n");
- return ret;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to setup common attributes\n");
- indio_dev->channels = devm_kmemdup(&pdev->dev, gyro_3d_channels,
+ indio_dev->channels = devm_kmemdup(dev, gyro_3d_channels,
sizeof(gyro_3d_channels), GFP_KERNEL);
if (!indio_dev->channels)
return -ENOMEM;
@@ -297,10 +296,8 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
ret = gyro_3d_parse_report(pdev, hsdev,
(struct iio_chan_spec *)indio_dev->channels,
HID_USAGE_SENSOR_GYRO_3D, gyro_state);
- if (ret) {
- dev_err(&pdev->dev, "failed to setup attributes\n");
- return ret;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to setup attributes\n");
indio_dev->num_channels = ARRAY_SIZE(gyro_3d_channels);
indio_dev->info = &gyro_3d_info;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] iio: gyro: hid-sensor-gyro-3d: Remove redundant dev_err()
2026-07-24 17:27 ` [PATCH v2 1/2] iio: gyro: hid-sensor-gyro-3d: Remove redundant dev_err() Sanjay Chitroda via B4 Relay
@ 2026-07-27 1:22 ` Jonathan Cameron
0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2026-07-27 1:22 UTC (permalink / raw)
To: Sanjay Chitroda via B4 Relay
Cc: sanjayembeddedse, Jiri Kosina, Srinivas Pandruvada, David Lechner,
Nuno Sá, Andy Shevchenko, linux-input, linux-iio,
linux-kernel
On Fri, 24 Jul 2026 22:57:20 +0530
Sanjay Chitroda via B4 Relay <devnull+sanjayembeddedse.gmail.com@kernel.org> wrote:
> From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
>
> Respective APIs used during probe setup already emit detailed error
> messages or return appropriate standard error codes on failure.
>
> Remove the redundant/dead driver-specific dev_err() calls to avoid
> duplicate error reporting.
>
> Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
> ---
> drivers/iio/gyro/hid-sensor-gyro-3d.c | 16 ++++------------
> 1 file changed, 4 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> index 58250a972567..bcf53e267701 100644
> --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
> +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> gyro_state->callbacks.pdev = pdev;
> ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_GYRO_3D,
> &gyro_state->callbacks);
> - if (ret < 0) {
> - dev_err(&pdev->dev, "callback reg failed\n");
Hmm. Just about on this one returning sufficient error codes.
However the caller of this can't differentiate those values from
the same values from other calls in this function.
> + if (ret < 0)
> goto error_remove_trigger;
> - }
>
> ret = iio_device_register(indio_dev);
This one I'm more dubious about. There is a lot of work done
iio_device_register() and traditionally we haven't been that
focused on printing error messages. There are some paths covered
but some others are not.
I'm not sure it is useful to just return the error code as that
matches with other paths that will give similar error codes.
Maybe it is worth considering doing an audit of iio_device_register()
and making sure that suitable errors are printed in all locations
but that will be hard to do and I'm not sure I want to see the churn
of ripping out prints on this in every driver because we now think
the core is doing enough.
I'm definitely open to gathering some more opinions on this though
so let us see if others reply to the thread.
Jonathan
> - if (ret) {
> - dev_err(&pdev->dev, "device register failed\n");
> + if (ret)
> goto error_remove_callback;
> - }
>
> return ret;
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe()
2026-07-24 17:27 ` [PATCH v2 2/2] iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe() Sanjay Chitroda via B4 Relay
@ 2026-07-27 1:25 ` Jonathan Cameron
0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2026-07-27 1:25 UTC (permalink / raw)
To: Sanjay Chitroda via B4 Relay
Cc: sanjayembeddedse, Jiri Kosina, Srinivas Pandruvada, David Lechner,
Nuno Sá, Andy Shevchenko, linux-input, linux-iio,
linux-kernel
On Fri, 24 Jul 2026 22:57:21 +0530
Sanjay Chitroda via B4 Relay <devnull+sanjayembeddedse.gmail.com@kernel.org> wrote:
> From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
>
> Replace dev_err() calls with dev_err_probe() during probe.
>
> dev_err_probe() makes error code handling simpler and handle
> deferred probe nicely (avoid spamming logs).
There are changes in here that aren't mentioned.
A common way to handle this is to add.
"To simplify the added dev_err_probe() calls, add a local struct devic
variable."
Then in a follow up patch do the rest and state something like
"Use the local struct device *dev to replace &pdev->dev, simplifying
code."
>
> Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
> ---
> drivers/iio/gyro/hid-sensor-gyro-3d.c | 19 ++++++++-----------
> 1 file changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> index bcf53e267701..749a2ecbc2d1 100644
> --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
> +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> @@ -264,13 +264,14 @@ static int gyro_3d_parse_report(struct platform_device *pdev,
> /* Function to initialize the processing for usage id */
> static int hid_gyro_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 const char *name = "gyro_3d";
> struct iio_dev *indio_dev;
> struct gyro_3d_state *gyro_state;
>
> - indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*gyro_state));
> + indio_dev = devm_iio_device_alloc(dev, sizeof(*gyro_state));
> if (!indio_dev)
> return -ENOMEM;
> platform_set_drvdata(pdev, indio_dev);
> @@ -284,12 +285,10 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
> &gyro_state->common_attributes,
> gyro_3d_sensitivity_addresses,
> ARRAY_SIZE(gyro_3d_sensitivity_addresses));
> - if (ret) {
> - dev_err(&pdev->dev, "failed to setup common attributes\n");
> - return ret;
> - }
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to setup common attributes\n");
>
> - indio_dev->channels = devm_kmemdup(&pdev->dev, gyro_3d_channels,
> + indio_dev->channels = devm_kmemdup(dev, gyro_3d_channels,
> sizeof(gyro_3d_channels), GFP_KERNEL);
This is the case I'm saying doesn't belong in this patch.
Jonathan
> if (!indio_dev->channels)
> return -ENOMEM;
> @@ -297,10 +296,8 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
> ret = gyro_3d_parse_report(pdev, hsdev,
> (struct iio_chan_spec *)indio_dev->channels,
> HID_USAGE_SENSOR_GYRO_3D, gyro_state);
> - if (ret) {
> - dev_err(&pdev->dev, "failed to setup attributes\n");
> - return ret;
> - }
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to setup attributes\n");
>
> indio_dev->num_channels = ARRAY_SIZE(gyro_3d_channels);
> indio_dev->info = &gyro_3d_info;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-27 1:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 17:27 [PATCH v2 0/2] HID: iio: gyro: hid-sensor-gyro-3d: probe cleanup Sanjay Chitroda via B4 Relay
2026-07-24 17:27 ` [PATCH v2 1/2] iio: gyro: hid-sensor-gyro-3d: Remove redundant dev_err() Sanjay Chitroda via B4 Relay
2026-07-27 1:22 ` Jonathan Cameron
2026-07-24 17:27 ` [PATCH v2 2/2] iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe() Sanjay Chitroda via B4 Relay
2026-07-27 1:25 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox