Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5788610pxu; Wed, 23 Dec 2020 05:39:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJzNwqcEr/jc3yMj9Q2y/+aFp5Ast2IQL51+FuhGrN6TukSmGHUjL6yM07V5gSL5nP/8hG X-Received: by 2002:a50:c209:: with SMTP id n9mr24650275edf.123.1608730764337; Wed, 23 Dec 2020 05:39:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608730764; cv=none; d=google.com; s=arc-20160816; b=g2QDo5O08ZLRrbiJqdrdCRZkZM/gjvw1K/rhR+ccUQWGW874bxHo0ky/raDwYCRJ0D ABtrifxK9HiCiIgOD256cmpiM1m6WlCJGOcpXkyN5NNazsl3Y4O4UiHCd8cIKNWat12T TikjgLomZf8R6Spjm5hiTmW8rNNAkgjKTgstb+ba7yZFD4kWjIXz2tCl/vboJd/tfSlU BGWY9rhJjKycqAoAyhu2bPHevfdDVXqBPz2qLOJd1e40PfxnTSTwVEF2dKAQbo2vM4YP SNTnTExRO9z/ES8mdiysPzM7y61agUu8kRjU2V03HE/NZc1XqfxCqFGfT87m072zHNbK y1hA== 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=WhLb6YEyHwrOqQmqk1DfxxcKaubqjfT3yk59f4tyNrg=; b=mWWlfSf6iitKo27uLAVegzdehvPllpJOV9yIPd1f2WxUhd32KScQBoyM/wzPtlMHZ/ pCQ5exgXYcfVjjvTcl45YZkRZBPGAeXKWpwuk/8ZYj7w+H4s/3jMmN8oZq8o9c9zxgWW 4zvvaK0cgBMvyZAMQK67N2Vvy24RaZXjGKKL9C+hrReDTzlkgIi2+vl/t24AF9ZMs8VI M5fj1lEpiE+CqCJrqtoASBZwqeq24LUWEZmtmYaGbIeygRKnYO2YRUKUIRxsL4mVc6vK wD5VLLyl7FLe+EYF04s92O8YG06Biq1hG8l5lRK+GjKljm3Jr8+tfDFqrq/HBESy/U4F +Wxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=coviEdr6; 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 n27si12200027ejc.673.2020.12.23.05.39.01; Wed, 23 Dec 2020 05:39:24 -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=coviEdr6; 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 S1728792AbgLWNhJ (ORCPT + 99 others); Wed, 23 Dec 2020 08:37:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728782AbgLWNhI (ORCPT ); Wed, 23 Dec 2020 08:37:08 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 023D4C0611BB for ; Wed, 23 Dec 2020 05:35:39 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id c5so18623281wrp.6 for ; Wed, 23 Dec 2020 05:35:38 -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=WhLb6YEyHwrOqQmqk1DfxxcKaubqjfT3yk59f4tyNrg=; b=coviEdr6k+TMkbLssys3vcXiH0H19eMqKwfZlw0TMmHAg+EarrsY9i9DPIFglr/4Fz vwRyb+++MV1UMbPVXBZpJhTowMs81E/c675nPQCLrbVgXRtXShLLRlRVTU5/EqCqryfy yX/DvAefMhi1E6oQ5ywN/MHDIw3MYc3N5al1I= 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=WhLb6YEyHwrOqQmqk1DfxxcKaubqjfT3yk59f4tyNrg=; b=faHWbOM6DXNkdjVvjMPfCtkpJBzfAHpsfQwegjj0F3TiYQ97ODUdfVlEg9/NJuO3bl 7Ka9Fv8BPwZjIUVMUtYSKg2FmtcKhQwqJpPkFkqQFfmzEg576TYGmED08mQ/zs5h9USX oR89K+kLDoHUpOQf7+4XjKpMtpNT2Ef7VSieh+FyRS2wobZYTXdliFasIEcT/P5pfnI+ q/jmhQRi0fLb2ig9lt+WvnS+47HkCg0OzDC60BYgfG0HbAW1Tap66qR9NY0lNke2cnuf evhGUxWpysSAZrQ/Y3XVCMiIq0SKh/Tbm9J8/z7WQFkWUOlsJfiJtPqaUEZIjLkIi8RC 8U3A== X-Gm-Message-State: AOAM530LMfk5WGnlIF89Dyq/XdXMgwnstTa6m2xDdSr5XZlNqLsCIqVu jpBXVq576Gu9ISDfPJgNJTHYSQ== X-Received: by 2002:a5d:5005:: with SMTP id e5mr28782686wrt.279.1608730537773; Wed, 23 Dec 2020 05:35:37 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id q143sm31572247wme.28.2020.12.23.05.35.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 05:35:37 -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 v7 09/12] media: uvcvideo: New macro uvc_trace_cont Date: Wed, 23 Dec 2020 14:35:25 +0100 Message-Id: <20201223133528.55014-10-ribalda@chromium.org> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog In-Reply-To: <20201223133528.55014-1-ribalda@chromium.org> References: <20201223133528.55014-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 printk(KERN_CONT, with a new macro. Reviewed-by: Laurent Pinchart 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 9ca9fcdb7b3d..b4b47cc35af9 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1606,8 +1606,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) - printk(KERN_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 " @@ -1618,8 +1617,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) - printk(KERN_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 " @@ -1631,8 +1629,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) - printk(KERN_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) @@ -1650,27 +1647,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) - printk(KERN_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) - printk(KERN_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) - printk(KERN_CONT " <- IT %d\n", entity->id); - } else { - if (uvc_trace_param & UVC_TRACE_PROBE) - printk(KERN_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; @@ -1717,13 +1709,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) - printk(KERN_CONT " (->"); + if (!found) + uvc_trace_cont(UVC_TRACE_PROBE, " (->"); - printk(KERN_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: @@ -1737,18 +1727,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) - printk(KERN_CONT " (->"); + if (!found) + uvc_trace_cont(UVC_TRACE_PROBE, " (->"); - printk(KERN_CONT " OT %d", forward->id); - found = 1; - } + uvc_trace_cont(UVC_TRACE_PROBE, " OT %d", forward->id); + found = 1; break; } } if (found) - printk(KERN_CONT ")"); + uvc_trace_cont(UVC_TRACE_PROBE, ")"); return 0; } @@ -1773,8 +1761,7 @@ static int uvc_scan_chain_backward(struct uvc_video_chain *chain, break; } - if (uvc_trace_param & UVC_TRACE_PROBE) - printk(KERN_CONT " <- IT"); + uvc_trace_cont(UVC_TRACE_PROBE, " <- IT"); chain->selector = entity; for (i = 0; i < entity->bNrInPins; ++i) { @@ -1794,15 +1781,13 @@ static int uvc_scan_chain_backward(struct uvc_video_chain *chain, return -EINVAL; } - if (uvc_trace_param & UVC_TRACE_PROBE) - printk(KERN_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) - printk(KERN_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 a8c2766f3d6a..fb01d52eed39 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -757,6 +757,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.729.g45daf8777d-goog