blob: 58b1fec40d37373001a6d46840702d33e70f1001 [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
Tejun Heod43ff432015-06-25 15:01:24 -070033#define CONSOLE_EXT_LOG_MAX 8192
34
Borislav Petkova8fe19e2014-06-04 16:11:46 -070035/* printk's without a loglevel use this.. */
Alex Elder42a9dc02014-08-06 16:09:01 -070036#define MESSAGE_LOGLEVEL_DEFAULT CONFIG_MESSAGE_LOGLEVEL_DEFAULT
Borislav Petkova8fe19e2014-06-04 16:11:46 -070037
38/* We show everything that is MORE important than this.. */
39#define CONSOLE_LOGLEVEL_SILENT 0 /* Mum's the word */
40#define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */
41#define CONSOLE_LOGLEVEL_QUIET 4 /* Shhh ..., when booted with "quiet" */
42#define CONSOLE_LOGLEVEL_DEFAULT 7 /* anything MORE serious than KERN_DEBUG */
43#define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */
44#define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */
45
Linus Torvalds968ab182010-11-15 13:37:37 -080046extern int console_printk[];
47
48#define console_loglevel (console_printk[0])
49#define default_message_loglevel (console_printk[1])
50#define minimum_console_loglevel (console_printk[2])
51#define default_console_loglevel (console_printk[3])
52
Joe Perchesa9747cc2011-01-12 16:59:43 -080053static inline void console_silent(void)
54{
Borislav Petkova8fe19e2014-06-04 16:11:46 -070055 console_loglevel = CONSOLE_LOGLEVEL_SILENT;
Joe Perchesa9747cc2011-01-12 16:59:43 -080056}
57
58static inline void console_verbose(void)
59{
60 if (console_loglevel)
Borislav Petkova8fe19e2014-06-04 16:11:46 -070061 console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
Joe Perchesa9747cc2011-01-12 16:59:43 -080062}
63
Linus Torvalds968ab182010-11-15 13:37:37 -080064struct va_format {
65 const char *fmt;
66 va_list *va;
67};
68
69/*
70 * FW_BUG
71 * Add this to a message where you are sure the firmware is buggy or behaves
72 * really stupid or out of spec. Be aware that the responsible BIOS developer
73 * should be able to fix this issue or at least get a concrete idea of the
74 * problem by reading your message without the need of looking at the kernel
75 * code.
76 *
77 * Use it for definite and high priority BIOS bugs.
78 *
79 * FW_WARN
80 * Use it for not that clear (e.g. could the kernel messed up things already?)
81 * and medium priority BIOS bugs.
82 *
83 * FW_INFO
84 * Use this one if you want to tell the user or vendor about something
85 * suspicious, but generally harmless related to the firmware.
86 *
87 * Use it for information or very low priority BIOS bugs.
88 */
89#define FW_BUG "[Firmware Bug]: "
90#define FW_WARN "[Firmware Warn]: "
91#define FW_INFO "[Firmware Info]: "
92
93/*
94 * HW_ERR
95 * Add this to a message for hardware errors, so that user can report
96 * it to hardware vendor instead of LKML or software vendor.
97 */
98#define HW_ERR "[Hardware Error]: "
99
Joe Perches5264f2f2011-01-12 16:59:45 -0800100/*
Neil Horman0a9a8bf2013-12-23 08:29:42 -0500101 * DEPRECATED
102 * Add this to a message whenever you want to warn user space about the use
103 * of a deprecated aspect of an API so they can stop using it
104 */
105#define DEPRECATED "[Deprecated]: "
106
107/*
Joe Perches5264f2f2011-01-12 16:59:45 -0800108 * Dummy printk for disabled debugging statements to use whilst maintaining
109 * gcc's format and side-effect checking.
110 */
Joe Perchesb9075fa2011-10-31 17:11:33 -0700111static inline __printf(1, 2)
Joe Perches5264f2f2011-01-12 16:59:45 -0800112int no_printk(const char *fmt, ...)
113{
114 return 0;
115}
116
Thomas Gleixnerd0380e62013-04-29 16:17:18 -0700117#ifdef CONFIG_EARLY_PRINTK
Joe Perchesb9075fa2011-10-31 17:11:33 -0700118extern asmlinkage __printf(1, 2)
Joe Perches5264f2f2011-01-12 16:59:45 -0800119void early_printk(const char *fmt, ...);
Thomas Gleixnerd0380e62013-04-29 16:17:18 -0700120#else
121static inline __printf(1, 2) __cold
122void early_printk(const char *s, ...) { }
123#endif
Joe Perches5264f2f2011-01-12 16:59:45 -0800124
Steven Rostedt (Red Hat)04b74b22014-11-21 09:16:58 -0500125typedef int(*printk_func_t)(const char *fmt, va_list args);
126
Linus Torvalds968ab182010-11-15 13:37:37 -0800127#ifdef CONFIG_PRINTK
Kay Sievers7ff95542012-05-03 02:29:13 +0200128asmlinkage __printf(5, 0)
129int vprintk_emit(int facility, int level,
130 const char *dict, size_t dictlen,
131 const char *fmt, va_list args);
132
Joe Perchesb9075fa2011-10-31 17:11:33 -0700133asmlinkage __printf(1, 0)
Joe Perches5264f2f2011-01-12 16:59:45 -0800134int vprintk(const char *fmt, va_list args);
Kay Sievers7ff95542012-05-03 02:29:13 +0200135
136asmlinkage __printf(5, 6) __cold
Simon Kågströmd487d572014-04-03 14:48:44 -0700137int printk_emit(int facility, int level,
138 const char *dict, size_t dictlen,
139 const char *fmt, ...);
Kay Sievers7ff95542012-05-03 02:29:13 +0200140
Joe Perchesb9075fa2011-10-31 17:11:33 -0700141asmlinkage __printf(1, 2) __cold
Joe Perches5264f2f2011-01-12 16:59:45 -0800142int printk(const char *fmt, ...);
Linus Torvalds968ab182010-11-15 13:37:37 -0800143
144/*
John Stultzaac74dc2014-06-04 16:11:40 -0700145 * Special printk facility for scheduler/timekeeping use only, _DO_NOT_USE_ !
Peter Zijlstra3ccf3e82012-02-27 10:47:00 +0100146 */
John Stultzaac74dc2014-06-04 16:11:40 -0700147__printf(1, 2) __cold int printk_deferred(const char *fmt, ...);
Peter Zijlstra3ccf3e82012-02-27 10:47:00 +0100148
149/*
Linus Torvalds968ab182010-11-15 13:37:37 -0800150 * Please don't use printk_ratelimit(), because it shares ratelimiting state
151 * with all other unrelated printk_ratelimit() callsites. Instead use
152 * printk_ratelimited() or plain old __ratelimit().
153 */
154extern int __printk_ratelimit(const char *func);
155#define printk_ratelimit() __printk_ratelimit(__func__)
156extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
157 unsigned int interval_msec);
158
159extern int printk_delay_msec;
160extern int dmesg_restrict;
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800161extern int kptr_restrict;
Linus Torvalds968ab182010-11-15 13:37:37 -0800162
Frederic Weisbeckerdc72c322013-03-22 15:04:39 -0700163extern void wake_up_klogd(void);
164
Pranith Kumar07261ed2015-01-26 12:58:43 -0800165char *log_buf_addr_get(void);
166u32 log_buf_len_get(void);
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
Pranith Kumar07261ed2015-01-26 12:58:43 -0800202static inline char *log_buf_addr_get(void)
203{
204 return NULL;
205}
206
207static inline u32 log_buf_len_get(void)
208{
209 return 0;
210}
211
Linus Torvalds968ab182010-11-15 13:37:37 -0800212static inline void log_buf_kexec_setup(void)
213{
214}
Mike Travis162a7e72011-05-24 17:13:20 -0700215
216static inline void setup_log_buf(int early)
217{
218}
Tejun Heo196779b2013-04-30 15:27:12 -0700219
Tejun Heo98e5e1b2013-04-30 15:27:15 -0700220static inline void dump_stack_set_arch_desc(const char *fmt, ...)
221{
222}
223
Tejun Heo196779b2013-04-30 15:27:12 -0700224static inline void dump_stack_print_info(const char *log_lvl)
225{
226}
Tejun Heoa43cb952013-04-30 15:27:17 -0700227
228static inline void show_regs_print_info(const char *log_lvl)
229{
230}
Linus Torvalds968ab182010-11-15 13:37:37 -0800231#endif
232
Andi Kleenb6c035d2013-08-05 15:02:48 -0700233extern asmlinkage void dump_stack(void) __cold;
Linus Torvalds968ab182010-11-15 13:37:37 -0800234
Linus Torvalds968ab182010-11-15 13:37:37 -0800235#ifndef pr_fmt
236#define pr_fmt(fmt) fmt
237#endif
238
Dan Streetman6e099f52014-06-04 16:11:44 -0700239/*
240 * These can be used to print at the various log levels.
241 * All of these will print unconditionally, although note that pr_debug()
242 * and other debug macros are compiled out unless either DEBUG is defined
243 * or CONFIG_DYNAMIC_DEBUG is set.
244 */
Linus Torvalds968ab182010-11-15 13:37:37 -0800245#define pr_emerg(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800246 printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800247#define pr_alert(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800248 printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800249#define pr_crit(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800250 printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800251#define pr_err(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800252 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800253#define pr_warning(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800254 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800255#define pr_warn pr_warning
256#define pr_notice(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800257 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800258#define pr_info(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800259 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
Steven Rostedt7b1460e2015-04-15 16:16:59 -0700260/*
261 * Like KERN_CONT, pr_cont() should only be used when continuing
262 * a line with no newline ('\n') enclosed. Otherwise it defaults
263 * back to KERN_DEFAULT.
264 */
Linus Torvalds968ab182010-11-15 13:37:37 -0800265#define pr_cont(fmt, ...) \
266 printk(KERN_CONT fmt, ##__VA_ARGS__)
267
268/* pr_devel() should produce zero code unless DEBUG is defined */
269#ifdef DEBUG
270#define pr_devel(fmt, ...) \
271 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
272#else
273#define pr_devel(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
Joe Perches29fc2bc2013-10-26 20:41:53 -0700277#include <linux/dynamic_debug.h>
278
Linus Torvalds968ab182010-11-15 13:37:37 -0800279/* If you are writing a driver, please use dev_dbg instead */
Jim Cromieb558c962011-12-19 17:11:18 -0500280#if defined(CONFIG_DYNAMIC_DEBUG)
Linus Torvalds968ab182010-11-15 13:37:37 -0800281/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
282#define pr_debug(fmt, ...) \
283 dynamic_pr_debug(fmt, ##__VA_ARGS__)
Jim Cromieb558c962011-12-19 17:11:18 -0500284#elif defined(DEBUG)
285#define pr_debug(fmt, ...) \
286 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800287#else
288#define pr_debug(fmt, ...) \
Joe Perches5264f2f2011-01-12 16:59:45 -0800289 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800290#endif
291
292/*
Joe Perches16cb8392011-01-12 16:59:46 -0800293 * Print a one-time message (analogous to WARN_ONCE() et al):
294 */
295
296#ifdef CONFIG_PRINTK
Joe Perchesc28aa1f2014-01-23 15:54:16 -0800297#define printk_once(fmt, ...) \
298({ \
299 static bool __print_once __read_mostly; \
300 \
301 if (!__print_once) { \
302 __print_once = true; \
303 printk(fmt, ##__VA_ARGS__); \
304 } \
Joe Perches16cb8392011-01-12 16:59:46 -0800305})
John Stultzc2248152014-06-04 16:11:41 -0700306#define printk_deferred_once(fmt, ...) \
307({ \
308 static bool __print_once __read_mostly; \
309 \
310 if (!__print_once) { \
311 __print_once = true; \
312 printk_deferred(fmt, ##__VA_ARGS__); \
313 } \
314})
Joe Perches16cb8392011-01-12 16:59:46 -0800315#else
Joe Perchesc28aa1f2014-01-23 15:54:16 -0800316#define printk_once(fmt, ...) \
Joe Perches16cb8392011-01-12 16:59:46 -0800317 no_printk(fmt, ##__VA_ARGS__)
John Stultzc2248152014-06-04 16:11:41 -0700318#define printk_deferred_once(fmt, ...) \
319 no_printk(fmt, ##__VA_ARGS__)
Joe Perches16cb8392011-01-12 16:59:46 -0800320#endif
321
322#define pr_emerg_once(fmt, ...) \
323 printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
324#define pr_alert_once(fmt, ...) \
325 printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
326#define pr_crit_once(fmt, ...) \
327 printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
328#define pr_err_once(fmt, ...) \
329 printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
330#define pr_warn_once(fmt, ...) \
331 printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
332#define pr_notice_once(fmt, ...) \
333 printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
334#define pr_info_once(fmt, ...) \
335 printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
336#define pr_cont_once(fmt, ...) \
337 printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__)
Mikhail Gruzdev36d308d2013-02-21 16:43:10 -0800338
339#if defined(DEBUG)
340#define pr_devel_once(fmt, ...) \
341 printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
342#else
343#define pr_devel_once(fmt, ...) \
344 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
345#endif
346
Joe Perches16cb8392011-01-12 16:59:46 -0800347/* If you are writing a driver, please use dev_dbg instead */
348#if defined(DEBUG)
349#define pr_debug_once(fmt, ...) \
350 printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
351#else
352#define pr_debug_once(fmt, ...) \
353 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
354#endif
355
356/*
Linus Torvalds968ab182010-11-15 13:37:37 -0800357 * ratelimited messages with local ratelimit_state,
358 * no local ratelimit_state used in the !PRINTK case
359 */
360#ifdef CONFIG_PRINTK
Joe Perches6ec42a562011-01-12 16:59:47 -0800361#define printk_ratelimited(fmt, ...) \
362({ \
Linus Torvalds968ab182010-11-15 13:37:37 -0800363 static DEFINE_RATELIMIT_STATE(_rs, \
364 DEFAULT_RATELIMIT_INTERVAL, \
365 DEFAULT_RATELIMIT_BURST); \
366 \
367 if (__ratelimit(&_rs)) \
368 printk(fmt, ##__VA_ARGS__); \
369})
370#else
Joe Perches6ec42a562011-01-12 16:59:47 -0800371#define printk_ratelimited(fmt, ...) \
372 no_printk(fmt, ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800373#endif
374
Joe Perches6ec42a562011-01-12 16:59:47 -0800375#define pr_emerg_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800376 printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800377#define pr_alert_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800378 printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800379#define pr_crit_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800380 printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800381#define pr_err_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800382 printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800383#define pr_warn_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800384 printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800385#define pr_notice_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800386 printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800387#define pr_info_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800388 printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
389/* no pr_cont_ratelimited, don't do that... */
Mikhail Gruzdev36d308d2013-02-21 16:43:10 -0800390
391#if defined(DEBUG)
392#define pr_devel_ratelimited(fmt, ...) \
393 printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
394#else
395#define pr_devel_ratelimited(fmt, ...) \
396 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
397#endif
398
Linus Torvalds968ab182010-11-15 13:37:37 -0800399/* If you are writing a driver, please use dev_dbg instead */
Joe Perches29fc2bc2013-10-26 20:41:53 -0700400#if defined(CONFIG_DYNAMIC_DEBUG)
401/* descriptor check is first to prevent flooding with "callbacks suppressed" */
402#define pr_debug_ratelimited(fmt, ...) \
403do { \
404 static DEFINE_RATELIMIT_STATE(_rs, \
405 DEFAULT_RATELIMIT_INTERVAL, \
406 DEFAULT_RATELIMIT_BURST); \
407 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
408 if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \
409 __ratelimit(&_rs)) \
410 __dynamic_pr_debug(&descriptor, fmt, ##__VA_ARGS__); \
411} while (0)
412#elif defined(DEBUG)
Joe Perches6ec42a562011-01-12 16:59:47 -0800413#define pr_debug_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800414 printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
415#else
416#define pr_debug_ratelimited(fmt, ...) \
Joe Perches5264f2f2011-01-12 16:59:45 -0800417 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800418#endif
419
Kay Sieverse11fea92012-05-03 02:29:41 +0200420extern const struct file_operations kmsg_fops;
421
Joe Perchesac83ed62011-01-12 16:59:47 -0800422enum {
423 DUMP_PREFIX_NONE,
424 DUMP_PREFIX_ADDRESS,
425 DUMP_PREFIX_OFFSET
426};
Andy Shevchenko114fc1a2015-02-12 15:02:29 -0800427extern int hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
428 int groupsize, char *linebuf, size_t linebuflen,
429 bool ascii);
Joe Perchesac83ed62011-01-12 16:59:47 -0800430#ifdef CONFIG_PRINTK
431extern void print_hex_dump(const char *level, const char *prefix_str,
432 int prefix_type, int rowsize, int groupsize,
433 const void *buf, size_t len, bool ascii);
Vladimir Kondratiev7a555612012-12-05 16:48:27 -0500434#if defined(CONFIG_DYNAMIC_DEBUG)
435#define print_hex_dump_bytes(prefix_str, prefix_type, buf, len) \
436 dynamic_hex_dump(prefix_str, prefix_type, 16, 1, buf, len, true)
437#else
Joe Perchesac83ed62011-01-12 16:59:47 -0800438extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
439 const void *buf, size_t len);
Vladimir Kondratiev7a555612012-12-05 16:48:27 -0500440#endif /* defined(CONFIG_DYNAMIC_DEBUG) */
Joe Perchesac83ed62011-01-12 16:59:47 -0800441#else
442static inline void print_hex_dump(const char *level, const char *prefix_str,
443 int prefix_type, int rowsize, int groupsize,
444 const void *buf, size_t len, bool ascii)
445{
446}
447static inline void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
448 const void *buf, size_t len)
449{
450}
451
452#endif
453
Vladimir Kondratiev7a555612012-12-05 16:48:27 -0500454#if defined(CONFIG_DYNAMIC_DEBUG)
455#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \
456 groupsize, buf, len, ascii) \
457 dynamic_hex_dump(prefix_str, prefix_type, rowsize, \
458 groupsize, buf, len, ascii)
459#else
460#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \
461 groupsize, buf, len, ascii) \
462 print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize, \
463 groupsize, buf, len, ascii)
464#endif /* defined(CONFIG_DYNAMIC_DEBUG) */
465
Linus Torvalds968ab182010-11-15 13:37:37 -0800466#endif