Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Martin Schwidefsky and committed by
Linus Torvalds
d091c2f5 4d41e121

+23 -19
+23 -19
include/linux/kernel.h
··· 318 318 return buf; 319 319 } 320 320 321 - #define pr_emerg(fmt, arg...) \ 322 - printk(KERN_EMERG fmt, ##arg) 323 - #define pr_alert(fmt, arg...) \ 324 - printk(KERN_ALERT fmt, ##arg) 325 - #define pr_crit(fmt, arg...) \ 326 - printk(KERN_CRIT fmt, ##arg) 327 - #define pr_err(fmt, arg...) \ 328 - printk(KERN_ERR fmt, ##arg) 329 - #define pr_warning(fmt, arg...) \ 330 - printk(KERN_WARNING fmt, ##arg) 331 - #define pr_notice(fmt, arg...) \ 332 - printk(KERN_NOTICE fmt, ##arg) 333 - #define pr_info(fmt, arg...) \ 334 - printk(KERN_INFO fmt, ##arg) 321 + #ifndef pr_fmt 322 + #define pr_fmt(fmt) fmt 323 + #endif 324 + 325 + #define pr_emerg(fmt, ...) \ 326 + printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) 327 + #define pr_alert(fmt, ...) \ 328 + printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) 329 + #define pr_crit(fmt, ...) \ 330 + printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) 331 + #define pr_err(fmt, ...) \ 332 + printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) 333 + #define pr_warning(fmt, ...) \ 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 340 /* If you are writing a driver, please use dev_dbg instead */ 337 341 #if defined(CONFIG_DYNAMIC_PRINTK_DEBUG) 338 342 #define pr_debug(fmt, ...) do { \ 339 - dynamic_pr_debug(fmt, ##__VA_ARGS__); \ 343 + dynamic_pr_debug(pr_fmt(fmt), ##__VA_ARGS__); \ 340 344 } while (0) 341 345 #elif defined(DEBUG) 342 - #define pr_debug(fmt, arg...) \ 343 - printk(KERN_DEBUG fmt, ##arg) 346 + #define pr_debug(fmt, ...) \ 347 + printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) 344 348 #else 345 - #define pr_debug(fmt, arg...) \ 346 - ({ if (0) printk(KERN_DEBUG fmt, ##arg); 0; }) 349 + #define pr_debug(fmt, ...) \ 350 + ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) 347 351 #endif 348 352 349 353 /*