From patchwork Wed Sep 13 11:45:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 112437 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp846758qgf; Wed, 13 Sep 2017 04:45:49 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6/NPceh15vTyOEkcOuSy5hYPJEWdEOrsgM+LSSNiYEdbPazorxBx04a6jvKBNxWHbH2NfI X-Received: by 10.80.210.215 with SMTP id q23mr8353105edg.61.1505303149848; Wed, 13 Sep 2017 04:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505303149; cv=none; d=google.com; s=arc-20160816; b=pShTy4JV4xqE1eMD8mVznBeeoSUJsrVRW29+lpNgURY0dzXUa4IG/Pk9d9Z1m7Yy5L YSycWpj9hjeLpOizQf0/855OvRE1kMyuxeCAd/UXwFXlT3K/y1x4RadGUGMFftNmLAEq QoSOCoPpd3mVSdrj9fTwJkQImz0dsul92iXlPVe89riTp2YZFRxWzkJzo8nddmL1tNXr gVy8bVWZSBlnCCWGTyA4oLbJ6VoWKYvvOa0gZvu3B+IXA/9h9o1amPP/59ID7FvIpWWb Yhsk23XZ+x4MsVGWnPUkRyKbXZd5VeQdwf6VBiveAMHotneZ83A1lqaybpGo4FWXE8ez /mOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=fumvpj1Q9qJrhe5mh/W4Q65CeE02MEGjfDPZqiURzNE=; b=eoFGA3yew6ngI3h79GFq7PN8YXAcvxLy+bahD623XepQ3zhV3y9iEcoNBqC0TD699R BacOsCEv+GrXosghBNyDXgrq3SxLATl8qoFFUF2zpglKN7OLbSDipiTVB7Db4kjQ5R6Z hoOUhrDDE0iEMr1qHuHNIjBNnZ1Zgp6iZetKEXjD9Ro0i0qb5oQycIcyLQ/mVrPNkpuE 8BDyBTImLKG1dLrJLaX48iPtq+BYWh7hgfjsJN+XnUO0T4GNfLpMRy0AVrKX7dsSqDP0 WEi2V4+mlmvtjlb6avequVlyGbazu5DY5Q+Xtl2M6702B2AkA2gzTxtZ9HMFcaeIH14E yR9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=KFaHu8Vy; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id s6si14246997edk.292.2017.09.13.04.45.49; Wed, 13 Sep 2017 04:45:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=KFaHu8Vy; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 085D9C225F8; Wed, 13 Sep 2017 11:45:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 9EB80C220CB; Wed, 13 Sep 2017 11:45:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 937BBC22515; Wed, 13 Sep 2017 11:45:32 +0000 (UTC) Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by lists.denx.de (Postfix) with ESMTPS id 1357CC22527 for ; Wed, 13 Sep 2017 11:45:31 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id v8DBjE4o018351; Wed, 13 Sep 2017 20:45:15 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v8DBjE4o018351 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1505303116; bh=K3gEn0BJiU0mJk70g9E3EiwpwXh2HFdhw5fOJVMChIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KFaHu8VyOgOxdZbdRlA3zxpz7c3QS/x+bAHFutVBiOzX6fNNnc5JtUySXJFtai0nT 0yOeXhEtjwc6Hb2nfNqiY3YUMiCUkA0QrxoLd2szWPl0I3fiydRGcnfU/WqmbgLFGD lR14y/RL9Q60ss4yVZ9/beEtHyhA/bFUhINvFUhziRfhyLK6FZsh4at+oUrvshW5/k ovwJPS7pUlazlSreaWej71p7ZDPNXhditvxBzbC5uznKnC8tqkyTBe3iROZHKu9kkD eE7YUPaF+YQt7Db9FOfPy7HBBQgcwEoyJGWM/eO+apAq4Cv/UFEyLJCaXnCCBn7m1r YWco5rYx5e00g== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Wed, 13 Sep 2017 20:45:01 +0900 Message-Id: <1505303106-9780-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505303106-9780-1-git-send-email-yamada.masahiro@socionext.com> References: <1505303106-9780-1-git-send-email-yamada.masahiro@socionext.com> Cc: Marek Vasut , Albert Aribaud Subject: [U-Boot] [PATCH 1/6] printk: collect printk stuff into X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When we want to print something to the console, we generally include , then use printf() and friends. When we import code from Linux, planning to sync it from time to time, we want to use printk() and pr_*(). U-Boot does not support them in a clean way. So, people end up with local macros, or compat headers here and there, then we occasionally see build errors of definition conflicts. We have some compat macros in include/linux/compat.h, but putting all sorts of unrelated things into a single header looks a bad idea to me. One more thing, simply replaces "printk" pattern with "printf", so it needs included. This header pulls in tons of headers. Putting #include at the beginning of every file is a bad convention. Hence this patch, to move all printk stuff into . If you want to use printk() stuff, just include this header, and that's it. Currently, all printk() and pr_*() behave as printf(), except that pr_debug() is enabled only when DEBUG is defined. Of course, it will be easy to implement "loglevel" concept to differentiate pr_*(), but this kind of clean-up must happen first. Signed-off-by: Masahiro Yamada --- arch/arm/mach-uniphier/dram_init.c | 3 - arch/arm/mach-uniphier/init.h | 5 -- drivers/bios_emulator/include/x86emu/x86emui.h | 3 - drivers/usb/dwc3/linux-compat.h | 1 - drivers/usb/musb-new/linux-compat.h | 2 - include/common.h | 6 +- include/linux/compat.h | 11 ---- include/linux/mtd/mtd.h | 10 +--- include/linux/printk.h | 77 ++++++++++++++++++++++++++ 9 files changed, 79 insertions(+), 39 deletions(-) create mode 100644 include/linux/printk.h diff --git a/arch/arm/mach-uniphier/dram_init.c b/arch/arm/mach-uniphier/dram_init.c index 32d3593..2213685 100644 --- a/arch/arm/mach-uniphier/dram_init.c +++ b/arch/arm/mach-uniphier/dram_init.c @@ -15,9 +15,6 @@ #include "sg-regs.h" #include "soc-info.h" -#define pr_warn(fmt, args...) printf(fmt, ##args) -#define pr_err(fmt, args...) printf(fmt, ##args) - DECLARE_GLOBAL_DATA_PTR; struct uniphier_memif_data { diff --git a/arch/arm/mach-uniphier/init.h b/arch/arm/mach-uniphier/init.h index 29f638d..da20935 100644 --- a/arch/arm/mach-uniphier/init.h +++ b/arch/arm/mach-uniphier/init.h @@ -104,9 +104,4 @@ int uniphier_have_internal_stm(void); int uniphier_boot_from_backend(void); int uniphier_pin_init(const char *pinconfig_name); -#undef pr_warn -#define pr_warn(fmt, args...) printf(fmt, ##args) -#undef pr_err -#define pr_err(fmt, args...) printf(fmt, ##args) - #endif /* __MACH_INIT_H */ diff --git a/drivers/bios_emulator/include/x86emu/x86emui.h b/drivers/bios_emulator/include/x86emu/x86emui.h index a74957d..3537255 100644 --- a/drivers/bios_emulator/include/x86emu/x86emui.h +++ b/drivers/bios_emulator/include/x86emu/x86emui.h @@ -72,9 +72,6 @@ #include #endif -#define printk printf - - /*--------------------------- Inline Functions ----------------------------*/ #ifdef __cplusplus diff --git a/drivers/usb/dwc3/linux-compat.h b/drivers/usb/dwc3/linux-compat.h index 9e944a3..64db4ec 100644 --- a/drivers/usb/dwc3/linux-compat.h +++ b/drivers/usb/dwc3/linux-compat.h @@ -12,7 +12,6 @@ #ifndef __DWC3_LINUX_COMPAT__ #define __DWC3_LINUX_COMPAT__ -#define pr_debug(format) debug(format) #define WARN(val, format, arg...) debug(format, ##arg) #define dev_WARN(dev, format, arg...) debug(format, ##arg) #define WARN_ON_ONCE(val) debug("Error %d\n", val) diff --git a/drivers/usb/musb-new/linux-compat.h b/drivers/usb/musb-new/linux-compat.h index 4dae83e..7bb53d2 100644 --- a/drivers/usb/musb-new/linux-compat.h +++ b/drivers/usb/musb-new/linux-compat.h @@ -5,8 +5,6 @@ #include #include -#define pr_debug(fmt, args...) debug(fmt, ##args) - #define WARN(condition, fmt, args...) ({ \ int ret_warn = !!condition; \ if (ret_warn) \ diff --git a/include/common.h b/include/common.h index aaed131..ae3b876 100644 --- a/include/common.h +++ b/include/common.h @@ -25,6 +25,7 @@ typedef volatile unsigned char vu_char; #include #include #include +#include #include #include #include @@ -54,11 +55,6 @@ typedef volatile unsigned char vu_char; #define _SPL_BUILD 0 #endif -/* Define this at the top of a file to add a prefix to debug messages */ -#ifndef pr_fmt -#define pr_fmt(fmt) fmt -#endif - /* * Output a debug text when condition "cond" is met. The "cond" should be * computed by a preprocessor in the best case, allowing for the best diff --git a/include/linux/compat.h b/include/linux/compat.h index 2336b56..bc027ad 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -25,17 +25,6 @@ extern struct p_current *current; printf(fmt, ##args) #define dev_warn(dev, fmt, args...) \ printf(fmt, ##args) -#define printk printf -#define printk_once printf - -#define KERN_EMERG -#define KERN_ALERT -#define KERN_CRIT -#define KERN_ERR -#define KERN_WARNING -#define KERN_NOTICE -#define KERN_INFO -#define KERN_DEBUG #define GFP_ATOMIC ((gfp_t) 0) #define GFP_KERNEL ((gfp_t) 0) diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 1fd17c3..3e1694b 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -452,28 +452,20 @@ static inline void mtd_erase_callback(struct erase_info *instr) #define MTD_DEBUG_LEVEL3 (3) /* Noisy */ #ifdef CONFIG_MTD_DEBUG -#define pr_debug(args...) MTDDEBUG(MTD_DEBUG_LEVEL0, args) #define MTDDEBUG(n, args...) \ do { \ if (n <= CONFIG_MTD_DEBUG_VERBOSE) \ printk(KERN_INFO args); \ } while(0) #else /* CONFIG_MTD_DEBUG */ -#define pr_debug(args...) #define MTDDEBUG(n, args...) \ do { \ if (0) \ printk(KERN_INFO args); \ } while(0) #endif /* CONFIG_MTD_DEBUG */ -#define pr_info(args...) MTDDEBUG(MTD_DEBUG_LEVEL0, args) -#define pr_warn(args...) MTDDEBUG(MTD_DEBUG_LEVEL0, args) -#define pr_err(args...) MTDDEBUG(MTD_DEBUG_LEVEL0, args) -#define pr_crit(args...) MTDDEBUG(MTD_DEBUG_LEVEL0, args) -#define pr_cont(args...) MTDDEBUG(MTD_DEBUG_LEVEL0, args) -#define pr_notice(args...) MTDDEBUG(MTD_DEBUG_LEVEL0, args) #endif - + static inline int mtd_is_bitflip(int err) { return err == -EUCLEAN; } diff --git a/include/linux/printk.h b/include/linux/printk.h new file mode 100644 index 0000000..3752567 --- /dev/null +++ b/include/linux/printk.h @@ -0,0 +1,77 @@ +#ifndef __KERNEL_PRINTK__ +#define __KERNEL_PRINTK__ + +#include + +#define KERN_EMERG +#define KERN_ALERT +#define KERN_CRIT +#define KERN_ERR +#define KERN_WARNING +#define KERN_NOTICE +#define KERN_INFO +#define KERN_DEBUG +#define KERN_CONT + +__printf(1, 2) int printf(const char *fmt, ...); + +/* + * Dummy printk for disabled debugging statements to use whilst maintaining + * gcc's format checking. + */ +#define no_printk(fmt, ...) \ +({ \ + do { \ + if (0) \ + printk(fmt, ##__VA_ARGS__); \ + } while (0); \ + 0; \ +}) + +#define printk(fmt, ...) \ + printf(fmt, ##__VA_ARGS__) + +#ifndef pr_fmt +#define pr_fmt(fmt) fmt +#endif + +#define pr_emerg(fmt, ...) \ + printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) +#define pr_alert(fmt, ...) \ + printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) +#define pr_crit(fmt, ...) \ + printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) +#define pr_err(fmt, ...) \ + printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) +#define pr_warning(fmt, ...) \ + printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) +#define pr_warn pr_warning +#define pr_notice(fmt, ...) \ + printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) +#define pr_info(fmt, ...) \ + printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) + +#define pr_cont(fmt, ...) \ + printk(KERN_CONT fmt, ##__VA_ARGS__) + +/* pr_devel() should produce zero code unless DEBUG is defined */ +#ifdef DEBUG +#define pr_devel(fmt, ...) \ + printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) +#else +#define pr_devel(fmt, ...) \ + no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) +#endif + +#ifdef DEBUG +#define pr_debug(fmt, ...) \ + printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) +#else +#define pr_debug(fmt, ...) \ + no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) +#endif + +#define printk_once(fmt, ...) \ + printk(fmt, ##__VA_ARGS__) + +#endif