diff options
author | Joe Perches <joe@perches.com> | 2011-01-12 19:59:46 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-13 11:03:09 -0500 |
commit | 16cb839f13324978bd58082e69de81a711802b11 (patch) | |
tree | eb59fdf9deea125a432c50d7cb8f7f733bd58681 /include/linux/printk.h | |
parent | 5264f2f75d8678f3e9683042a4639baa5884bda9 (diff) |
include/linux/printk.h: add pr_<level>_once macros
- Move printk_once definitions and add an #ifdef CONFIG_PRINTK
- Add pr_<level>_once so printks can use pr_fmt
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Matt Mackall <mpm@selenic.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/printk.h')
-rw-r--r-- | include/linux/printk.h | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/include/linux/printk.h b/include/linux/printk.h index 4788c2887e65..6442156707c9 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h | |||
@@ -112,18 +112,6 @@ extern int printk_delay_msec; | |||
112 | extern int dmesg_restrict; | 112 | extern int dmesg_restrict; |
113 | extern int kptr_restrict; | 113 | extern int kptr_restrict; |
114 | 114 | ||
115 | /* | ||
116 | * Print a one-time message (analogous to WARN_ONCE() et al): | ||
117 | */ | ||
118 | #define printk_once(x...) ({ \ | ||
119 | static bool __print_once; \ | ||
120 | \ | ||
121 | if (!__print_once) { \ | ||
122 | __print_once = true; \ | ||
123 | printk(x); \ | ||
124 | } \ | ||
125 | }) | ||
126 | |||
127 | void log_buf_kexec_setup(void); | 115 | void log_buf_kexec_setup(void); |
128 | #else | 116 | #else |
129 | static inline __attribute__ ((format (printf, 1, 0))) | 117 | static inline __attribute__ ((format (printf, 1, 0))) |
@@ -146,9 +134,6 @@ static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, | |||
146 | return false; | 134 | return false; |
147 | } | 135 | } |
148 | 136 | ||
149 | /* No effect, but we still get type checking even in the !PRINTK case: */ | ||
150 | #define printk_once(fmt, ...) no_printk(fmt, ##__VA_ARGS__) | ||
151 | |||
152 | static inline void log_buf_kexec_setup(void) | 137 | static inline void log_buf_kexec_setup(void) |
153 | { | 138 | { |
154 | } | 139 | } |
@@ -215,6 +200,50 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type, | |||
215 | #endif | 200 | #endif |
216 | 201 | ||
217 | /* | 202 | /* |
203 | * Print a one-time message (analogous to WARN_ONCE() et al): | ||
204 | */ | ||
205 | |||
206 | #ifdef CONFIG_PRINTK | ||
207 | #define printk_once(fmt, ...) \ | ||
208 | ({ \ | ||
209 | static bool __print_once; \ | ||
210 | \ | ||
211 | if (!__print_once) { \ | ||
212 | __print_once = true; \ | ||
213 | printk(fmt, ##__VA_ARGS__); \ | ||
214 | } \ | ||
215 | }) | ||
216 | #else | ||
217 | #define printk_once(fmt, ...) \ | ||
218 | no_printk(fmt, ##__VA_ARGS__) | ||
219 | #endif | ||
220 | |||
221 | #define pr_emerg_once(fmt, ...) \ | ||
222 | printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) | ||
223 | #define pr_alert_once(fmt, ...) \ | ||
224 | printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) | ||
225 | #define pr_crit_once(fmt, ...) \ | ||
226 | printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) | ||
227 | #define pr_err_once(fmt, ...) \ | ||
228 | printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) | ||
229 | #define pr_warn_once(fmt, ...) \ | ||
230 | printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) | ||
231 | #define pr_notice_once(fmt, ...) \ | ||
232 | printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) | ||
233 | #define pr_info_once(fmt, ...) \ | ||
234 | printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | ||
235 | #define pr_cont_once(fmt, ...) \ | ||
236 | printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__) | ||
237 | /* If you are writing a driver, please use dev_dbg instead */ | ||
238 | #if defined(DEBUG) | ||
239 | #define pr_debug_once(fmt, ...) \ | ||
240 | printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ||
241 | #else | ||
242 | #define pr_debug_once(fmt, ...) \ | ||
243 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ||
244 | #endif | ||
245 | |||
246 | /* | ||
218 | * ratelimited messages with local ratelimit_state, | 247 | * ratelimited messages with local ratelimit_state, |
219 | * no local ratelimit_state used in the !PRINTK case | 248 | * no local ratelimit_state used in the !PRINTK case |
220 | */ | 249 | */ |