From patchwork Mon Jan 4 07:02:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1421998 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=iLYxymkZ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D8RRp5zZ6z9sVR for ; Mon, 4 Jan 2021 18:03:31 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DFFC482647; Mon, 4 Jan 2021 08:03:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="iLYxymkZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8BC338262D; Mon, 4 Jan 2021 08:03:15 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A805980829 for ; Mon, 4 Jan 2021 08:03:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1609743789; bh=0bpsc16wXuXgqNL4b0IxG0OXz1k2L9GSjUvK/GdLgI0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=iLYxymkZEcTdcgNdT1cF2YWeV2mFjaRz3Q5L1S+gnQtoKvYDGkaqwD+sTP8CcHLdJ tAq+I5kVQRGensGKIXMim9ZJyC+0N06QhiBvF4Y5gTm2MnKN6I0p8BWgWmceW0RsXs 5ZgU3eScgi5L8NLHI+CV73FZCE70GQUMt31Ju6Y4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([62.143.246.89]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1Mf078-1kKD7n2n7q-00galS; Mon, 04 Jan 2021 08:03:09 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Lokesh Vutla , Bin Meng , Vignesh Raghavendra , Grygorii Strashko , Sean Anderson , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH 4/5] log: convert pr_*() to logging Date: Mon, 4 Jan 2021 08:02:55 +0100 Message-Id: <20210104070256.260002-5-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210104070256.260002-1-xypron.glpk@gmx.de> References: <20210104070256.260002-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:NRsrl5zAHFqTnSlQO0IPXBYk6ehUUYNJzVdU4o8aBrm7/vwDq6t vmqFj/+rs2FFx97S3ZsPW3ZYjfbhbb6htI9OlQLiYJufbSbYzD7txhDmSthL7jmcjKx5f+n czpkx/A6a/XhmqupeoedUo+HULsn1/kdAwIau633aANU9gYfQqtwBYPmH3ZNoCD/4toiTbD RdVs1E0wtnVmuk5Y5YmMw== X-UI-Out-Filterresults: notjunk:1;V03:K0:J+wq07ruDcU=:jaKmEW+HkNf5dSatayFzoe lzholeFgAcSCa+yPBpgHcmQFrFYsitIMRa2EGWS47uoQpHL3CyqM1i35gldS+67XiDJT+rxOr 9+L+ZNB7p5vhcGUUHqqMdCt89qaiZWJnS7wxL3nbmaS6FsTIHeVsOiZxhGqYArbgfOpmeCcdv YgKHX877GH4FeV4brfqo2Gxg9M18StPhy/HkRp5F4nsnQw9mhKSKxnr8GcPh24xyMJBVPuBcg MtTclJ6vMRz7YOEQoVcF5MdMlwvVIi7Yy6nSkva9+lRK5cNb5j/dNf3FpVTr+v3FGUIEEUAlI HSuom3WLMq/6aXYvzmKrr6G0AsRFJTEJ5YYBFCrFztBzwI4HiNU2Yh6JPVNl2Xm8lTTM0EHeQ usj2BIQarOCLhc1sSss9hQECsnV9Vg2cyffhqAxqG0JWizZiEq9AWlozUfgAITITm5sPmRN7X bgPgaIfOtDoKxQY4HS8w7OtPTyWdXG7NA/iXjqfIfyAfaIJ+fYYCtGAHKh3HQOnI/Ek8GpOTU WxbKKA3wwBBFPAzOA8M29+urVpepEieMDmpAcN8EnjSasZVruN0KF1r86TP696vhL8HMLQ6oU N4ipzXC/g7vAbIkVPN8pvIM/LRLEyvJ2W7r/SLWf80oCr2GNbitU+oPQc8pxTKKqLp9rm6Lb5 ZzXUy4ZXp0CuqmxHHkEwpr68dU2rpoPFAy2PgBkYfOa2b9pHGr/0Zl9Cicz59eGR7NbTXY8RN rbBMUlB9RBqKId3rQPiTWr5ypFdplQX7NnFxWVxkjf46uEUsEiWqijap5cpBw692Nb3OC4a5L S5czyP5pHpdlUjPOE6YP9dce8GiE4i69GVhdzrrB6d0bD3BEBwKzAyjkzJE70BgrzQ5ADTghd uFH6KqnePrrbxSyuxR9w== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean In drivers we use a family of printing functions including pr_err() and pr_cont(). CONFIG_LOGLEVEL is used to control which of these lead to output via printf(). Our logging functions allow finer grained control of output. So replace printf() by the matching logging functions. The usage of CONFIG_LOGLEVEL remains unchanged. Signed-off-by: Heinrich Schuchardt --- include/linux/bitops.h | 4 ++- include/linux/printk.h | 82 +++++++++++++++++++++++------------------- 2 files changed, 48 insertions(+), 38 deletions(-) -- 2.29.2 diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 16f28993f5..d2e5ca026e 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -6,7 +6,6 @@ #include #include #include -#include #ifdef __KERNEL__ #define BIT(nr) (1UL << (nr)) @@ -19,6 +18,9 @@ #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) #endif +/* kernel.h includes log.h which include bitops.h */ +#include + /* * Create a contiguous bitmask starting at bit position @l and ending at * position @h. For example diff --git a/include/linux/printk.h b/include/linux/printk.h index 088513ad29..5e85513853 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -1,6 +1,7 @@ #ifndef __KERNEL_PRINTK__ #define __KERNEL_PRINTK__ +#include #include #include @@ -28,49 +29,56 @@ 0; \ }) -#define __printk(level, fmt, ...) \ -({ \ - level < CONFIG_LOGLEVEL ? printk(fmt, ##__VA_ARGS__) : 0; \ -}) - #ifndef pr_fmt #define pr_fmt(fmt) fmt #endif -#define pr_emerg(fmt, ...) \ - __printk(0, pr_fmt(fmt), ##__VA_ARGS__) -#define pr_alert(fmt, ...) \ - __printk(1, pr_fmt(fmt), ##__VA_ARGS__) -#define pr_crit(fmt, ...) \ - __printk(2, pr_fmt(fmt), ##__VA_ARGS__) -#define pr_err(fmt, ...) \ - __printk(3, pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warning(fmt, ...) \ - __printk(4, pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warn pr_warning -#define pr_notice(fmt, ...) \ - __printk(5, pr_fmt(fmt), ##__VA_ARGS__) -#define pr_info(fmt, ...) \ - __printk(6, pr_fmt(fmt), ##__VA_ARGS__) - -#define pr_cont(fmt, ...) \ - printk(fmt, ##__VA_ARGS__) - -/* pr_devel() should produce zero code unless DEBUG is defined */ -#ifdef DEBUG -#define pr_devel(fmt, ...) \ - __printk(7, pr_fmt(fmt), ##__VA_ARGS__) -#else -#define pr_devel(fmt, ...) \ - no_printk(pr_fmt(fmt), ##__VA_ARGS__) -#endif +#define pr_emerg(fmt, ...) \ +({ \ + CONFIG_LOGLEVEL > 0 ? log_emerg(fmt, ##__VA_ARGS__) : 0; \ +}) +#define pr_alert(fmt, ...) \ +({ \ + CONFIG_LOGLEVEL > 1 ? log_alert(fmt, ##__VA_ARGS__) : 0; \ +}) +#define pr_crit(fmt, ...) \ +({ \ + CONFIG_LOGLEVEL > 2 ? log_crit(fmt, ##__VA_ARGS__) : 0; \ +}) +#define pr_err(fmt, ...) \ +({ \ + CONFIG_LOGLEVEL > 3 ? log_err(fmt, ##__VA_ARGS__) : 0; \ +}) +#define pr_warn(fmt, ...) \ +({ \ + CONFIG_LOGLEVEL > 4 ? log_warning(fmt, ##__VA_ARGS__) : 0; \ +}) +#define pr_notice(fmt, ...) \ +({ \ + CONFIG_LOGLEVEL > 5 ? log_notice(fmt, ##__VA_ARGS__) : 0; \ +}) +#define pr_info(fmt, ...) \ +({ \ + CONFIG_LOGLEVEL > 6 ? log_info(fmt, ##__VA_ARGS__) : 0; \ +}) +#define pr_debug(fmt, ...) \ +({ \ + CONFIG_LOGLEVEL > 7 ? log_debug(fmt, ##__VA_ARGS__) : 0; \ +}) +#define pr_devel(fmt, ...) \ +({ \ + CONFIG_LOGLEVEL > 7 ? log_debug(fmt, ##__VA_ARGS__) : 0; \ +}) -#ifdef DEBUG -#define pr_debug(fmt, ...) \ - __printk(7, pr_fmt(fmt), ##__VA_ARGS__) +#ifdef CONFIG_LOG +#define pr_cont(fmt, ...) \ +({ \ + gd->logl_prev < CONFIG_LOGLEVEL ? \ + log_cont(fmt, ##__VA_ARGS__) : 0; \ +}) #else -#define pr_debug(fmt, ...) \ - no_printk(pr_fmt(fmt), ##__VA_ARGS__) +#define pr_cont(fmt, ...) \ + printk(fmt, ##__VA_ARGS__) #endif #define printk_once(fmt, ...) \