linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] media: uvcvideo: Populate all errors in uvc_probe()
@ 2025-05-23 14:28 Ricardo Ribalda
  2025-05-26 13:15 ` Laurent Pinchart
  2025-05-26 13:21 ` Hans de Goede
  0 siblings, 2 replies; 4+ messages in thread
From: Ricardo Ribalda @ 2025-05-23 14:28 UTC (permalink / raw)
  To: Laurent Pinchart, Hans de Goede, Mauro Carvalho Chehab
  Cc: linux-media, linux-kernel, Ricardo Ribalda

Now we are replacing most of the error codes with -ENODEV.
Instead, Populate the error code from the functions called by
uvc_probe().

Take this opportunity to replace a generic error code from
uvc_scan_device() into something more meaningful.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
CodeStyle and refactor patches after the last uvc Pull Request.
---
Changes in v2:
- Patches 1-3 will be handled by Laurent: https://lore.kernel.org/linux-media/20250523125840.GG12514@pendragon.ideasonboard.com/
- Properly propagate ret value. Sorry about that :)
- Link to v1: https://lore.kernel.org/r/20250509-uvc-followup-v1-0-73bcde30d2b5@chromium.org
---
 drivers/media/usb/uvc/uvc_driver.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index da24a655ab68cc0957762f2b67387677c22224d1..04552da114354128b0cc8fb25e1cc645498ac323 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1866,7 +1866,7 @@ static int uvc_scan_device(struct uvc_device *dev)
 
 	if (list_empty(&dev->chains)) {
 		dev_info(&dev->udev->dev, "No valid video chain found.\n");
-		return -1;
+		return -ENODEV;
 	}
 
 	/* Add GPIO entity to the first chain. */
