diff options
author | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2008-11-12 15:16:43 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-11-15 14:43:37 -0500 |
commit | d091c2f58ba32029495a933b721e8e02fbd12caa (patch) | |
tree | 9f20dc4cc77e7178270fb1d5946918fe44d4e3eb /include/linux/kernel.h | |
parent | 4d41e121664893e5e338f41fbd36be4a2578c8d6 (diff) |
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: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index fba141d3ca07..dc7e0d0a6474 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -318,32 +318,36 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
318 | return buf; | 318 | return buf; |
319 | } | 319 | } |
320 | 320 | ||
321 | #define pr_emerg(fmt, arg...) \ | 321 | #ifndef pr_fmt |
322 | printk(KERN_EMERG fmt, ##arg) | 322 | #define pr_fmt(fmt) fmt |
323 | #define pr_alert(fmt, arg...) \ | 323 | #endif |
324 | printk(KERN_ALERT fmt, ##arg) | 324 | |
325 | #define pr_crit(fmt, arg...) \ | 325 | #define pr_emerg(fmt, ...) \ |
326 | printk(KERN_CRIT fmt, ##arg) | 326 | printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) |
327 | #define pr_err(fmt, arg...) \ | 327 | #define pr_alert(fmt, ...) \ |
328 | printk(KERN_ERR fmt, ##arg) | 328 | printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) |
329 | #define pr_warning(fmt, arg...) \ | 329 | #define pr_crit(fmt, ...) \ |
330 | printk(KERN_WARNING fmt, ##arg) | 330 | printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) |
331 | #define pr_notice(fmt, arg...) \ | 331 | #define pr_err(fmt, ...) \ |
332 | printk(KERN_NOTICE fmt, ##arg) | 332 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) |
333 | #define pr_info(fmt, arg...) \ | 333 | #define pr_warning(fmt, ...) \ |
334 | printk(KERN_INFO fmt, ##arg) | 334 | printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) |
335 | #define pr_notice(fmt, ...) \ | ||
336 | printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) | ||
337 | #define pr_info(fmt, ...) \ | ||
338 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | ||
335 | 339 | ||
336 | /* If you are writing a driver, please use dev_dbg instead */ | 340 | /* If you are writing a driver, please use dev_dbg instead */ |
337 | #if defined(CONFIG_DYNAMIC_PRINTK_DEBUG) | 341 | #if defined(CONFIG_DYNAMIC_PRINTK_DEBUG) |
338 | #define pr_debug(fmt, ...) do { \ | 342 | #define pr_debug(fmt, ...) do { \ |
339 | dynamic_pr_debug(fmt, ##__VA_ARGS__); \ | 343 | dynamic_pr_debug(pr_fmt(fmt), ##__VA_ARGS__); \ |
340 | } while (0) | 344 | } while (0) |
341 | #elif defined(DEBUG) | 345 | #elif defined(DEBUG) |
342 | #define pr_debug(fmt, arg...) \ | 346 | #define pr_debug(fmt, ...) \ |
343 | printk(KERN_DEBUG fmt, ##arg) | 347 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
344 | #else | 348 | #else |
345 | #define pr_debug(fmt, arg...) \ | 349 | #define pr_debug(fmt, ...) \ |
346 | ({ if (0) printk(KERN_DEBUG fmt, ##arg); 0; }) | 350 | ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) |
347 | #endif | 351 | #endif |
348 | 352 | ||
349 | /* | 353 | /* |