提交 e86ad666 编写于 作者: H Heinrich Schuchardt 提交者: Tom Rini

log: convert pr_*() to logging

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: NHeinrich Schuchardt <xypron.glpk@gmx.de>
上级 1afb9f22
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include <asm/types.h> #include <asm/types.h>
#include <asm-generic/bitsperlong.h> #include <asm-generic/bitsperlong.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/kernel.h>
#ifdef __KERNEL__ #ifdef __KERNEL__
#define BIT(nr) (1UL << (nr)) #define BIT(nr) (1UL << (nr))
...@@ -19,6 +18,9 @@ ...@@ -19,6 +18,9 @@
#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
#endif #endif
/* kernel.h includes log.h which include bitops.h */
#include <linux/kernel.h>
/* /*
* Create a contiguous bitmask starting at bit position @l and ending at * Create a contiguous bitmask starting at bit position @l and ending at
* position @h. For example * position @h. For example
......
#ifndef __KERNEL_PRINTK__ #ifndef __KERNEL_PRINTK__
#define __KERNEL_PRINTK__ #define __KERNEL_PRINTK__
#include <log.h>
#include <stdio.h> #include <stdio.h>
#include <linux/compiler.h> #include <linux/compiler.h>
...@@ -28,49 +29,56 @@ ...@@ -28,49 +29,56 @@
0; \ 0; \
}) })
#define __printk(level, fmt, ...) \
({ \
level < CONFIG_LOGLEVEL ? printk(fmt, ##__VA_ARGS__) : 0; \
})
#ifndef pr_fmt #ifndef pr_fmt
#define pr_fmt(fmt) fmt #define pr_fmt(fmt) fmt
#endif #endif
#define pr_emerg(fmt, ...) \ #define pr_emerg(fmt, ...) \
__printk(0, pr_fmt(fmt), ##__VA_ARGS__) ({ \
CONFIG_LOGLEVEL > 0 ? log_emerg(fmt, ##__VA_ARGS__) : 0; \
})
#define pr_alert(fmt, ...) \ #define pr_alert(fmt, ...) \
__printk(1, pr_fmt(fmt), ##__VA_ARGS__) ({ \
CONFIG_LOGLEVEL > 1 ? log_alert(fmt, ##__VA_ARGS__) : 0; \
})
#define pr_crit(fmt, ...) \ #define pr_crit(fmt, ...) \
__printk(2, pr_fmt(fmt), ##__VA_ARGS__) ({ \
CONFIG_LOGLEVEL > 2 ? log_crit(fmt, ##__VA_ARGS__) : 0; \
})
#define pr_err(fmt, ...) \ #define pr_err(fmt, ...) \
__printk(3, pr_fmt(fmt), ##__VA_ARGS__) ({ \
#define pr_warning(fmt, ...) \ CONFIG_LOGLEVEL > 3 ? log_err(fmt, ##__VA_ARGS__) : 0; \
__printk(4, pr_fmt(fmt), ##__VA_ARGS__) })
#define pr_warn pr_warning #define pr_warn(fmt, ...) \
({ \
CONFIG_LOGLEVEL > 4 ? log_warning(fmt, ##__VA_ARGS__) : 0; \
})
#define pr_notice(fmt, ...) \ #define pr_notice(fmt, ...) \
__printk(5, pr_fmt(fmt), ##__VA_ARGS__) ({ \
CONFIG_LOGLEVEL > 5 ? log_notice(fmt, ##__VA_ARGS__) : 0; \
})
#define pr_info(fmt, ...) \ #define pr_info(fmt, ...) \
__printk(6, pr_fmt(fmt), ##__VA_ARGS__) ({ \
CONFIG_LOGLEVEL > 6 ? log_info(fmt, ##__VA_ARGS__) : 0; \
#define pr_cont(fmt, ...) \ })
printk(fmt, ##__VA_ARGS__) #define pr_debug(fmt, ...) \
({ \
/* pr_devel() should produce zero code unless DEBUG is defined */ CONFIG_LOGLEVEL > 7 ? log_debug(fmt, ##__VA_ARGS__) : 0; \
#ifdef DEBUG })
#define pr_devel(fmt, ...) \
__printk(7, pr_fmt(fmt), ##__VA_ARGS__)
#else
#define pr_devel(fmt, ...) \ #define pr_devel(fmt, ...) \
no_printk(pr_fmt(fmt), ##__VA_ARGS__) ({ \
#endif CONFIG_LOGLEVEL > 7 ? log_debug(fmt, ##__VA_ARGS__) : 0; \
})
#ifdef DEBUG #ifdef CONFIG_LOG
#define pr_debug(fmt, ...) \ #define pr_cont(fmt, ...) \
__printk(7, pr_fmt(fmt), ##__VA_ARGS__) ({ \
gd->logl_prev < CONFIG_LOGLEVEL ? \
log_cont(fmt, ##__VA_ARGS__) : 0; \
})
#else #else
#define pr_debug(fmt, ...) \ #define pr_cont(fmt, ...) \
no_printk(pr_fmt(fmt), ##__VA_ARGS__) printk(fmt, ##__VA_ARGS__)
#endif #endif
#define printk_once(fmt, ...) \ #define printk_once(fmt, ...) \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册