@@ -2239,7 +2239,6 @@ static int uvc_probe(struct usb_interface *intf,
 	/* Parse the Video Class control descriptor. */
 	ret = uvc_parse_control(dev);
 	if (ret < 0) {
-		ret = -ENODEV;
 		uvc_dbg(dev, PROBE, "Unable to parse UVC descriptors\n");
 		goto error;
 	}
@@ -2275,22 +2274,19 @@ static int uvc_probe(struct usb_interface *intf,
 		goto error;
 
 	/* Scan the device for video chains. */
-	if (uvc_scan_device(dev) < 0) {
-		ret = -ENODEV;
+	ret = uvc_scan_device(dev);
+	if (ret < 0)
 		goto error;
-	}
 
 	/* Initialize controls. */
-	if (uvc_ctrl_init_device(dev) < 0) {
-		ret = -ENODEV;
+	ret = uvc_ctrl_init_device(dev);
+	if (ret < 0)
 		goto error;
-	}
 
 	/* Register video device nodes. */
-	if (uvc_register_chains(dev) < 0) {
-		ret = -ENODEV;
+	ret = uvc_register_chains(dev);
+	if (ret < 0)
 		goto error;
-	}
 
 #ifdef CONFIG_MEDIA_CONTROLLER
 	/* Register the media device node */

---
base-commit: 5e1ff2314797bf53636468a97719a8222deca9ae
change-id: 20250509-uvc-followup-d97ff563df95

Best regards,
-- 
Ricardo Ribalda <ribalda@chromium.org>


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

* Re: [PATCH v2] media: uvcvideo: Populate all errors in uvc_probe()
  2025-05-23 14:28 [PATCH v2] media: uvcvideo: Populate all errors in uvc_probe() Ricardo Ribalda
@ 2025-05-26 13:15 ` Laurent Pinchart
  2025-05-26 13:21 ` Hans de Goede
  1 sibling, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2025-05-26 13:15 UTC (permalink / raw)
  To: Ricardo Ribalda
  Cc: Hans de Goede, Mauro Carvalho Chehab, linux-media, linux-kernel

Hi Ricardo,

Thank you for the patch.

On Fri, May 23, 2025 at 02:28:41PM +0000, Ricardo Ribalda wrote:
> Now we are replacing most of the error codes with -ENODEV.
> Instead, Populate the error code from the functions called by
> uvc_probe().
> 
> Take this opportunity to replace a generic error code from
> uvc_scan_device() into something more meaningful.
> 
> Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> CodeStyle and refactor patches after the last uvc Pull Request.
> ---
> Changes in v2:
> - Patches 1-3 will be handled by Laurent: https://lore.kernel.org/linux-media/20250523125840.GG12514@pendragon.ideasonboard.com/
> - Properly propagate ret value. Sorry about that :)
> - Link to v1: https://lore.kernel.org/r/20250509-uvc-followup-v1-0-73bcde30d2b5@chromium.org
> ---
>  drivers/media/usb/uvc/uvc_driver.c | 18 +++++++-----------
>  1 file changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
> index da24a655ab68cc0957762f2b67387677c22224d1..04552da114354128b0cc8fb25e1cc645498ac323 100644
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -1866,7 +1866,7 @@ static int uvc_scan_device(struct uvc_device *dev)
>  
>  	if (list_empty(&dev->chains)) {
>  		dev_info(&dev->udev->dev, "No valid video chain found.\n");
> -		return -1;
> +		return -ENODEV;
>  	}
>  
>  	/* Add GPIO entity to the first chain. */
> @@ -2239,7 +2239,6 @@ static int uvc_probe(struct usb_interface *intf,
>  	/* Parse the Video Class control descriptor. */
>  	ret = uvc_parse_control(dev);
>  	if (ret < 0) {
> -		ret = -ENODEV;
>  		uvc_dbg(dev, PROBE, "Unable to parse UVC descriptors\n");
>  		goto error;
>  	}
> @@ -2275,22 +2274,19 @@ static int uvc_probe(struct usb_interface *intf,
>  		goto error;
>  
>  	/* Scan the device for video chains. */
> -	if (uvc_scan_device(dev) < 0) {
> -		ret = -ENODEV;
> +	ret = uvc_scan_device(dev);
> +	if (ret < 0)
>  		goto error;
> -	}
>  
>  	/* Initialize controls. */
> -	if (uvc_ctrl_init_device(dev) < 0) {
> -		ret = -ENODEV;
> +	ret = uvc_ctrl_init_device(dev);
> +	if (ret < 0)
>  		goto error;
> -	}
>  
>  	/* Register video device nodes. */
> -	if (uvc_register_chains(dev) < 0) {
> -		ret = -ENODEV;
> +	ret = uvc_register_chains(dev);
> +	if (ret < 0)
>  		goto error;
> -	}
>  
>  #ifdef CONFIG_MEDIA_CONTROLLER
>  	/* Register the media device node */
> 
> ---
> base-commit: 5e1ff2314797bf53636468a97719a8222deca9ae
> change-id: 20250509-uvc-followup-d97ff563df95

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH v2] media: uvcvideo: Populate all errors in uvc_probe()
  2025-05-23 14:28 [PATCH v2] media: uvcvideo: Populate all errors in uvc_probe() Ricardo Ribalda
  2025-05-26 13:15 ` Laurent Pinchart
@ 2025-05-26 13:21 ` Hans de Goede
  2025-05-26 13:32   ` Laurent Pinchart
  1 sibling, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2025-05-26 13:21 UTC (permalink / raw)
  To: Ricardo Ribalda, Laurent Pinchart, Mauro Carvalho Chehab
  Cc: linux-media, linux-kernel

Hi,

On 23-May-25 16:28, Ricardo Ribalda wrote:
> Now we are replacing most of the error codes with -ENODEV.
> Instead, Populate the error code from the functions called by
> uvc_probe().
> 
> Take this opportunity to replace a generic error code from
> uvc_scan_device() into something more meaningful.
> 
> Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hansg@kernel.org>

I have merged this into:

https://gitlab.freedesktop.org/linux-media/users/uvc/-/commits/next/

now.

Regards,

Hans




> ---
> CodeStyle and refactor patches after the last uvc Pull Request.
> ---
> Changes in v2:
> - Patches 1-3 will be handled by Laurent: https://lore.kernel.org/linux-media/20250523125840.GG12514@pendragon.ideasonboard.com/
> - Properly propagate ret value. Sorry about that :)
> - Link to v1: https://lore.kernel.org/r/20250509-uvc-followup-v1-0-73bcde30d2b5@chromium.org
> ---
>  drivers/media/usb/uvc/uvc_driver.c | 18 +++++++-----------
>  1 file changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
> index da24a655ab68cc0957762f2b67387677c22224d1..04552da114354128b0cc8fb25e1cc645498ac323 100644
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -1866,7 +1866,7 @@ static int uvc_scan_device(struct uvc_device *dev)
>  
>  	if (list_empty(&dev->chains)) {
>  		dev_info(&dev->udev->dev, "No valid video chain found.\n");
> -		return -1;
> +		return -ENODEV;
>  	}
>  
>  	/* Add GPIO entity to the first chain. */
> @@ -2239,7 +2239,6 @@ static int uvc_probe(struct usb_interface *intf,
>  	/* Parse the Video Class control descriptor. */
>  	ret = uvc_parse_control(dev);
>  	if (ret < 0) {
> -		ret = -ENODEV;
>  		uvc_dbg(dev, PROBE, "Unable to parse UVC descriptors\n");
>  		goto error;
>  	}
> @@ -2275,22 +2274,19 @@ static int uvc_probe(struct usb_interface *intf,
>  		goto error;
>  
>  	/* Scan the device for video chains. */
> -	if (uvc_scan_device(dev) < 0) {
> -		ret = -ENODEV;
> +	ret = uvc_scan_device(dev);
> +	if (ret < 0)
>  		goto error;
> -	}
>  
>  	/* Initialize controls. */
> -	if (uvc_ctrl_init_device(dev) < 0) {
> -		ret = -ENODEV;
> +	ret = uvc_ctrl_init_device(dev);
> +	if (ret < 0)
>  		goto error;
> -	}
>  
>  	/* Register video device nodes. */
> -	if (uvc_register_chains(dev) < 0) {
> -		ret = -ENODEV;
> +	ret = uvc_register_chains(dev);
> +	if (ret < 0)
>  		goto error;
> -	}
>  
>  #ifdef CONFIG_MEDIA_CONTROLLER
>  	/* Register the media device node */
> 
> ---
> base-commit: 5e1ff2314797bf53636468a97719a8222deca9ae
> change-id: 20250509-uvc-followup-d97ff563df95
> 
> Best regards,


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

* Re: [PATCH v2] media: uvcvideo: Populate all errors in uvc_probe()
  2025-05-26 13:21 ` Hans de Goede
@ 2025-05-26 13:32   ` Laurent Pinchart
  0 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2025-05-26 13:32 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Ricardo Ribalda, Mauro Carvalho Chehab, linux-media, linux-kernel

On Mon, May 26, 2025 at 03:21:37PM +0200, Hans de Goede wrote:
> On 23-May-25 16:28, Ricardo Ribalda wrote:
> > Now we are replacing most of the error codes with -ENODEV.
> > Instead, Populate the error code from the functions called by
> > uvc_probe().
> > 
> > Take this opportunity to replace a generic error code from
> > uvc_scan_device() into something more meaningful.
> > 
> > Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> 
> Thanks, patch looks good to me:
> 
> Reviewed-by: Hans de Goede <hansg@kernel.org>
> 
> I have merged this into:
> 
> https://gitlab.freedesktop.org/linux-media/users/uvc/-/commits/next/
> 
> now.

I was working on this :-/ As it stems from my review comments on v1, I'd
like an opportunity to check before you push.

> > ---
> > CodeStyle and refactor patches after the last uvc Pull Request.
> > ---
> > Changes in v2:
> > - Patches 1-3 will be handled by Laurent: https://lore.kernel.org/linux-media/20250523125840.GG12514@pendragon.ideasonboard.com/
> > - Properly propagate ret value. Sorry about that :)
> > - Link to v1: https://lore.kernel.org/r/20250509-uvc-followup-v1-0-73bcde30d2b5@chromium.org
> > ---
> >  drivers/media/usb/uvc/uvc_driver.c | 18 +++++++-----------
> >  1 file changed, 7 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
> > index da24a655ab68cc0957762f2b67387677c22224d1..04552da114354128b0cc8fb25e1cc645498ac323 100644
> > --- a/drivers/media/usb/uvc/uvc_driver.c
> > +++ b/drivers/media/usb/uvc/uvc_driver.c
> > @@ -1866,7 +1866,7 @@ static int uvc_scan_device(struct uvc_device *dev)
> >  
> >  	if (list_empty(&dev->chains)) {
> >  		dev_info(&dev->udev->dev, "No valid video chain found.\n");
> > -		return -1;
> > +		return -ENODEV;
> >  	}
> >  
> >  	/* Add GPIO entity to the first chain. */
> > @@ -2239,7 +2239,6 @@ static int uvc_probe(struct usb_interface *intf,
> >  	/* Parse the Video Class control descriptor. */
> >  	ret = uvc_parse_control(dev);
> >  	if (ret < 0) {
> > -		ret = -ENODEV;
> >  		uvc_dbg(dev, PROBE, "Unable to parse UVC descriptors\n");
> >  		goto error;
> >  	}
> > @@ -2275,22 +2274,19 @@ static int uvc_probe(struct usb_interface *intf,
> >  		goto error;
> >  
> >  	/* Scan the device for video chains. */
> > -	if (uvc_scan_device(dev) < 0) {
> > -		ret = -ENODEV;
> > +	ret = uvc_scan_device(dev);
> > +	if (ret < 0)
> >  		goto error;
> > -	}
> >  
> >  	/* Initialize controls. */
> > -	if (uvc_ctrl_init_device(dev) < 0) {
> > -		ret = -ENODEV;
> > +	ret = uvc_ctrl_init_device(dev);
> > +	if (ret < 0)
> >  		goto error;
> > -	}
> >  
> >  	/* Register video device nodes. */
> > -	if (uvc_register_chains(dev) < 0) {
> > -		ret = -ENODEV;
> > +	ret = uvc_register_chains(dev);
> > +	if (ret < 0)
> >  		goto error;
> > -	}
> >  
> >  #ifdef CONFIG_MEDIA_CONTROLLER
> >  	/* Register the media device node */
> > 
> > ---
> > base-commit: 5e1ff2314797bf53636468a97719a8222deca9ae
> > change-id: 20250509-uvc-followup-d97ff563df95

-- 
Regards,

Laurent Pinchart

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

end of thread, other threads:[~2025-05-26 13:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-23 14:28 [PATCH v2] media: uvcvideo: Populate all errors in uvc_probe() Ricardo Ribalda
2025-05-26 13:15 ` Laurent Pinchart
2025-05-26 13:21 ` Hans de Goede
2025-05-26 13:32   ` Laurent Pinchart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).