diff mbox series

[v2,2/2] media: uvcvideo: Use dev_err_probe for devm_gpiod_get_optional

Message ID 20250303-uvc-eprobedefer-v2-2-be7c987cc3ca@chromium.org
State New
Headers show
Series media: uvcvideo: Fix Fix deferred probing error | expand

Commit Message

Ricardo Ribalda March 3, 2025, 7:07 p.m. UTC
Use the dev_err_probe() helper for devm_gpiod_get_optional(), like we do
with gpiod_to_irq()

That eventually calls device_set_deferred_probe_reason() which can be
helpful for tracking down problems.

Suggested-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/usb/uvc/uvc_driver.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Doug Anderson March 7, 2025, 4:10 p.m. UTC | #1
Hi,

On Mon, Mar 3, 2025 at 11:07 AM Ricardo Ribalda <ribalda@chromium.org> wrote:
>
> Use the dev_err_probe() helper for devm_gpiod_get_optional(), like we do
> with gpiod_to_irq()
>
> That eventually calls device_set_deferred_probe_reason() which can be
> helpful for tracking down problems.
>
> Suggested-by: Doug Anderson <dianders@chromium.org>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>  drivers/media/usb/uvc/uvc_driver.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)

Reviewed-by: Douglas Anderson <dianders@chromium.org>

NOTE: If it were up to me, I would have also changed the caller of
uvc_gpio_parse() to no longer print an error message in the case of
errors. After your patch here all causes of errors in uvc_gpio_parse()
will have already printed something, so the extra print is not
terribly useful and just clutters the code and logs. That being said,
it's not a huge deal and I'm happy to let owners of this code indicate
what they like. :-)

-Doug
diff mbox series

Patch

diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index e966bdb9239f..0094cfc092d6 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1297,8 +1297,13 @@  static int uvc_gpio_parse(struct uvc_device *dev)
 
 	gpio_privacy = devm_gpiod_get_optional(&dev->intf->dev, "privacy",
 					       GPIOD_IN);
-	if (IS_ERR_OR_NULL(gpio_privacy))
-		return PTR_ERR_OR_ZERO(gpio_privacy);
+	if (!gpio_privacy)
+		return 0;
+
+	if (IS_ERR(gpio_privacy))
+		return dev_err_probe(&dev->intf->dev,
+				     PTR_ERR(gpio_privacy),
+				     "Can't get privacy GPIO\n");
 
 	irq = gpiod_to_irq(gpio_privacy);
 	if (irq < 0)