[v3,2/8] media: uvcvideo: improve error logging in uvc_query_ctrl()

Message ID 20220920-resend-v4l2-compliance-v3-2-598d33a15815@chromium.org
State New
Headers
Series Follow-up patches for uvc v4l2-compliance |

Commit Message

Ricardo Ribalda Jan. 3, 2023, 2:36 p.m. UTC
  From: Hans Verkuil <hverkuil-cisco@xs4all.nl>

Standard use of the driver may result in error messages on the kernel
ring buffer. This can hide other more important messages, and alert
unnecessarily the user. Let's keep dev_err() for the important
occasions.

If __uvc_query_ctrl() failed with a non -EPIPE error, then report that
with dev_err. If an error code is obtained, then report that with
dev_dbg.

Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/uvc/uvc_video.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
  

Comments

Laurent Pinchart Jan. 3, 2023, 8:13 p.m. UTC | #1
Hi Ricardo,

Thank you for the patch.

On Tue, Jan 03, 2023 at 03:36:20PM +0100, Ricardo Ribalda wrote:
> From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> 
> Standard use of the driver may result in error messages on the kernel
> ring buffer. This can hide other more important messages, and alert

I assume you meant log (or log buffer), not ring buffer. I'll fix that
when applying.

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

> unnecessarily the user. Let's keep dev_err() for the important
> occasions.
> 
> If __uvc_query_ctrl() failed with a non -EPIPE error, then report that
> with dev_err. If an error code is obtained, then report that with
> dev_dbg.
> 
> Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/uvc/uvc_video.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index d2eb9066e4dc..6b20a23bc3cf 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -79,13 +79,14 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
>  	if (likely(ret == size))
>  		return 0;
>  
> -	dev_err(&dev->udev->dev,
> -		"Failed to query (%s) UVC control %u on unit %u: %d (exp. %u).\n",
> -		uvc_query_name(query), cs, unit, ret, size);
> -
> -	if (ret != -EPIPE)
> +	if (ret != -EPIPE) {
> +		dev_err(&dev->udev->dev,
> +			"Failed to query (%s) UVC control %u on unit %u: %d (exp. %u).\n",
> +			uvc_query_name(query), cs, unit, ret, size);
>  		return ret;
> +	}
>  
> +	/* Reuse data[0] to request the error code. */
>  	tmp = *(u8 *)data;
>  
>  	ret = __uvc_query_ctrl(dev, UVC_GET_CUR, 0, intfnum,
  
Ricardo Ribalda Jan. 3, 2023, 8:15 p.m. UTC | #2
Hi Laurent

On Tue, 3 Jan 2023 at 21:13, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Hi Ricardo,
>
> Thank you for the patch.
>
> On Tue, Jan 03, 2023 at 03:36:20PM +0100, Ricardo Ribalda wrote:
> > From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> >
> > Standard use of the driver may result in error messages on the kernel
> > ring buffer. This can hide other more important messages, and alert
>
> I assume you meant log (or log buffer), not ring buffer. I'll fix that
> when applying.

I tried to use the best term. And I found this:
https://man7.org/linux/man-pages/man1/dmesg.1.html

seems that kernel ring buffer is the correct term (but I might confess
that I use dmesg or simply log)

In this case, anything works for me ;)

Thanks!

>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> > unnecessarily the user. Let's keep dev_err() for the important
> > occasions.
> >
> > If __uvc_query_ctrl() failed with a non -EPIPE error, then report that
> > with dev_err. If an error code is obtained, then report that with
> > dev_dbg.
> >
> > Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
> > Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> > ---
> >  drivers/media/usb/uvc/uvc_video.c | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> > index d2eb9066e4dc..6b20a23bc3cf 100644
> > --- a/drivers/media/usb/uvc/uvc_video.c
> > +++ b/drivers/media/usb/uvc/uvc_video.c
> > @@ -79,13 +79,14 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
> >       if (likely(ret == size))
> >               return 0;
> >
> > -     dev_err(&dev->udev->dev,
> > -             "Failed to query (%s) UVC control %u on unit %u: %d (exp. %u).\n",
> > -             uvc_query_name(query), cs, unit, ret, size);
> > -
> > -     if (ret != -EPIPE)
> > +     if (ret != -EPIPE) {
> > +             dev_err(&dev->udev->dev,
> > +                     "Failed to query (%s) UVC control %u on unit %u: %d (exp. %u).\n",
> > +                     uvc_query_name(query), cs, unit, ret, size);
> >               return ret;
> > +     }
> >
> > +     /* Reuse data[0] to request the error code. */
> >       tmp = *(u8 *)data;
> >
> >       ret = __uvc_query_ctrl(dev, UVC_GET_CUR, 0, intfnum,
>
> --
> Regards,
>
> Laurent Pinchart
  
Laurent Pinchart Jan. 12, 2023, 10:21 p.m. UTC | #3
Hi Hans,

On Tue, Jan 03, 2023 at 03:36:20PM +0100, Ricardo Ribalda wrote:
> From: Hans Verkuil <hverkuil-cisco@xs4all.nl>

There's also a mismatch here between From and Signed-off-by.

> Standard use of the driver may result in error messages on the kernel
> ring buffer. This can hide other more important messages, and alert
> unnecessarily the user. Let's keep dev_err() for the important
> occasions.
> 
> If __uvc_query_ctrl() failed with a non -EPIPE error, then report that
> with dev_err. If an error code is obtained, then report that with
> dev_dbg.
> 
> Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/uvc/uvc_video.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index d2eb9066e4dc..6b20a23bc3cf 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -79,13 +79,14 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
>  	if (likely(ret == size))
>  		return 0;
>  
> -	dev_err(&dev->udev->dev,
> -		"Failed to query (%s) UVC control %u on unit %u: %d (exp. %u).\n",
> -		uvc_query_name(query), cs, unit, ret, size);
> -
> -	if (ret != -EPIPE)
> +	if (ret != -EPIPE) {
> +		dev_err(&dev->udev->dev,
> +			"Failed to query (%s) UVC control %u on unit %u: %d (exp. %u).\n",
> +			uvc_query_name(query), cs, unit, ret, size);
>  		return ret;
> +	}
>  
> +	/* Reuse data[0] to request the error code. */
>  	tmp = *(u8 *)data;
>  
>  	ret = __uvc_query_ctrl(dev, UVC_GET_CUR, 0, intfnum,
>
  

Patch

diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index d2eb9066e4dc..6b20a23bc3cf 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -79,13 +79,14 @@  int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
 	if (likely(ret == size))
 		return 0;
 
-	dev_err(&dev->udev->dev,
-		"Failed to query (%s) UVC control %u on unit %u: %d (exp. %u).\n",
-		uvc_query_name(query), cs, unit, ret, size);
-
-	if (ret != -EPIPE)
+	if (ret != -EPIPE) {
+		dev_err(&dev->udev->dev,
+			"Failed to query (%s) UVC control %u on unit %u: %d (exp. %u).\n",
+			uvc_query_name(query), cs, unit, ret, size);
 		return ret;
+	}
 
+	/* Reuse data[0] to request the error code. */
 	tmp = *(u8 *)data;
 
 	ret = __uvc_query_ctrl(dev, UVC_GET_CUR, 0, intfnum,