blob: 4d5bf5726578c58b739a79a5f093e5f7c4a009a3 [file] [log] [blame]
Linus Torvalds968ab182010-11-15 13:37:37 -08001#ifndef __KERNEL_PRINTK__
2#define __KERNEL_PRINTK__
3
Andrew Morton1b2c2892013-04-29 16:17:19 -07004#include <stdarg.h>
Mike Travis162a7e72011-05-24 17:13:20 -07005#include <linux/init.h>
Joe Perches314ba352012-07-30 14:40:11 -07006#include <linux/kern_levels.h>
Ralf Baechle154c2672013-05-21 10:51:10 +02007#include <linux/linkage.h>
Joe Perchesc28aa1f2014-01-23 15:54:16 -08008#include <linux/cache.h>
Mike Travis162a7e72011-05-24 17:13:20 -07009
Linus Torvalds968ab182010-11-15 13:37:37 -080010extern const char linux_banner[];
11extern const char linux_proc_banner[];
12
Joe Perchesacc8fa412012-07-30 14:40:09 -070013static inline int printk_get_level(const char *buffer)
14{
Joe Perches04d2c8c2012-07-30 14:40:17 -070015 if (buffer[0] == KERN_SOH_ASCII && buffer[1]) {
Joe Perchesacc8fa412012-07-30 14:40:09 -070016 switch (buffer[1]) {
17 case '0' ... '7':
18 case 'd': /* KERN_DEFAULT */
Joe Perchesacc8fa412012-07-30 14:40:09 -070019 return buffer[1];
20 }
21 }
22 return 0;
23}
24
25static inline const char *printk_skip_level(const char *buffer)
26{
Petr Mladek01856982014-04-03 14:48:38 -070027 if (printk_get_level(buffer))
28 return buffer + 2;
29
Joe Perchesacc8fa412012-07-30 14:40:09 -070030 return buffer;
31}
32
Borislav Petkova8fe19e2014-06-04 16:11:46 -070033/* printk's without a loglevel use this.. */
Alex Elder42a9dc02014-08-06 16:09:01 -070034#define MESSAGE_LOGLEVEL_DEFAULT CONFIG_MESSAGE_LOGLEVEL_DEFAULT
Borislav Petkova8fe19e2014-06-04 16:11:46 -070035
36/* We show everything that is MORE important than this.. */
37#define CONSOLE_LOGLEVEL_SILENT 0 /* Mum's the word */
38#define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */
39#define CONSOLE_LOGLEVEL_QUIET 4 /* Shhh ..., when booted with "quiet" */
40#define CONSOLE_LOGLEVEL_DEFAULT 7 /* anything MORE serious than KERN_DEBUG */
41#define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */
42#define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */
43
Linus Torvalds968ab182010-11-15 13:37:37 -080044extern int console_printk[];
45
46#define console_loglevel (console_printk[0])
47#define default_message_loglevel (console_printk[1])
48#define minimum_console_loglevel (console_printk[2])
49#define default_console_loglevel (console_printk[3])
50
Joe Perchesa9747cc2011-01-12 16:59:43 -080051static inline void console_silent(void)
52{
Borislav Petkova8fe19e2014-06-04 16:11:46 -070053 console_loglevel = CONSOLE_LOGLEVEL_SILENT;
Joe Perchesa9747cc2011-01-12 16:59:43 -080054}
55
56static inline void console_verbose(void)
57{
58 if (console_loglevel)
Borislav Petkova8fe19e2014-06-04 16:11:46 -070059 console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
Joe Perchesa9747cc2011-01-12 16:59:43 -080060}
61
Linus Torvalds968ab182010-11-15 13:37:37 -080062struct va_format {
63 const char *fmt;
64 va_list *va;
65};
66
67/*
68 * FW_BUG
69 * Add this to a message where you are sure the firmware is buggy or behaves
70 * really stupid or out of spec. Be aware that the responsible BIOS developer
71 * should be able to fix this issue or at least get a concrete idea of the
72 * problem by reading your message without the need of looking at the kernel
73 * code.
74 *
75 * Use it for definite and high priority BIOS bugs.
76 *
77 * FW_WARN
78 * Use it for not that clear (e.g. could the kernel messed up things already?)
79 * and medium priority BIOS bugs.
80 *
81 * FW_INFO
82 * Use this one if you want to tell the user or vendor about something
83 * suspicious, but generally harmless related to the firmware.
84 *
85 * Use it for information or very low priority BIOS bugs.
86 */
87#define FW_BUG "[Firmware Bug]: "
88#define FW_WARN "[Firmware Warn]: "
89#define FW_INFO "[Firmware Info]: "
90
91/*
92 * HW_ERR
93 * Add this to a message for hardware errors, so that user can report
94 * it to hardware vendor instead of LKML or software vendor.
95 */
96#define HW_ERR "[Hardware Error]: "
97
Joe Perches5264f2f2011-01-12 16:59:45 -080098/*
Neil Horman0a9a8bf2013-12-23 08:29:42 -050099 * DEPRECATED
100 * Add this to a message whenever you want to warn user space about the use
101 * of a deprecated aspect of an API so they can stop using it
102 */
103#define DEPRECATED "[Deprecated]: "
104
105/*
Joe Perches5264f2f2011-01-12 16:59:45 -0800106 * Dummy printk for disabled debugging statements to use whilst maintaining
107 * gcc's format and side-effect checking.
108 */
Joe Perchesb9075fa2011-10-31 17:11:33 -0700109static inline __printf(1, 2)
Joe Perches5264f2f2011-01-12 16:59:45 -0800110int no_printk(const char *fmt, ...)
111{
112 return 0;
113}
114
Thomas Gleixnerd0380e62013-04-29 16:17:18 -0700115#ifdef CONFIG_EARLY_PRINTK
Joe Perchesb9075fa2011-10-31 17:11:33 -0700116extern asmlinkage __printf(1, 2)
Joe Perches5264f2f2011-01-12 16:59:45 -0800117void early_printk(const char *fmt, ...);
Thomas Gleixnerd0380e62013-04-29 16:17:18 -0700118#else
119static inline __printf(1, 2) __cold
120void early_printk(const char *s, ...) { }
121#endif
Joe Perches5264f2f2011-01-12 16:59:45 -0800122
Steven Rostedt (Red Hat)04b74b22014-11-21 09:16:58 -0500123typedef int(*printk_func_t)(const char *fmt, va_list args);
124
Linus Torvalds968ab182010-11-15 13:37:37 -0800125#ifdef CONFIG_PRINTK
Kay Sievers7ff95542012-05-03 02:29:13 +0200126asmlinkage __printf(5, 0)
127int vprintk_emit(int facility, int level,
128 const char *dict, size_t dictlen,
129 const char *fmt, va_list args);
130
Joe Perchesb9075fa2011-10-31 17:11:33 -0700131asmlinkage __printf(1, 0)
Joe Perches5264f2f2011-01-12 16:59:45 -0800132int vprintk(const char *fmt, va_list args);
Kay Sievers7ff95542012-05-03 02:29:13 +0200133
134asmlinkage __printf(5, 6) __cold
Simon Kågströmd487d572014-04-03 14:48:44 -0700135int printk_emit(int facility, int level,
136 const char *dict, size_t dictlen,
137 const char *fmt, ...);
Kay Sievers7ff95542012-05-03 02:29:13 +0200138
Joe Perchesb9075fa2011-10-31 17:11:33 -0700139asmlinkage __printf(1, 2) __cold
Joe Perches5264f2f2011-01-12 16:59:45 -0800140int printk(const char *fmt, ...);
Linus Torvalds968ab182010-11-15 13:37:37 -0800141
142/*
John Stultzaac74dc2014-06-04 16:11:40 -0700143 * Special printk facility for scheduler/timekeeping use only, _DO_NOT_USE_ !
Peter Zijlstra3ccf3e82012-02-27 10:47:00 +0100144 */
John Stultzaac74dc2014-06-04 16:11:40 -0700145__printf(1, 2) __cold int printk_deferred(const char *fmt, ...);
Peter Zijlstra3ccf3e82012-02-27 10:47:00 +0100146
147/*
Linus Torvalds968ab182010-11-15 13:37:37 -0800148 * Please don't use printk_ratelimit(), because it shares ratelimiting state
149 * with all other unrelated printk_ratelimit() callsites. Instead use
150 * printk_ratelimited() or plain old __ratelimit().
151 */
152extern int __printk_ratelimit(const char *func);
153#define printk_ratelimit() __printk_ratelimit(__func__)
154extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
155 unsigned int interval_msec);
156
157extern int printk_delay_msec;
158extern int dmesg_restrict;
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800159extern int kptr_restrict;
Linus Torvalds968ab182010-11-15 13:37:37 -0800160
Frederic Weisbeckerdc72c322013-03-22 15:04:39 -0700161extern void wake_up_klogd(void);
162
Pranith Kumar07261ed2015-01-26 12:58:43 -0800163char *log_buf_addr_get(void);
164u32 log_buf_len_get(void);
Linus Torvalds968ab182010-11-15 13:37:37 -0800165void log_buf_kexec_setup(void);
Mike Travis162a7e72011-05-24 17:13:20 -0700166void __init setup_log_buf(int early);
Tejun Heo98e5e1b2013-04-30 15:27:15 -0700167void dump_stack_set_arch_desc(const char *fmt, ...);
Tejun Heo196779b2013-04-30 15:27:12 -0700168void dump_stack_print_info(const char *log_lvl);
Tejun Heoa43cb952013-04-30 15:27:17 -0700169void show_regs_print_info(const char *log_lvl);
Linus Torvalds968ab182010-11-15 13:37:37 -0800170#else
Joe Perchesb9075fa2011-10-31 17:11:33 -0700171static inline __printf(1, 0)
Joe Perches5264f2f2011-01-12 16:59:45 -0800172int vprintk(const char *s, va_list args)
173{
174 return 0;
175}
Joe Perchesb9075fa2011-10-31 17:11:33 -0700176static inline __printf(1, 2) __cold
Joe Perches5264f2f2011-01-12 16:59:45 -0800177int printk(const char *s, ...)
178{
179 return 0;
180}
Peter Zijlstra3ccf3e82012-02-27 10:47:00 +0100181static inline __printf(1, 2) __cold
John Stultzaac74dc2014-06-04 16:11:40 -0700182int printk_deferred(const char *s, ...)
Peter Zijlstra3ccf3e82012-02-27 10:47:00 +0100183{
184 return 0;
185}
Joe Perches5264f2f2011-01-12 16:59:45 -0800186static inline int printk_ratelimit(void)
187{
188 return 0;
189}
190static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies,
191 unsigned int interval_msec)
192{
193 return false;
194}
Linus Torvalds968ab182010-11-15 13:37:37 -0800195
Frederic Weisbeckerdc72c322013-03-22 15:04:39 -0700196static inline void wake_up_klogd(void)
197{
198}
199
Pranith Kumar07261ed2015-01-26 12:58:43 -0800200static inline char *log_buf_addr_get(void)
201{
202 return NULL;
203}
204
205static inline u32 log_buf_len_get(void)
206{
207 return 0;
208}
209
Linus Torvalds968ab182010-11-15 13:37:37 -0800210static inline void log_buf_kexec_setup(void)
211{
212}
Mike Travis162a7e72011-05-24 17:13:20 -0700213
214static inline void setup_log_buf(int early)
215{
216}
Tejun Heo196779b2013-04-30 15:27:12 -0700217
Tejun Heo98e5e1b2013-04-30 15:27:15 -0700218static inline void dump_stack_set_arch_desc(const char *fmt, ...)
219{
220}
221
Tejun Heo196779b2013-04-30 15:27:12 -0700222static inline void dump_stack_print_info(const char *log_lvl)
223{
224}
Tejun Heoa43cb952013-04-30 15:27:17 -0700225
226static inline void show_regs_print_info(const char *log_lvl)
227{
228}
Linus Torvalds968ab182010-11-15 13:37:37 -0800229#endif
230
Andi Kleenb6c035d2013-08-05 15:02:48 -0700231extern asmlinkage void dump_stack(void) __cold;
Linus Torvalds968ab182010-11-15 13:37:37 -0800232
Linus Torvalds968ab182010-11-15 13:37:37 -0800233#ifndef pr_fmt
234#define pr_fmt(fmt) fmt
235#endif
236
Dan Streetman6e099f52014-06-04 16:11:44 -0700237/*
238 * These can be used to print at the various log levels.
239 * All of these will print unconditionally, although note that pr_debug()
240 * and other debug macros are compiled out unless either DEBUG is defined
241 * or CONFIG_DYNAMIC_DEBUG is set.
242 */
Linus Torvalds968ab182010-11-15 13:37:37 -0800243#define pr_emerg(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800244 printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800245#define pr_alert(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800246 printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800247#define pr_crit(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800248 printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800249#define pr_err(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800250 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800251#define pr_warning(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800252 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800253#define pr_warn pr_warning
254#define pr_notice(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800255 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800256#define pr_info(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800257 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800258#define pr_cont(fmt, ...) \
259 printk(KERN_CONT fmt, ##__VA_ARGS__)
260
261/* pr_devel() should produce zero code unless DEBUG is defined */
262#ifdef DEBUG
263#define pr_devel(fmt, ...) \
264 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
265#else
266#define pr_devel(fmt, ...) \
Joe Perches5264f2f2011-01-12 16:59:45 -0800267 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800268#endif
269
Joe Perches29fc2bc2013-10-26 20:41:53 -0700270#include <linux/dynamic_debug.h>
271
Linus Torvalds968ab182010-11-15 13:37:37 -0800272/* If you are writing a driver, please use dev_dbg instead */
Jim Cromieb558c962011-12-19 17:11:18 -0500273#if defined(CONFIG_DYNAMIC_DEBUG)
Linus Torvalds968ab182010-11-15 13:37:37 -0800274/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
275#define pr_debug(fmt, ...) \
276 dynamic_pr_debug(fmt, ##__VA_ARGS__)
Jim Cromieb558c962011-12-19 17:11:18 -0500277#elif defined(DEBUG)
278#define pr_debug(fmt, ...) \
279 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800280#else
281#define pr_debug(fmt, ...) \
Joe Perches5264f2f2011-01-12 16:59:45 -0800282 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800283#endif
284
285/*
Joe Perches16cb8392011-01-12 16:59:46 -0800286 * Print a one-time message (analogous to WARN_ONCE() et al):
287 */
288
289#ifdef CONFIG_PRINTK
Joe Perchesc28aa1f2014-01-23 15:54:16 -0800290#define printk_once(fmt, ...) \
291({ \
292 static bool __print_once __read_mostly; \
293 \
294 if (!__print_once) { \
295 __print_once = true; \
296 printk(fmt, ##__VA_ARGS__); \
297 } \
Joe Perches16cb8392011-01-12 16:59:46 -0800298})
John Stultzc2248152014-06-04 16:11:41 -0700299#define printk_deferred_once(fmt, ...) \
300({ \
301 static bool __print_once __read_mostly; \
302 \
303 if (!__print_once) { \
304 __print_once = true; \
305 printk_deferred(fmt, ##__VA_ARGS__); \
306 } \
307})
Joe Perches16cb8392011-01-12 16:59:46 -0800308#else
Joe Perchesc28aa1f2014-01-23 15:54:16 -0800309#define printk_once(fmt, ...) \
Joe Perches16cb8392011-01-12 16:59:46 -0800310 no_printk(fmt, ##__VA_ARGS__)
John Stultzc2248152014-06-04 16:11:41 -0700311#define printk_deferred_once(fmt, ...) \
312 no_printk(fmt, ##__VA_ARGS__)
Joe Perches16cb8392011-01-12 16:59:46 -0800313#endif
314
315#define pr_emerg_once(fmt, ...) \
316 printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
317#define pr_alert_once(fmt, ...) \
318 printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
319#define pr_crit_once(fmt, ...) \
320 printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
321#define pr_err_once(fmt, ...) \
322 printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
323#define pr_warn_once(fmt, ...) \
324 printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
325#define pr_notice_once(fmt, ...) \
326 printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
327#define pr_info_once(fmt, ...) \
328 printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
329#define pr_cont_once(fmt, ...) \
330 printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__)
Mikhail Gruzdev36d308d2013-02-21 16:43:10 -0800331
332#if defined(DEBUG)
333#define pr_devel_once(fmt, ...) \
334 printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
335#else
336#define pr_devel_once(fmt, ...) \
337 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
338#endif
339
Joe Perches16cb8392011-01-12 16:59:46 -0800340/* If you are writing a driver, please use dev_dbg instead */
341#if defined(DEBUG)
342#define pr_debug_once(fmt, ...) \
343 printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
344#else
345#define pr_debug_once(fmt, ...) \
346 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
347#endif
348
349/*
Linus Torvalds968ab182010-11-15 13:37:37 -0800350 * ratelimited messages with local ratelimit_state,
351 * no local ratelimit_state used in the !PRINTK case
352 */
353#ifdef CONFIG_PRINTK
Joe Perches6ec42a562011-01-12 16:59:47 -0800354#define printk_ratelimited(fmt, ...) \
355({ \
Linus Torvalds968ab182010-11-15 13:37:37 -0800356 static DEFINE_RATELIMIT_STATE(_rs, \
357 DEFAULT_RATELIMIT_INTERVAL, \
358 DEFAULT_RATELIMIT_BURST); \
359 \
360 if (__ratelimit(&_rs)) \
361 printk(fmt, ##__VA_ARGS__); \
362})
363#else
Joe Perches6ec42a562011-01-12 16:59:47 -0800364#define printk_ratelimited(fmt, ...) \
365 no_printk(fmt, ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800366#endif
367
Joe Perches6ec42a562011-01-12 16:59:47 -0800368#define pr_emerg_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800369 printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800370#define pr_alert_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800371 printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800372#define pr_crit_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800373 printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800374#define pr_err_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800375 printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800376#define pr_warn_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800377 printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800378#define pr_notice_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800379 printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800380#define pr_info_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800381 printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
382/* no pr_cont_ratelimited, don't do that... */
Mikhail Gruzdev36d308d2013-02-21 16:43:10 -0800383
384#if defined(DEBUG)
385#define pr_devel_ratelimited(fmt, ...) \
386 printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
387#else
388#define pr_devel_ratelimited(fmt, ...) \
389 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
390#endif
391
Linus Torvalds968ab182010-11-15 13:37:37 -0800392/* If you are writing a driver, please use dev_dbg instead */
Joe Perches29fc2bc2013-10-26 20:41:53 -0700393#if defined(CONFIG_DYNAMIC_DEBUG)
394/* descriptor check is first to prevent flooding with "callbacks suppressed" */
395#define pr_debug_ratelimited(fmt, ...) \
396do { \
397 static DEFINE_RATELIMIT_STATE(_rs, \
398 DEFAULT_RATELIMIT_INTERVAL, \
399 DEFAULT_RATELIMIT_BURST); \
400 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
401 if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \
402 __ratelimit(&_rs)) \
403 __dynamic_pr_debug(&descriptor, fmt, ##__VA_ARGS__); \
404} while (0)
405#elif defined(DEBUG)
Joe Perches6ec42a562011-01-12 16:59:47 -0800406#define pr_debug_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800407 printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
408#else
409#define pr_debug_ratelimited(fmt, ...) \
Joe Perches5264f2f2011-01-12 16:59:45 -0800410 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800411#endif
412
Kay Sieverse11fea92012-05-03 02:29:41 +0200413extern const struct file_operations kmsg_fops;
414
Joe Perchesac83ed62011-01-12 16:59:47 -0800415enum {
416 DUMP_PREFIX_NONE,
417 DUMP_PREFIX_ADDRESS,
418 DUMP_PREFIX_OFFSET
419};
420extern void hex_dump_to_buffer(const void *buf, size_t len,
421 int rowsize, int groupsize,
422 char *linebuf, size_t linebuflen, bool ascii);
423#ifdef CONFIG_PRINTK
424extern void print_hex_dump(const char *level, const char *prefix_str,
425 int prefix_type, int rowsize, int groupsize,
426 const void *buf, size_t len, bool ascii);
Vladimir Kondratiev7a555612012-12-05 16:48:27 -0500427#if defined(CONFIG_DYNAMIC_DEBUG)
428#define print_hex_dump_bytes(prefix_str, prefix_type, buf, len) \
429 dynamic_hex_dump(prefix_str, prefix_type, 16, 1, buf, len, true)
430#else
Joe Perchesac83ed62011-01-12 16:59:47 -0800431extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
432 const void *buf, size_t len);
Vladimir Kondratiev7a555612012-12-05 16:48:27 -0500433#endif /* defined(CONFIG_DYNAMIC_DEBUG) */
Joe Perchesac83ed62011-01-12 16:59:47 -0800434#else
435static inline void print_hex_dump(const char *level, const char *prefix_str,
436 int prefix_type, int rowsize, int groupsize,
437 const void *buf, size_t len, bool ascii)
438{
439}
440static inline void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
441 const void *buf, size_t len)
442{
443}
444
445#endif
446
Vladimir Kondratiev7a555612012-12-05 16:48:27 -0500447#if defined(CONFIG_DYNAMIC_DEBUG)
448#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \
449 groupsize, buf, len, ascii) \
450 dynamic_hex_dump(prefix_str, prefix_type, rowsize, \
451 groupsize, buf, len, ascii)
452#else
453#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \
454 groupsize, buf, len, ascii) \
455 print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize, \
456 groupsize, buf, len, ascii)
457#endif /* defined(CONFIG_DYNAMIC_DEBUG) */
458
Linus Torvalds968ab182010-11-15 13:37:37 -0800459#endif