aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/printk.h59
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;
112extern int dmesg_restrict; 112extern int dmesg_restrict;
113extern int kptr_restrict; 113extern 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
127void log_buf_kexec_setup(void); 115void log_buf_kexec_setup(void);
128#else 116#else
129static inline __attribute__ ((format (printf, 1, 0))) 117static 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
152static inline void log_buf_kexec_setup(void) 137static 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 */