Skip to content

Commit aac91ae

Browse files
ribaldagregkh
authored andcommitted
media: uvcvideo: Fix deferred probing error
commit 387e893 upstream. 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: 2886477 ("media: uvcvideo: Implement UVC_EXT_GPIO_UNIT") Reviewed-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Message-ID: <20250313-uvc-eprobedefer-v3-1-a1d312708eef@chromium.org> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6d2b12e commit aac91ae

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

drivers/media/usb/uvc/uvc_driver.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,13 +2217,16 @@ static int uvc_probe(struct usb_interface *intf,
22172217
#endif
22182218

22192219
/* Parse the Video Class control descriptor. */
2220-
if (uvc_parse_control(dev) < 0) {
2220+
ret = uvc_parse_control(dev);
2221+
if (ret < 0) {
2222+
ret = -ENODEV;
22212223
uvc_dbg(dev, PROBE, "Unable to parse UVC descriptors\n");
22222224
goto error;
22232225
}
22242226

22252227
/* Parse the associated GPIOs. */
2226-
if (uvc_gpio_parse(dev) < 0) {
2228+
ret = uvc_gpio_parse(dev);
2229+
if (ret < 0) {
22272230
uvc_dbg(dev, PROBE, "Unable to parse UVC GPIOs\n");
22282231
goto error;
22292232
}
@@ -2249,24 +2252,32 @@ static int uvc_probe(struct usb_interface *intf,
22492252
}
22502253

22512254
/* Register the V4L2 device. */
2252-
if (v4l2_device_register(&intf->dev, &dev->vdev) < 0)
2255+
ret = v4l2_device_register(&intf->dev, &dev->vdev);
2256+
if (ret < 0)
22532257
goto error;
22542258

22552259
/* Scan the device for video chains. */
2256-
if (uvc_scan_device(dev) < 0)
2260+
if (uvc_scan_device(dev) < 0) {
2261+
ret = -ENODEV;
22572262
goto error;
2263+
}
22582264

22592265
/* Initialize controls. */
2260-
if (uvc_ctrl_init_device(dev) < 0)
2266+
if (uvc_ctrl_init_device(dev) < 0) {
2267+
ret = -ENODEV;
22612268
goto error;
2269+
}
22622270

22632271
/* Register video device nodes. */
2264-
if (uvc_register_chains(dev) < 0)
2272+
if (uvc_register_chains(dev) < 0) {
2273+
ret = -ENODEV;
22652274
goto error;
2275+
}
22662276

22672277
#ifdef CONFIG_MEDIA_CONTROLLER
22682278
/* Register the media device node */
2269-
if (media_device_register(&dev->mdev) < 0)
2279+
ret = media_device_register(&dev->mdev);
2280+
if (ret < 0)
22702281
goto error;
22712282
#endif
22722283
/* Save our data pointer in the interface data. */
@@ -2300,7 +2311,7 @@ static int uvc_probe(struct usb_interface *intf,
23002311
error:
23012312
uvc_unregister_video(dev);
23022313
kref_put(&dev->ref, uvc_delete);
2303-
return -ENODEV;
2314+
return ret;
23042315
}
23052316

23062317
static void uvc_disconnect(struct usb_interface *intf)

0 commit comments

Comments
 (0)