提交 d091c2f5 编写于 作者: M Martin Schwidefsky 提交者: Linus Torvalds

Add 'pr_fmt()' format modifier to pr_xyz macros.

A common reason for device drivers to implement their own printk macros
is the lack of a printk prefix with the standard pr_xyz macros.
Introduce a pr_fmt() macro that is applied for every pr_xyz macro to the
format string.

The most common use of the pr_fmt macro would be to add the name of the
device driver to all pr_xyz messages in a source file.
Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 4d41e121
...@@ -318,32 +318,36 @@ static inline char *pack_hex_byte(char *buf, u8 byte) ...@@ -318,32 +318,36 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
return buf; return buf;
} }
#define pr_emerg(fmt, arg...) \ #ifndef pr_fmt
printk(KERN_EMERG fmt, ##arg) #define pr_fmt(fmt) fmt
#define pr_alert(fmt, arg...) \ #endif
printk(KERN_ALERT fmt, ##arg)
#define pr_crit(fmt, arg...) \ #define pr_emerg(fmt, ...) \
printk(KERN_CRIT fmt, ##arg) printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
#define pr_err(fmt, arg...) \ #define pr_alert(fmt, ...) \
printk(KERN_ERR fmt, ##arg) printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
#define pr_warning(fmt, arg...) \ #define pr_crit(fmt, ...) \
printk(KERN_WARNING fmt, ##arg) printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
#define pr_notice(fmt, arg...) \ #define pr_err(fmt, ...) \
printk(KERN_NOTICE fmt, ##arg) printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
#define pr_info(fmt, arg...) \ #define pr_warning(fmt, ...) \
printk(KERN_INFO fmt, ##arg) printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
#define pr_notice(fmt, ...) \
printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
#define pr_info(fmt, ...) \
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
/* If you are writing a driver, please use dev_dbg instead */ /* If you are writing a driver, please use dev_dbg instead */
#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG) #if defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
#define pr_debug(fmt, ...) do { \ #define pr_debug(fmt, ...) do { \
dynamic_pr_debug(fmt, ##__VA_ARGS__); \ dynamic_pr_debug(pr_fmt(fmt), ##__VA_ARGS__); \
} while (0) } while (0)
#elif defined(DEBUG) #elif defined(DEBUG)
#define pr_debug(fmt, arg...) \ #define pr_debug(fmt, ...) \
printk(KERN_DEBUG fmt, ##arg) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#else #else
#define pr_debug(fmt, arg...) \ #define pr_debug(fmt, ...) \
({ if (0) printk(KERN_DEBUG fmt, ##arg); 0; }) ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
#endif #endif
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册