Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp787007pxb; Thu, 19 Nov 2020 13:53:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJztkmuCHjllH1qqEYX3wNm8qBHy+bCaVZQggMBwoaVdaXxssZMxjsW3mPJbkMEbPk/VvqNZ X-Received: by 2002:a17:906:d8ab:: with SMTP id qc11mr2163514ejb.64.1605822808609; Thu, 19 Nov 2020 13:53:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605822808; cv=none; d=google.com; s=arc-20160816; b=MQYfqxhilwVhvQvjumnKtOt4lH/cC9zKRwnTxDpOOLohdskb34kxQLgtTMkpWiQeIW Ty31T/OOmwNSWx2cWJSVDqSSVDA7R56avz2bW0BgZIl/8A4kW6UH5xNhSnBk3NqaKs0+ 5RMeeQ7VLQYFwXusXzVWwpBsOLT2B9gp4WmMkkYNiLIYhu+C2/vyeB0oKQ1jd57trCHp W2jaj9/23pYNGAz78+ce9Qt8hmTZLoQ3xiF2OIyIZLsvlXg77wuaK7g5CDax6V+L51BA JWWeKrDidM/4EnTI2n0gSpw3ZIpEWYDnyZUwXDHVJmnaIEISpbaKSjUhP2ebgWkCndvb 6o8Q== 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=M4UWJdzxGjZ3FRbN2p0hSo/ueaYeOwZVoPX3ogUn9Jg=; b=sjoLSICXkgIbz5cBzGv65P1XLVAZEfdeRahJJN/6OufifIqjLC232f9/MM4NWchR+R De9Y+CoZ3oa34GMWU8AQEZcaXU7l/PtY6wo25Zrxt598O0mwA/z6Krcm+pNjaDXt23ei KaYwE/psPcJNestQcN/PAxc58xUDh9TeN1RQLnEzZiZWkpEBV15FhMsNFItzamkYHbxI hn7ts8qBXl+M9+KiHZrEwTPMDe02DeFZD/Xn8loqtwCI44sGfRotBjDbPYhm4Wc0uCYK i+W2l3zFKgckpen8M3Q9akdqNS6bBSnJe7Yj8RsFbNTUksuJ+UL2iSSJMlPTMd+ii71F FQAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iXVkGHnI; 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 x19si636582edi.214.2020.11.19.13.53.05; Thu, 19 Nov 2020 13:53:28 -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=iXVkGHnI; 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 S1726567AbgKSVuf (ORCPT + 99 others); Thu, 19 Nov 2020 16:50:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726698AbgKSVuf (ORCPT ); Thu, 19 Nov 2020 16:50:35 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65948C061A4A for ; Thu, 19 Nov 2020 13:50:33 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id 1so8066419wme.3 for ; Thu, 19 Nov 2020 13:50:33 -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=M4UWJdzxGjZ3FRbN2p0hSo/ueaYeOwZVoPX3ogUn9Jg=; b=iXVkGHnII8i3RzXJ8Aaig2z/iMI4UYTlhuf9rzpqG06q/VB3iMLKUvvBYaYJohyOvI B6UphpbRnEqKer7Lz1BQqEppKfaEOYzzCgn40jfqbB83lFJRwMddR67x1ACMcXs9gBMk ElVftK0vZhOdtIHLsO4L2F/yiIYX5NhQu7uyo= 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=M4UWJdzxGjZ3FRbN2p0hSo/ueaYeOwZVoPX3ogUn9Jg=; b=OcjfWQ5WEgcd2b7JF4S54P9Q3D8y87B6HaIZwJpXkxQhr5ts0WcB1yXzliAAp1sk0X eGGBEhIV7hP7UlOBFVkybfxF2VEsu6wgM0D7pEm5ot6Qw1tg/d5OUujfXJZUTC1JLE0i vrXYyCrpth+Q1cZF+q5+Sbk2mx8ZkPkndOH0mkAi0ShqgOkJ2HtO5XKUIshUFegRcvkM azLFoL4BLddi225Ekfk/McR9ztuUHyZMVGL/7lkFiLnhK9+WGXPbNy8IgtkGERPIlHqN 3LEk28xjsrdFww3Bq1Jvw9I8BHjt9ZILgDLna88tEVsgazWP74udYkfzXylAql3CFpIj uruA== X-Gm-Message-State: AOAM531C2LtNgCECO7l1fuq9aOgXAslveDfksZMJ2iPy4oruBv2cRAfC LzcBnkp/gGIl3JaKVd0PPFk8Dw== X-Received: by 2002:a1c:1982:: with SMTP id 124mr6474217wmz.74.1605822632113; Thu, 19 Nov 2020 13:50:32 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id t136sm1818859wmt.18.2020.11.19.13.50.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 13:50:31 -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 v3 8/8] media: uvcvideo: New macro uvc_trace_cont Date: Thu, 19 Nov 2020 22:50:20 +0100 Message-Id: <20201119215020.508487-9-ribalda@chromium.org> X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog In-Reply-To: <20201119215020.508487-1-ribalda@chromium.org> References: <20201119215020.508487-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.299.gdc1121823c-goog