Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH 0/2] HID: iio: gyro: hid-sensor-gyro-3d: probe cleanup
@ 2026-07-24 17:14 Sanjay Chitroda via B4 Relay
  2026-07-24 17:14 ` [PATCH 1/2] iio: gyro: hid-sensor-gyro-3d: Remove redundant dev_err() Sanjay Chitroda via B4 Relay
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Sanjay Chitroda via B4 Relay @ 2026-07-24 17:14 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

---
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 1/2] iio: gyro: hid-sensor-gyro-3d: Remove redundant dev_err()
  2026-07-24 17:14 [PATCH 0/2] HID: iio: gyro: hid-sensor-gyro-3d: probe cleanup Sanjay Chitroda via B4 Relay
@ 2026-07-24 17:14 ` Sanjay Chitroda via B4 Relay
  2026-07-24 17:14 ` [PATCH 2/2] iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe() Sanjay Chitroda via B4 Relay
  2026-07-24 17:29 ` [PATCH 0/2] HID: iio: gyro: hid-sensor-gyro-3d: probe cleanup Sanjay Chitroda
  2 siblings, 0 replies; 5+ messages in thread
From: Sanjay Chitroda via B4 Relay @ 2026-07-24 17:14 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 2/2] iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe()
  2026-07-24 17:14 [PATCH 0/2] HID: iio: gyro: hid-sensor-gyro-3d: probe cleanup Sanjay Chitroda via B4 Relay
  2026-07-24 17:14 ` [PATCH 1/2] iio: gyro: hid-sensor-gyro-3d: Remove redundant dev_err() Sanjay Chitroda via B4 Relay
@ 2026-07-24 17:14 ` Sanjay Chitroda via B4 Relay
  2026-07-24 17:23   ` sashiko-bot
  2026-07-24 17:29 ` [PATCH 0/2] HID: iio: gyro: hid-sensor-gyro-3d: probe cleanup Sanjay Chitroda
  2 siblings, 1 reply; 5+ messages in thread
From: Sanjay Chitroda via B4 Relay @ 2026-07-24 17:14 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..48540c9a097c 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)
+		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 2/2] iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe()
  2026-07-24 17:14 ` [PATCH 2/2] iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe() Sanjay Chitroda via B4 Relay
@ 2026-07-24 17:23   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-07-24 17:23 UTC (permalink / raw)
  To: Sanjay Chitroda; +Cc: linux-input, dmitry.torokhov

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The patch drops the `return` statement when handling failures from `gyro_3d_parse_report()`, causing the probe function to continue instead of aborting.
--

--- Patch [2]: [PATCH 2/2] iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe() ---
commit 9e2d893e70018e9931c8153d83e07fffde994281
Author: Sanjay Chitroda <sanjayembeddedse@gmail.com>

iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe()

This commit replaces dev_err() calls with dev_err_probe() during the driver
probe to simplify error code handling and nicely manage deferred probes.

> diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> index bcf53e2677015..48540c9a097c5 100644
> --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
> +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
[ ... ]
> @@ -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)
> +		dev_err_probe(dev, ret, "failed to setup attributes\n");

[Severity: High]
Does this accidentally drop the return statement?

If gyro_3d_parse_report() fails, hid_gyro_3d_probe() will now continue
executing instead of aborting. This could lead to an incompletely initialized
IIO device being registered.

Should this also be returning dev_err_probe(dev, ret, ...), similar to the
previous error handling block in this function?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260724-24-july-hid-gyro-dev-log-clenaup-v1-0-0c932b77104a@gmail.com?part=2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] HID: iio: gyro: hid-sensor-gyro-3d: probe cleanup
  2026-07-24 17:14 [PATCH 0/2] HID: iio: gyro: hid-sensor-gyro-3d: probe cleanup Sanjay Chitroda via B4 Relay
  2026-07-24 17:14 ` [PATCH 1/2] iio: gyro: hid-sensor-gyro-3d: Remove redundant dev_err() Sanjay Chitroda via B4 Relay
  2026-07-24 17:14 ` [PATCH 2/2] iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe() Sanjay Chitroda via B4 Relay
@ 2026-07-24 17:29 ` Sanjay Chitroda
  2 siblings, 0 replies; 5+ messages in thread
From: Sanjay Chitroda @ 2026-07-24 17:29 UTC (permalink / raw)
  To: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada, David Lechner,
	Nuno Sá, Andy Shevchenko, Sanjay Chitroda via B4 Relay
  Cc: linux-input, linux-iio, linux-kernel

Kindly ignore this series, I have re-sent v2.

Thanks, Sanjay


On 24 July 2026 10:44:29 pm IST, Sanjay Chitroda via B4 Relay <devnull+sanjayembeddedse.gmail.com@kernel.org> wrote:
>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
>
>---
>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

end of thread, other threads:[~2026-07-24 17:29 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:14 [PATCH 0/2] HID: iio: gyro: hid-sensor-gyro-3d: probe cleanup Sanjay Chitroda via B4 Relay
2026-07-24 17:14 ` [PATCH 1/2] iio: gyro: hid-sensor-gyro-3d: Remove redundant dev_err() Sanjay Chitroda via B4 Relay
2026-07-24 17:14 ` [PATCH 2/2] iio: gyro: hid-sensor-gyro-3d: Use dev_err_probe() Sanjay Chitroda via B4 Relay
2026-07-24 17:23   ` sashiko-bot
2026-07-24 17:29 ` [PATCH 0/2] HID: iio: gyro: hid-sensor-gyro-3d: probe cleanup Sanjay Chitroda

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