Skip to content

Commit 387e893

Browse files
ribaldahverkuil
authored andcommitted
media: uvcvideo: Fix deferred probing error
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>
1 parent a70705d commit 387e893

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

drivers/media/usb/uvc/uvc_driver.c

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

22342234
/* Parse the Video Class control descriptor. */
2235-
if (uvc_parse_control(dev) < 0) {
2235+
ret = uvc_parse_control(dev);
2236+
if (ret < 0) {
2237+
ret = -ENODEV;
22362238
uvc_dbg(dev, PROBE, "Unable to parse UVC descriptors\n");
22372239
goto error;
22382240
}
22392241

22402242
/* Parse the associated GPIOs. */
2241-
if (uvc_gpio_parse(dev) < 0) {
2243+
ret = uvc_gpio_parse(dev);
2244+
if (ret < 0) {
22422245
uvc_dbg(dev, PROBE, "Unable to parse UVC GPIOs\n");
22432246
goto error;
22442247
}
@@ -2264,24 +2267,32 @@ static int uvc_probe(struct usb_interface *intf,
22642267
}
22652268

22662269
/* Register the V4L2 device. */
2267-
if (v4l2_device_register(&intf->dev, &dev->vdev) < 0)
2270+
ret = v4l2_device_register(&intf->dev, &dev->vdev);
2271+
if (ret < 0)
22682272
goto error;
22692273

22702274
/* Scan the device for video chains. */
2271-
if (uvc_scan_device(dev) < 0)
2275+
if (uvc_scan_device(dev) < 0) {
2276+
ret = -ENODEV;
22722277
goto error;
2278+
}
22732279

22742280
/* Initialize controls. */
2275-
if (uvc_ctrl_init_device(dev) < 0)
2281+
if (uvc_ctrl_init_device(dev) < 0) {
2282+
ret = -ENODEV;
22762283
goto error;
2284+
}
22772285

22782286
/* Register video device nodes. */
2279-
if (uvc_register_chains(dev) < 0)
2287+
if (uvc_register_chains(dev) < 0) {
2288+
ret = -ENODEV;
22802289
goto error;
2290+
}
22812291

22822292
#ifdef CONFIG_MEDIA_CONTROLLER
22832293
/* Register the media device node */
2284-
if (media_device_register(&dev->mdev) < 0)
2294+
ret = media_device_register(&dev->mdev);
2295+
if (ret < 0)
22852296
goto error;
22862297
#endif
22872298
/* Save our data pointer in the interface data. */
@@ -2315,7 +2326,7 @@ static int uvc_probe(struct usb_interface *intf,
23152326
error:
23162327
uvc_unregister_video(dev);
23172328
kref_put(&dev->ref, uvc_delete);
2318-
return -ENODEV;
2329+
return ret;
23192330
}
23202331

23212332
static void uvc_disconnect(struct usb_interface *intf)

0 commit comments

Comments
 (0)