blob: c69be9ee8f48dd6525209d9c1cf5615e95cf379d [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
Vasant Hegde14c40002014-08-09 11:15:30 +053013extern char *log_buf_addr_get(void);
14extern u32 log_buf_len_get(void);
15
Joe Perchesacc8fa412012-07-30 14:40:09 -070016static inline int printk_get_level(const char *buffer)
17{
Joe Perches04d2c8c2012-07-30 14:40:17 -070018 if (buffer[0] == KERN_SOH_ASCII && buffer[1]) {
Joe Perchesacc8fa412012-07-30 14:40:09 -070019 switch (buffer[1]) {
20 case '0' ... '7':
21 case 'd': /* KERN_DEFAULT */
Joe Perchesacc8fa412012-07-30 14:40:09 -070022 return buffer[1];
23 }
24 }
25 return 0;
26}
27
28static inline const char *printk_skip_level(const char *buffer)
29{
Petr Mladek01856982014-04-03 14:48:38 -070030 if (printk_get_level(buffer))
31 return buffer + 2;
32
Joe Perchesacc8fa412012-07-30 14:40:09 -070033 return buffer;
34}
35
Borislav Petkova8fe19e2014-06-04 16:11:46 -070036/* printk's without a loglevel use this.. */
Alex Elder42a9dc02014-08-06 16:09:01 -070037#define MESSAGE_LOGLEVEL_DEFAULT CONFIG_MESSAGE_LOGLEVEL_DEFAULT
Borislav Petkova8fe19e2014-06-04 16:11:46 -070038
39/* We show everything that is MORE important than this.. */
40#define CONSOLE_LOGLEVEL_SILENT 0 /* Mum's the word */
41#define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */
42#define CONSOLE_LOGLEVEL_QUIET 4 /* Shhh ..., when booted with "quiet" */
43#define CONSOLE_LOGLEVEL_DEFAULT 7 /* anything MORE serious than KERN_DEBUG */
44#define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */
45#define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */
46
Linus Torvalds968ab182010-11-15 13:37:37 -080047extern int console_printk[];
48
49#define console_loglevel (console_printk[0])
50#define default_message_loglevel (console_printk[1])
51#define minimum_console_loglevel (console_printk[2])
52#define default_console_loglevel (console_printk[3])
53
Joe Perchesa9747cc2011-01-12 16:59:43 -080054static inline void console_silent(void)
55{
Borislav Petkova8fe19e2014-06-04 16:11:46 -070056 console_loglevel = CONSOLE_LOGLEVEL_SILENT;
Joe Perchesa9747cc2011-01-12 16:59:43 -080057}
58
59static inline void console_verbose(void)
60{
61 if (console_loglevel)
Borislav Petkova8fe19e2014-06-04 16:11:46 -070062 console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
Joe Perchesa9747cc2011-01-12 16:59:43 -080063}
64
Linus Torvalds968ab182010-11-15 13:37:37 -080065struct va_format {
66 const char *fmt;
67 va_list *va;
68};
69
70/*
71 * FW_BUG
72 * Add this to a message where you are sure the firmware is buggy or behaves
73 * really stupid or out of spec. Be aware that the responsible BIOS developer
74 * should be able to fix this issue or at least get a concrete idea of the
75 * problem by reading your message without the need of looking at the kernel
76 * code.
77 *
78 * Use it for definite and high priority BIOS bugs.
79 *
80 * FW_WARN
81 * Use it for not that clear (e.g. could the kernel messed up things already?)
82 * and medium priority BIOS bugs.
83 *
84 * FW_INFO
85 * Use this one if you want to tell the user or vendor about something
86 * suspicious, but generally harmless related to the firmware.
87 *
88 * Use it for information or very low priority BIOS bugs.
89 */
90#define FW_BUG "[Firmware Bug]: "
91#define FW_WARN "[Firmware Warn]: "
92#define FW_INFO "[Firmware Info]: "
93
94/*
95 * HW_ERR
96 * Add this to a message for hardware errors, so that user can report
97 * it to hardware vendor instead of LKML or software vendor.
98 */
99#define HW_ERR "[Hardware Error]: "
100
Joe Perches5264f2f2011-01-12 16:59:45 -0800101/*
Neil Horman0a9a8bf2013-12-23 08:29:42 -0500102 * DEPRECATED
103 * Add this to a message whenever you want to warn user space about the use
104 * of a deprecated aspect of an API so they can stop using it
105 */
106#define DEPRECATED "[Deprecated]: "
107
108/*
Joe Perches5264f2f2011-01-12 16:59:45 -0800109 * Dummy printk for disabled debugging statements to use whilst maintaining
110 * gcc's format and side-effect checking.
111 */
Joe Perchesb9075fa2011-10-31 17:11:33 -0700112static inline __printf(1, 2)
Joe Perches5264f2f2011-01-12 16:59:45 -0800113int no_printk(const char *fmt, ...)
114{
115 return 0;
116}
117
Thomas Gleixnerd0380e62013-04-29 16:17:18 -0700118#ifdef CONFIG_EARLY_PRINTK
Joe Perchesb9075fa2011-10-31 17:11:33 -0700119extern asmlinkage __printf(1, 2)
Joe Perches5264f2f2011-01-12 16:59:45 -0800120void early_printk(const char *fmt, ...);
Thomas Gleixnerd0380e62013-04-29 16:17:18 -0700121void early_vprintk(const char *fmt, va_list ap);
122#else
123static inline __printf(1, 2) __cold
124void early_printk(const char *s, ...) { }
125#endif
Joe Perches5264f2f2011-01-12 16:59:45 -0800126
Steven Rostedt (Red Hat)04b74b22014-11-21 09:16:58 -0500127typedef int(*printk_func_t)(const char *fmt, va_list args);
128
Linus Torvalds968ab182010-11-15 13:37:37 -0800129#ifdef CONFIG_PRINTK
Kay Sievers7ff95542012-05-03 02:29:13 +0200130asmlinkage __printf(5, 0)
131int vprintk_emit(int facility, int level,
132 const char *dict, size_t dictlen,
133 const char *fmt, va_list args);
134
Joe Perchesb9075fa2011-10-31 17:11:33 -0700135asmlinkage __printf(1, 0)
Joe Perches5264f2f2011-01-12 16:59:45 -0800136int vprintk(const char *fmt, va_list args);
Kay Sievers7ff95542012-05-03 02:29:13 +0200137
138asmlinkage __printf(5, 6) __cold
Simon Kågströmd487d572014-04-03 14:48:44 -0700139int printk_emit(int facility, int level,
140 const char *dict, size_t dictlen,
141 const char *fmt, ...);
Kay Sievers7ff95542012-05-03 02:29:13 +0200142
Joe Perchesb9075fa2011-10-31 17:11:33 -0700143asmlinkage __printf(1, 2) __cold
Joe Perches5264f2f2011-01-12 16:59:45 -0800144int printk(const char *fmt, ...);
Linus Torvalds968ab182010-11-15 13:37:37 -0800145
146/*
John Stultzaac74dc2014-06-04 16:11:40 -0700147 * Special printk facility for scheduler/timekeeping use only, _DO_NOT_USE_ !
Peter Zijlstra3ccf3e82012-02-27 10:47:00 +0100148 */
John Stultzaac74dc2014-06-04 16:11:40 -0700149__printf(1, 2) __cold int printk_deferred(const char *fmt, ...);
Peter Zijlstra3ccf3e82012-02-27 10:47:00 +0100150
151/*
Linus Torvalds968ab182010-11-15 13:37:37 -0800152 * Please don't use printk_ratelimit(), because it shares ratelimiting state
153 * with all other unrelated printk_ratelimit() callsites. Instead use
154 * printk_ratelimited() or plain old __ratelimit().
155 */
156extern int __printk_ratelimit(const char *func);
157#define printk_ratelimit() __printk_ratelimit(__func__)
158extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
159 unsigned int interval_msec);
160
161extern int printk_delay_msec;
162extern int dmesg_restrict;
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800163extern int kptr_restrict;
Linus Torvalds968ab182010-11-15 13:37:37 -0800164
Frederic Weisbeckerdc72c322013-03-22 15:04:39 -0700165extern void wake_up_klogd(void);
166
Linus Torvalds968ab182010-11-15 13:37:37 -0800167void log_buf_kexec_setup(void);
Mike Travis162a7e72011-05-24 17:13:20 -0700168void __init setup_log_buf(int early);
Tejun Heo98e5e1b2013-04-30 15:27:15 -0700169void dump_stack_set_arch_desc(const char *fmt, ...);
Tejun Heo196779b2013-04-30 15:27:12 -0700170void dump_stack_print_info(const char *log_lvl);
Tejun Heoa43cb952013-04-30 15:27:17 -0700171void show_regs_print_info(const char *log_lvl);
Linus Torvalds968ab182010-11-15 13:37:37 -0800172#else
Joe Perchesb9075fa2011-10-31 17:11:33 -0700173static inline __printf(1, 0)
Joe Perches5264f2f2011-01-12 16:59:45 -0800174int vprintk(const char *s, va_list args)
175{
176 return 0;
177}
Joe Perchesb9075fa2011-10-31 17:11:33 -0700178static inline __printf(1, 2) __cold
Joe Perches5264f2f2011-01-12 16:59:45 -0800179int printk(const char *s, ...)
180{
181 return 0;
182}
Peter Zijlstra3ccf3e82012-02-27 10:47:00 +0100183static inline __printf(1, 2) __cold
John Stultzaac74dc2014-06-04 16:11:40 -0700184int printk_deferred(const char *s, ...)
Peter Zijlstra3ccf3e82012-02-27 10:47:00 +0100185{
186 return 0;
187}
Joe Perches5264f2f2011-01-12 16:59:45 -0800188static inline int printk_ratelimit(void)
189{
190 return 0;
191}
192static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies,
193 unsigned int interval_msec)
194{
195 return false;
196}
Linus Torvalds968ab182010-11-15 13:37:37 -0800197
Frederic Weisbeckerdc72c322013-03-22 15:04:39 -0700198static inline void wake_up_klogd(void)
199{
200}
201
Linus Torvalds968ab182010-11-15 13:37:37 -0800202static inline void log_buf_kexec_setup(void)
203{
204}
Mike Travis162a7e72011-05-24 17:13:20 -0700205
206static inline void setup_log_buf(int early)
207{
208}
Tejun Heo196779b2013-04-30 15:27:12 -0700209
Tejun Heo98e5e1b2013-04-30 15:27:15 -0700210static inline void dump_stack_set_arch_desc(const char *fmt, ...)
211{
212}
213
Tejun Heo196779b2013-04-30 15:27:12 -0700214static inline void dump_stack_print_info(const char *log_lvl)
215{
216}
Tejun Heoa43cb952013-04-30 15:27:17 -0700217
218static inline void show_regs_print_info(const char *log_lvl)
219{
220}
Linus Torvalds968ab182010-11-15 13:37:37 -0800221#endif
222
Andi Kleenb6c035d2013-08-05 15:02:48 -0700223extern asmlinkage void dump_stack(void) __cold;
Linus Torvalds968ab182010-11-15 13:37:37 -0800224
Linus Torvalds968ab182010-11-15 13:37:37 -0800225#ifndef pr_fmt
226#define pr_fmt(fmt) fmt
227#endif
228
Dan Streetman6e099f52014-06-04 16:11:44 -0700229/*
230 * These can be used to print at the various log levels.
231 * All of these will print unconditionally, although note that pr_debug()
232 * and other debug macros are compiled out unless either DEBUG is defined
233 * or CONFIG_DYNAMIC_DEBUG is set.
234 */
Linus Torvalds968ab182010-11-15 13:37:37 -0800235#define pr_emerg(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800236 printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800237#define pr_alert(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800238 printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800239#define pr_crit(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800240 printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800241#define pr_err(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800242 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800243#define pr_warning(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800244 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800245#define pr_warn pr_warning
246#define pr_notice(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800247 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800248#define pr_info(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800249 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800250#define pr_cont(fmt, ...) \
251 printk(KERN_CONT fmt, ##__VA_ARGS__)
252
253/* pr_devel() should produce zero code unless DEBUG is defined */
254#ifdef DEBUG
255#define pr_devel(fmt, ...) \
256 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
257#else
258#define pr_devel(fmt, ...) \
Joe Perches5264f2f2011-01-12 16:59:45 -0800259 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800260#endif
261
Joe Perches29fc2bc2013-10-26 20:41:53 -0700262#include <linux/dynamic_debug.h>
263
Linus Torvalds968ab182010-11-15 13:37:37 -0800264/* If you are writing a driver, please use dev_dbg instead */
Jim Cromieb558c962011-12-19 17:11:18 -0500265#if defined(CONFIG_DYNAMIC_DEBUG)
Linus Torvalds968ab182010-11-15 13:37:37 -0800266/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
267#define pr_debug(fmt, ...) \
268 dynamic_pr_debug(fmt, ##__VA_ARGS__)
Jim Cromieb558c962011-12-19 17:11:18 -0500269#elif defined(DEBUG)
270#define pr_debug(fmt, ...) \
271 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800272#else
273#define pr_debug(fmt, ...) \
Joe Perches5264f2f2011-01-12 16:59:45 -0800274 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800275#endif
276
277/*
Joe Perches16cb8392011-01-12 16:59:46 -0800278 * Print a one-time message (analogous to WARN_ONCE() et al):
279 */
280
281#ifdef CONFIG_PRINTK
Joe Perchesc28aa1f2014-01-23 15:54:16 -0800282#define printk_once(fmt, ...) \
283({ \
284 static bool __print_once __read_mostly; \
285 \
286 if (!__print_once) { \
287 __print_once = true; \
288 printk(fmt, ##__VA_ARGS__); \
289 } \
Joe Perches16cb8392011-01-12 16:59:46 -0800290})
John Stultzc2248152014-06-04 16:11:41 -0700291#define printk_deferred_once(fmt, ...) \
292({ \
293 static bool __print_once __read_mostly; \
294 \
295 if (!__print_once) { \
296 __print_once = true; \
297 printk_deferred(fmt, ##__VA_ARGS__); \
298 } \
299})
Joe Perches16cb8392011-01-12 16:59:46 -0800300#else
Joe Perchesc28aa1f2014-01-23 15:54:16 -0800301#define printk_once(fmt, ...) \
Joe Perches16cb8392011-01-12 16:59:46 -0800302 no_printk(fmt, ##__VA_ARGS__)
John Stultzc2248152014-06-04 16:11:41 -0700303#define printk_deferred_once(fmt, ...) \
304 no_printk(fmt, ##__VA_ARGS__)
Joe Perches16cb8392011-01-12 16:59:46 -0800305#endif
306
307#define pr_emerg_once(fmt, ...) \
308 printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
309#define pr_alert_once(fmt, ...) \
310 printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
311#define pr_crit_once(fmt, ...) \
312 printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
313#define pr_err_once(fmt, ...) \
314 printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
315#define pr_warn_once(fmt, ...) \
316 printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
317#define pr_notice_once(fmt, ...) \
318 printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
319#define pr_info_once(fmt, ...) \
320 printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
321#define pr_cont_once(fmt, ...) \
322 printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__)
Mikhail Gruzdev36d308d2013-02-21 16:43:10 -0800323
324#if defined(DEBUG)
325#define pr_devel_once(fmt, ...) \
326 printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
327#else
328#define pr_devel_once(fmt, ...) \
329 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
330#endif
331
Joe Perches16cb8392011-01-12 16:59:46 -0800332/* If you are writing a driver, please use dev_dbg instead */
333#if defined(DEBUG)
334#define pr_debug_once(fmt, ...) \
335 printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
336#else
337#define pr_debug_once(fmt, ...) \
338 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
339#endif
340
341/*
Linus Torvalds968ab182010-11-15 13:37:37 -0800342 * ratelimited messages with local ratelimit_state,
343 * no local ratelimit_state used in the !PRINTK case
344 */
345#ifdef CONFIG_PRINTK
Joe Perches6ec42a562011-01-12 16:59:47 -0800346#define printk_ratelimited(fmt, ...) \
347({ \
Linus Torvalds968ab182010-11-15 13:37:37 -0800348 static DEFINE_RATELIMIT_STATE(_rs, \
349 DEFAULT_RATELIMIT_INTERVAL, \
350 DEFAULT_RATELIMIT_BURST); \
351 \
352 if (__ratelimit(&_rs)) \
353 printk(fmt, ##__VA_ARGS__); \
354})
355#else
Joe Perches6ec42a562011-01-12 16:59:47 -0800356#define printk_ratelimited(fmt, ...) \
357 no_printk(fmt, ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800358#endif
359
Joe Perches6ec42a562011-01-12 16:59:47 -0800360#define pr_emerg_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800361 printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800362#define pr_alert_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800363 printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800364#define pr_crit_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800365 printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800366#define pr_err_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800367 printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800368#define pr_warn_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800369 printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800370#define pr_notice_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800371 printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800372#define pr_info_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800373 printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
374/* no pr_cont_ratelimited, don't do that... */
Mikhail Gruzdev36d308d2013-02-21 16:43:10 -0800375
376#if defined(DEBUG)
377#define pr_devel_ratelimited(fmt, ...) \
378 printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
379#else
380#define pr_devel_ratelimited(fmt, ...) \
381 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
382#endif
383
Linus Torvalds968ab182010-11-15 13:37:37 -0800384/* If you are writing a driver, please use dev_dbg instead */
Joe Perches29fc2bc2013-10-26 20:41:53 -0700385#if defined(CONFIG_DYNAMIC_DEBUG)
386/* descriptor check is first to prevent flooding with "callbacks suppressed" */
387#define pr_debug_ratelimited(fmt, ...) \
388do { \
389 static DEFINE_RATELIMIT_STATE(_rs, \
390 DEFAULT_RATELIMIT_INTERVAL, \
391 DEFAULT_RATELIMIT_BURST); \
392 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
393 if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \
394 __ratelimit(&_rs)) \
395 __dynamic_pr_debug(&descriptor, fmt, ##__VA_ARGS__); \
396} while (0)
397#elif defined(DEBUG)
Joe Perches6ec42a562011-01-12 16:59:47 -0800398#define pr_debug_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800399 printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
400#else
401#define pr_debug_ratelimited(fmt, ...) \
Joe Perches5264f2f2011-01-12 16:59:45 -0800402 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800403#endif
404
Kay Sieverse11fea92012-05-03 02:29:41 +0200405extern const struct file_operations kmsg_fops;
406
Joe Perchesac83ed62011-01-12 16:59:47 -0800407enum {
408 DUMP_PREFIX_NONE,
409 DUMP_PREFIX_ADDRESS,
410 DUMP_PREFIX_OFFSET
411};
412extern void hex_dump_to_buffer(const void *buf, size_t len,
413 int rowsize, int groupsize,
414 char *linebuf, size_t linebuflen, bool ascii);
415#ifdef CONFIG_PRINTK
416extern void print_hex_dump(const char *level, const char *prefix_str,
417 int prefix_type, int rowsize, int groupsize,
418 const void *buf, size_t len, bool ascii);
Vladimir Kondratiev7a555612012-12-05 16:48:27 -0500419#if defined(CONFIG_DYNAMIC_DEBUG)
420#define print_hex_dump_bytes(prefix_str, prefix_type, buf, len) \
421 dynamic_hex_dump(prefix_str, prefix_type, 16, 1, buf, len, true)
422#else
Joe Perchesac83ed62011-01-12 16:59:47 -0800423extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
424 const void *buf, size_t len);
Vladimir Kondratiev7a555612012-12-05 16:48:27 -0500425#endif /* defined(CONFIG_DYNAMIC_DEBUG) */
Joe Perchesac83ed62011-01-12 16:59:47 -0800426#else
427static inline void print_hex_dump(const char *level, const char *prefix_str,
428 int prefix_type, int rowsize, int groupsize,
429 const void *buf, size_t len, bool ascii)
430{
431}
432static inline void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
433 const void *buf, size_t len)
434{
435}
436
437#endif
438
Vladimir Kondratiev7a555612012-12-05 16:48:27 -0500439#if defined(CONFIG_DYNAMIC_DEBUG)
440#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \
441 groupsize, buf, len, ascii) \
442 dynamic_hex_dump(prefix_str, prefix_type, rowsize, \
443 groupsize, buf, len, ascii)
444#else
445#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \
446 groupsize, buf, len, ascii) \
447 print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize, \
448 groupsize, buf, len, ascii)
449#endif /* defined(CONFIG_DYNAMIC_DEBUG) */
450
Linus Torvalds968ab182010-11-15 13:37:37 -0800451#endif