Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3475426pxu; Tue, 15 Dec 2020 07:53:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJwn3Ry3lrIbtsLDWD4sTYo5DBwcH2SKFne+Hdzc38RjrpGCMpbuUmz091ZRB9lzJIrsIPhM X-Received: by 2002:a17:907:3312:: with SMTP id ym18mr27862319ejb.437.1608047629211; Tue, 15 Dec 2020 07:53:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608047629; cv=none; d=google.com; s=arc-20160816; b=dnEOAoDlqs+MGaL8muBXW0ep6m2ETTHfOxZYaw/ALw38d8mlEKZg8pUqzrjgdRUanK MDiivWn8CkAyxziDx4/Urxy8TiAJYy1TBRQB0F+vZLtODPFyakNWK7jdb1PeIwUh/nBq CJtqF47T/86DgUaeFxgrngOXhQjZYuy1HFVrfAmSvCh/vtlvyHq47/otpcqnexkOoNmk 3/kaeYB1VezZQGbZXe+fXIO2Q/4YKhnPe52LvuRxo3xtIVsbluqqw68uaGjfcOcUedLH 4xm0b4GLq7tkaHQdlezWqSBk/yso6kZ9AuykmpuS5fxB8qwCbFmbJLl2/zqWAfN6BgWl m76Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=63nxgYmH5gNYWgh3y0hSo7/YhWwFqacfn0tO/krx40o=; b=J28HDYwgum+C3pXYO0tDfxqrFQGS53nW0t3l2vTzXUUgWD0w7TOp0F7061VaLtBJuv BtIYTQ75DPenOkBF2ghSF9WEhNIOuq2PsAAkUkLOePVZUMPNtq9qUwMLFVBZDn7ylCHI F87s2ukxRvznkaMc+dAEvJiQ5MZdBzXByOkUjRnCO3h7ZkCqNilbXxUoGIV9JAGe5kxD h5gx1hWPAEK7K+jYuUyMwRhU3Pk1KCPhPSpRkW7JYNr12aDuAisgqhcXnGmsFbrFgwcc sRaVN14wfHWNpELztdDet9hMmS8+UNnDEVevMf8BfNR/j16YW1u/GRVT8eMD0XrPlm/c ne6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=R2iyY0tS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t10si1030764eju.346.2020.12.15.07.53.25; Tue, 15 Dec 2020 07:53:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=R2iyY0tS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729895AbgLOPt3 (ORCPT + 99 others); Tue, 15 Dec 2020 10:49:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730409AbgLOPqg (ORCPT ); Tue, 15 Dec 2020 10:46:36 -0500 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BF2FC0611D0 for ; Tue, 15 Dec 2020 07:45:01 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id y17so20297282wrr.10 for ; Tue, 15 Dec 2020 07:45:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=63nxgYmH5gNYWgh3y0hSo7/YhWwFqacfn0tO/krx40o=; b=R2iyY0tSO+ucOJL+odjs3LhG5Utb453x/7zPUGjRuUwm/8DkCQ0ugssdtasdt24Je/ u+UQKBkEvwVIPJRunHp3AQ59RUOOFORPoOw6x7lgxZCsq+IXpfpOnZvfZi6JPc52D+oL by4vXbIac0b6AzY7i0ilxc3Qh//6SUFg9pxV0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=63nxgYmH5gNYWgh3y0hSo7/YhWwFqacfn0tO/krx40o=; b=dFwXTrHbDZod+YtfTi7c5rPyqgwd3XuHT3EYR96fnoBtJOoidEEwCF0IDKFl3xbZfx 4VvWQ5HM+0lII9Rxi+x9fgY++XDa4DZDiN+ZUPhs4m4d0p2jda0ikjweBetae2pUjFkK z85DE5VJKGimjhpeXS6dS22B7wigrdUJZDQxE71ytvaLttCG/2lQMjoR2/DISp8AcLHI /yawnO/aPu0b5RBRWbMx0MT+ejk9/MENlGywn7VYSyenM8k+EsVwzbHw0EvAxfguxNeh 0YXCRWkqI9bu0/iHwEl94/RZ8G/tST49//vpdm+qK2HEYwtRFeZvL3mWn7XtBSiG1va2 FZOQ== X-Gm-Message-State: AOAM531BvdZHuDFrKw6BV1IpCX6R/pGJVd9ksTYCSONkdUOEbCTSap32 Aj20WxJY4uw1gnEVTUZpcX0a1w== X-Received: by 2002:adf:ef8b:: with SMTP id d11mr6871654wro.156.1608047099963; Tue, 15 Dec 2020 07:44:59 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id 125sm38204141wmc.27.2020.12.15.07.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 07:44:59 -0800 (PST) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda , Joe Perches Subject: [PATCH v4 8/9] media: uvcvideo: New macro uvc_trace_cont Date: Tue, 15 Dec 2020 16:44:38 +0100 Message-Id: <20201215154439.69062-9-ribalda@chromium.org> X-Mailer: git-send-email 2.29.2.684.gfbc64c5ab5-goog In-Reply-To: <20201215154439.69062-1-ribalda@chromium.org> References: <20201215154439.69062-1-ribalda@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove all the duplicated code around pr_cont with a new macro. Suggested-by: Joe Perches Signed-off-by: Ricardo Ribalda --- 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)) \ -- 2.29.2.684.gfbc64c5ab5-goog