* [PATCH v2 0/2] media: uvcvideo: Fix Fix deferred probing error
@ 2025-03-03 19:07 Ricardo Ribalda
2025-03-03 19:07 ` [PATCH v2 1/2] media: uvcvideo: " Ricardo Ribalda
2025-03-03 19:07 ` [PATCH v2 2/2] media: uvcvideo: Use dev_err_probe for devm_gpiod_get_optional Ricardo Ribalda
0 siblings, 2 replies; 4+ messages in thread
From: Ricardo Ribalda @ 2025-03-03 19:07 UTC (permalink / raw)
To: Laurent Pinchart, Hans de Goede, Mauro Carvalho Chehab
Cc: Mauro Carvalho Chehab, linux-media, linux-kernel,
Ricardo Ribalda, stable, Douglas Anderson
uvc_gpio_parse() can return -EPROBE_DEFER when the GPIOs it depends on
have not yet been probed.
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
Changes in v2:
- Add follow-up patch for using dev_err_probe
- Avoid error_retcode style
- Link to v1: https://lore.kernel.org/r/20250129-uvc-eprobedefer-v1-1-643b2603c0d2@chromium.org
---
Ricardo Ribalda (2):
media: uvcvideo: Fix deferred probing error
media: uvcvideo: Use dev_err_probe for devm_gpiod_get_optional
drivers/media/usb/uvc/uvc_driver.c | 36 ++++++++++++++++++++++++++----------
1 file changed, 26 insertions(+), 10 deletions(-)
---
base-commit: f4b211714bcc70effa60c34d9fa613d182e3ef1e
change-id: 20250129-uvc-eprobedefer-b5ebb4db63cc
Best regards,
--
Ricardo Ribalda <ribalda@chromium.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] media: uvcvideo: Fix deferred probing error
2025-03-03 19:07 [PATCH v2 0/2] media: uvcvideo: Fix Fix deferred probing error Ricardo Ribalda
@ 2025-03-03 19:07 ` Ricardo Ribalda
2025-03-03 19:07 ` [PATCH v2 2/2] media: uvcvideo: Use dev_err_probe for devm_gpiod_get_optional Ricardo Ribalda
1 sibling, 0 replies; 4+ messages in thread
From: Ricardo Ribalda @ 2025-03-03 19:07 UTC (permalink / raw)
To: Laurent Pinchart, Hans de Goede, Mauro Carvalho Chehab
Cc: Mauro Carvalho Chehab, linux-media, linux-kernel,
Ricardo Ribalda, stable, Douglas Anderson
uvc_gpio_parse() can return -EPROBE_DEFER when the GPIOs it depends on
have not yet been probed. This return code should be propagated to the
caller of uvc_probe() to ensure that probing is retried when the required
GPIOs become available.
Currently, this error code is incorrectly converted to -ENODEV,
causing some internal cameras to be ignored.
This commit fixes this issue by propagating the -EPROBE_DEFER error.
Cc: stable@vger.kernel.org
Fixes: 2886477ff987 ("media: uvcvideo: Implement UVC_EXT_GPIO_UNIT")
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/media/usb/uvc/uvc_driver.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index deadbcea5e22..e966bdb9239f 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -2231,13 +2231,16 @@ static int uvc_probe(struct usb_interface *intf,
#endif
/* Parse the Video Class control descriptor. */
- if (uvc_parse_control(dev) < 0) {
+ ret = uvc_parse_control(dev);
+ if (ret < 0) {
+ ret = -ENODEV;
uvc_dbg(dev, PROBE, "Unable to parse UVC descriptors\n");
goto error;
}
/* Parse the associated GPIOs. */
- if (uvc_gpio_parse(dev) < 0) {
+ ret = uvc_gpio_parse(dev);
+ if (ret < 0) {
uvc_dbg(dev, PROBE, "Unable to parse UVC GPIOs\n");
goto error;
}
@@ -2263,24 +2266,32 @@ static int uvc_probe(struct usb_interface *intf,
}
/* Register the V4L2 device. */
- if (v4l2_device_register(&intf->dev, &dev->vdev) < 0)
+ ret = v4l2_device_register(&intf->dev, &dev->vdev);
+ if (ret < 0)
goto error;
/* Scan the device for video chains. */
- if (uvc_scan_device(dev) < 0)
+ if (uvc_scan_device(dev) < 0) {
+ ret = -ENODEV;
goto error;
+ }
/* Initialize controls. */
- if (uvc_ctrl_init_device(dev) < 0)
+ if (uvc_ctrl_init_device(dev) < 0) {
+ ret = -ENODEV;
goto error;
+ }
/* Register video device nodes. */
- if (uvc_register_chains(dev) < 0)
+ if (uvc_register_chains(dev) < 0) {
+ ret = -ENODEV;
goto error;
+ }
#ifdef CONFIG_MEDIA_CONTROLLER
/* Register the media device node */
- if (media_device_register(&dev->mdev) < 0)
+ ret = media_device_register(&dev->mdev);
+ if (ret < 0)
goto error;
#endif
/* Save our data pointer in the interface data. */
@@ -2314,7 +2325,7 @@ static int uvc_probe(struct usb_interface *intf,
error:
uvc_unregister_video(dev);
kref_put(&dev->ref, uvc_delete);
- return -ENODEV;
+ return ret;
}
static void uvc_disconnect(struct usb_interface *intf)
--
2.48.1.711.g2feabab25a-goog
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] media: uvcvideo: Use dev_err_probe for devm_gpiod_get_optional
2025-03-03 19:07 [PATCH v2 0/2] media: uvcvideo: Fix Fix deferred probing error Ricardo Ribalda
2025-03-03 19:07 ` [PATCH v2 1/2] media: uvcvideo: " Ricardo Ribalda
@ 2025-03-03 19:07 ` Ricardo Ribalda
2025-03-07 16:10 ` Doug Anderson
1 sibling, 1 reply; 4+ messages in thread
From: Ricardo Ribalda @ 2025-03-03 19:07 UTC (permalink / raw)
To: Laurent Pinchart, Hans de Goede, Mauro Carvalho Chehab
Cc: Mauro Carvalho Chehab, linux-media, linux-kernel,
Ricardo Ribalda, Doug Anderson
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(-)
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)
--
2.48.1.711.g2feabab25a-goog
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 2/2] media: uvcvideo: Use dev_err_probe for devm_gpiod_get_optional
2025-03-03 19:07 ` [PATCH v2 2/2] media: uvcvideo: Use dev_err_probe for devm_gpiod_get_optional Ricardo Ribalda
@ 2025-03-07 16:10 ` Doug Anderson
0 siblings, 0 replies; 4+ messages in thread
From: Doug Anderson @ 2025-03-07 16:10 UTC (permalink / raw)
To: Ricardo Ribalda
Cc: Laurent Pinchart, Hans de Goede, Mauro Carvalho Chehab,
Mauro Carvalho Chehab, linux-media, linux-kernel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-03-07 16:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-03 19:07 [PATCH v2 0/2] media: uvcvideo: Fix Fix deferred probing error Ricardo Ribalda
2025-03-03 19:07 ` [PATCH v2 1/2] media: uvcvideo: " Ricardo Ribalda
2025-03-03 19:07 ` [PATCH v2 2/2] media: uvcvideo: Use dev_err_probe for devm_gpiod_get_optional Ricardo Ribalda
2025-03-07 16:10 ` Doug Anderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®