diff options
Diffstat (limited to 'include/linux/kernel.h')
| -rw-r--r-- | include/linux/kernel.h | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 3fa4c590cf12..4d9c916d06d9 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
| @@ -251,10 +251,10 @@ extern int printk_delay_msec; | |||
| 251 | * Print a one-time message (analogous to WARN_ONCE() et al): | 251 | * Print a one-time message (analogous to WARN_ONCE() et al): |
| 252 | */ | 252 | */ |
| 253 | #define printk_once(x...) ({ \ | 253 | #define printk_once(x...) ({ \ |
| 254 | static bool __print_once = true; \ | 254 | static bool __print_once; \ |
| 255 | \ | 255 | \ |
| 256 | if (__print_once) { \ | 256 | if (!__print_once) { \ |
| 257 | __print_once = false; \ | 257 | __print_once = true; \ |
| 258 | printk(x); \ | 258 | printk(x); \ |
| 259 | } \ | 259 | } \ |
| 260 | }) | 260 | }) |
| @@ -397,15 +397,58 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
| 397 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | 397 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
| 398 | #elif defined(CONFIG_DYNAMIC_DEBUG) | 398 | #elif defined(CONFIG_DYNAMIC_DEBUG) |
| 399 | /* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ | 399 | /* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ |
| 400 | #define pr_debug(fmt, ...) do { \ | 400 | #define pr_debug(fmt, ...) \ |
| 401 | dynamic_pr_debug(fmt, ##__VA_ARGS__); \ | 401 | dynamic_pr_debug(fmt, ##__VA_ARGS__) |
| 402 | } while (0) | ||
| 403 | #else | 402 | #else |
| 404 | #define pr_debug(fmt, ...) \ | 403 | #define pr_debug(fmt, ...) \ |
| 405 | ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) | 404 | ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) |
| 406 | #endif | 405 | #endif |
| 407 | 406 | ||
| 408 | /* | 407 | /* |
| 408 | * ratelimited messages with local ratelimit_state, | ||
| 409 | * no local ratelimit_state used in the !PRINTK case | ||
| 410 | */ | ||
| 411 | #ifdef CONFIG_PRINTK | ||
| 412 | #define printk_ratelimited(fmt, ...) ({ \ | ||
| 413 | static struct ratelimit_state _rs = { \ | ||
| 414 | .interval = DEFAULT_RATELIMIT_INTERVAL, \ | ||
| 415 | .burst = DEFAULT_RATELIMIT_BURST, \ | ||
| 416 | }; \ | ||
| 417 | \ | ||
| 418 | if (!__ratelimit(&_rs)) \ | ||
| 419 | printk(fmt, ##__VA_ARGS__); \ | ||
| 420 | }) | ||
| 421 | #else | ||
| 422 | /* No effect, but we still get type checking even in the !PRINTK case: */ | ||
| 423 | #define printk_ratelimited printk | ||
| 424 | #endif | ||
| 425 | |||
| 426 | #define pr_emerg_ratelimited(fmt, ...) \ | ||
| 427 | printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) | ||
| 428 | #define pr_alert_ratelimited(fmt, ...) \ | ||
| 429 | printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) | ||
| 430 | #define pr_crit_ratelimited(fmt, ...) \ | ||
| 431 | printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) | ||
| 432 | #define pr_err_ratelimited(fmt, ...) \ | ||
| 433 | printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) | ||
| 434 | #define pr_warning_ratelimited(fmt, ...) \ | ||
| 435 | printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) | ||
| 436 | #define pr_notice_ratelimited(fmt, ...) \ | ||
| 437 | printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) | ||
| 438 | #define pr_info_ratelimited(fmt, ...) \ | ||
| 439 | printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | ||
| 440 | /* no pr_cont_ratelimited, don't do that... */ | ||
| 441 | /* If you are writing a driver, please use dev_dbg instead */ | ||
| 442 | #if defined(DEBUG) | ||
| 443 | #define pr_debug_ratelimited(fmt, ...) \ | ||
| 444 | printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ||
| 445 | #else | ||
| 446 | #define pr_debug_ratelimited(fmt, ...) \ | ||
| 447 | ({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \ | ||
| 448 | ##__VA_ARGS__); 0; }) | ||
| 449 | #endif | ||
| 450 | |||
| 451 | /* | ||
| 409 | * General tracing related utility functions - trace_printk(), | 452 | * General tracing related utility functions - trace_printk(), |
| 410 | * tracing_on/tracing_off and tracing_start()/tracing_stop | 453 | * tracing_on/tracing_off and tracing_start()/tracing_stop |
| 411 | * | 454 | * |
