mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Ricardo Ribalda <ribalda@chromium.org>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Joe Perches <joe@perches.com>
Subject: Re: [PATCH v4 8/9] media: uvcvideo: New macro uvc_trace_cont
Date: Sun, 20 Dec 2020 19:13:15 +0200	[thread overview]
Message-ID: <X9+GK3/BY60kwxoX@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20201215154439.69062-9-ribalda@chromium.org>

Hi Ricardo,

Thank you for the patch.

On Tue, Dec 15, 2020 at 04:44:38PM +0100, Ricardo Ribalda wrote:
> Remove all the duplicated code around pr_cont with a new macro.
> 
> Suggested-by: Joe Perches <joe@perches.com>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>

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

> ---
>  drivers/media/usb/uvc/uvc_driver.c | 57 +++++++++++-------------------
>  drivers/media/usb/uvc/uvcvideo.h   |  6 ++++
>  2 files changed, 27 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
> index 4379916a6ac1..e49491250e87 100644
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -1593,8 +1593,7 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
>  {
>  	switch (UVC_ENTITY_TYPE(entity)) {
>  	case UVC_VC_EXTENSION_UNIT:
> -		if (uvc_trace_param & UVC_TRACE_PROBE)
> -			pr_cont(" <- XU %d", entity->id);
> +		uvc_trace_cont(UVC_TRACE_PROBE, " <- XU %d", entity->id);
>  
>  		if (entity->bNrInPins != 1) {
>  			uvc_trace(UVC_TRACE_DESCR, "Extension unit %d has more "
> @@ -1605,8 +1604,7 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
>  		break;
>  
>  	case UVC_VC_PROCESSING_UNIT:
> -		if (uvc_trace_param & UVC_TRACE_PROBE)
> -			pr_cont(" <- PU %d", entity->id);
> +		uvc_trace_cont(UVC_TRACE_PROBE, " <- PU %d", entity->id);
>  
>  		if (chain->processing != NULL) {
>  			uvc_trace(UVC_TRACE_DESCR, "Found multiple "
> @@ -1618,8 +1616,7 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
>  		break;
>  
>  	case UVC_VC_SELECTOR_UNIT:
> -		if (uvc_trace_param & UVC_TRACE_PROBE)
> -			pr_cont(" <- SU %d", entity->id);
> +		uvc_trace_cont(UVC_TRACE_PROBE, " <- SU %d", entity->id);
>  
>  		/* Single-input selector units are ignored. */
>  		if (entity->bNrInPins == 1)
> @@ -1637,27 +1634,22 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
>  	case UVC_ITT_VENDOR_SPECIFIC:
>  	case UVC_ITT_CAMERA:
>  	case UVC_ITT_MEDIA_TRANSPORT_INPUT:
> -		if (uvc_trace_param & UVC_TRACE_PROBE)
> -			pr_cont(" <- IT %d\n", entity->id);
> +		uvc_trace_cont(UVC_TRACE_PROBE, " <- IT %d\n", entity->id);
>  
>  		break;
>  
>  	case UVC_OTT_VENDOR_SPECIFIC:
>  	case UVC_OTT_DISPLAY:
>  	case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
> -		if (uvc_trace_param & UVC_TRACE_PROBE)
> -			pr_cont(" OT %d", entity->id);
> +		uvc_trace_cont(UVC_TRACE_PROBE, " OT %d", entity->id);
>  
>  		break;
>  
>  	case UVC_TT_STREAMING:
> -		if (UVC_ENTITY_IS_ITERM(entity)) {
> -			if (uvc_trace_param & UVC_TRACE_PROBE)
> -				pr_cont(" <- IT %d\n", entity->id);
> -		} else {
> -			if (uvc_trace_param & UVC_TRACE_PROBE)
> -				pr_cont(" OT %d", entity->id);
> -		}
> +		if (UVC_ENTITY_IS_ITERM(entity))
> +			uvc_trace_cont(UVC_TRACE_PROBE, " <- IT %d\n", entity->id);
> +		else
> +			uvc_trace_cont(UVC_TRACE_PROBE, " OT %d", entity->id);
>  
>  		break;
>  
> @@ -1704,13 +1696,11 @@ static int uvc_scan_chain_forward(struct uvc_video_chain *chain,
>  			}
>  
>  			list_add_tail(&forward->chain, &chain->entities);
> -			if (uvc_trace_param & UVC_TRACE_PROBE) {
> -				if (!found)
> -					pr_cont(" (->");
> +			if (!found)
> +				uvc_trace_cont(UVC_TRACE_PROBE, " (->");
>  
> -				pr_cont(" XU %d", forward->id);
> -				found = 1;
> -			}
> +			uvc_trace_cont(UVC_TRACE_PROBE, " XU %d", forward->id);
> +			found = 1;
>  			break;
>  
>  		case UVC_OTT_VENDOR_SPECIFIC:
> @@ -1724,18 +1714,16 @@ static int uvc_scan_chain_forward(struct uvc_video_chain *chain,
>  			}
>  
>  			list_add_tail(&forward->chain, &chain->entities);
> -			if (uvc_trace_param & UVC_TRACE_PROBE) {
> -				if (!found)
> -					pr_cont(" (->");
> +			if (!found)
> +				uvc_trace_cont(UVC_TRACE_PROBE, " (->");
>  
> -				pr_cont(" OT %d", forward->id);
> -				found = 1;
> -			}
> +			uvc_trace_cont(UVC_TRACE_PROBE, " OT %d", forward->id);
> +			found = 1;
>  			break;
>  		}
>  	}
>  	if (found)
> -		pr_cont(")");
> +		uvc_trace_cont(UVC_TRACE_PROBE, ")");
>  
>  	return 0;
>  }
> @@ -1760,8 +1748,7 @@ static int uvc_scan_chain_backward(struct uvc_video_chain *chain,
>  			break;
>  		}
>  
> -		if (uvc_trace_param & UVC_TRACE_PROBE)
> -			pr_cont(" <- IT");
> +		uvc_trace_cont(UVC_TRACE_PROBE, " <- IT");
>  
>  		chain->selector = entity;
>  		for (i = 0; i < entity->bNrInPins; ++i) {
> @@ -1781,15 +1768,13 @@ static int uvc_scan_chain_backward(struct uvc_video_chain *chain,
>  				return -EINVAL;
>  			}
>  
> -			if (uvc_trace_param & UVC_TRACE_PROBE)
> -				pr_cont(" %d", term->id);
> +			uvc_trace_cont(UVC_TRACE_PROBE, " %d", term->id);
>  
>  			list_add_tail(&term->chain, &chain->entities);
>  			uvc_scan_chain_forward(chain, term, entity);
>  		}
>  
> -		if (uvc_trace_param & UVC_TRACE_PROBE)
> -			pr_cont("\n");
> +		uvc_trace_cont(UVC_TRACE_PROBE, "\n");
>  
>  		id = 0;
>  		break;
> diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
> index d8e2f27bf576..2b5ba4b02d3a 100644
> --- a/drivers/media/usb/uvc/uvcvideo.h
> +++ b/drivers/media/usb/uvc/uvcvideo.h
> @@ -748,6 +748,12 @@ do {									\
>  		printk(KERN_DEBUG "uvcvideo: " fmt, ##__VA_ARGS__);	\
>  } while (0)
>  
> +#define uvc_trace_cont(flag, fmt, ...)					\
> +do {									\
> +	if (uvc_trace_param & flag)					\
> +		pr_cont(fmt, ##__VA_ARGS__);				\
> +} while (0)
> +
>  #define uvc_warn_once(_dev, warn, fmt, ...)				\
>  do {									\
>  	if (!test_and_set_bit(warn, &(_dev)->warnings))			\

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2020-12-20 17:14 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-15 15:44 [PATCH v4 0/9] Show privacy_gpio as a v4l2_ctrl Ricardo Ribalda
2020-12-15 15:44 ` [PATCH v4 1/9] media: uvcvideo: Move guid to entity Ricardo Ribalda
2020-12-20 16:05   ` Laurent Pinchart
2020-12-15 15:44 ` [PATCH v4 2/9] media: uvcvideo: Allow external entities Ricardo Ribalda
2020-12-20 16:53   ` Laurent Pinchart
2020-12-15 15:44 ` [PATCH v4 3/9] media: uvcvideo: Allow entities with no pads Ricardo Ribalda
2020-12-20 16:08   ` Laurent Pinchart
2020-12-15 15:44 ` [PATCH v4 4/9] media: uvcvideo: Entity defined get_info and get_cur Ricardo Ribalda
2020-12-20 16:15   ` Laurent Pinchart
2020-12-15 15:44 ` [PATCH v4 5/9] media: uvcvideo: Implement UVC_EXT_GPIO_UNIT Ricardo Ribalda
2020-12-20 16:49   ` Laurent Pinchart
2020-12-20 22:56     ` Ricardo Ribalda
2020-12-20 23:24       ` Laurent Pinchart
2020-12-21  0:30         ` Ricardo Ribalda
2020-12-15 15:44 ` [PATCH v4 6/9] media: uvcvideo: Add Privacy control based on EXT_GPIO Ricardo Ribalda
2020-12-20 16:55   ` Laurent Pinchart
2020-12-15 15:44 ` [PATCH v4 7/9] media: uvcvideo: Use dev_ printk aliases Ricardo Ribalda
2020-12-20 17:11   ` Laurent Pinchart
2020-12-15 15:44 ` [PATCH v4 8/9] media: uvcvideo: New macro uvc_trace_cont Ricardo Ribalda
2020-12-20 17:13   ` Laurent Pinchart [this message]
2020-12-15 15:44 ` [PATCH v4 9/9] media: uvcvideo: Implement UVC_QUIRK_PRIVACY_DURING_STREAM Ricardo Ribalda
2020-12-20 17:21   ` Laurent Pinchart
2020-12-21  1:10     ` Ricardo Ribalda
2020-12-21  2:08       ` Laurent Pinchart
2020-12-21  2:12         ` Ricardo Ribalda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=X9+GK3/BY60kwxoX@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=ribalda@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®