• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __KERNEL_PRINTK__
3 #define __KERNEL_PRINTK__
4 
5 #include <stdarg.h>
6 #include <linux/init.h>
7 #include <linux/kern_levels.h>
8 #include <linux/linkage.h>
9 #include <linux/ratelimit_types.h>
10 
11 extern const char linux_banner[];
12 extern const char linux_proc_banner[];
13 
14 extern int oops_in_progress;	/* If set, an oops, panic(), BUG() or die() is in progress */
15 
16 #define PRINTK_MAX_SINGLE_HEADER_LEN 2
17 
printk_get_level(const char * buffer)18 static inline int printk_get_level(const char *buffer)
19 {
20 	if (buffer[0] == KERN_SOH_ASCII && buffer[1]) {
21 		switch (buffer[1]) {
22 		case '0' ... '7':
23 		case 'c':	/* KERN_CONT */
24 			return buffer[1];
25 		}
26 	}
27 	return 0;
28 }
29 
printk_skip_level(const char * buffer)30 static inline const char *printk_skip_level(const char *buffer)
31 {
32 	if (printk_get_level(buffer))
33 		return buffer + 2;
34 
35 	return buffer;
36 }
37 
printk_skip_headers(const char * buffer)38 static inline const char *printk_skip_headers(const char *buffer)
39 {
40 	while (printk_get_level(buffer))
41 		buffer = printk_skip_level(buffer);
42 
43 	return buffer;
44 }
45 
46 #define CONSOLE_EXT_LOG_MAX	8192
47 
48 /* printk's without a loglevel use this.. */
49 #define MESSAGE_LOGLEVEL_DEFAULT CONFIG_MESSAGE_LOGLEVEL_DEFAULT
50 
51 /* We show everything that is MORE important than this.. */
52 #define CONSOLE_LOGLEVEL_SILENT  0 /* Mum's the word */
53 #define CONSOLE_LOGLEVEL_MIN	 1 /* Minimum loglevel we let people use */
54 #define CONSOLE_LOGLEVEL_DEBUG	10 /* issue debug messages */
55 #define CONSOLE_LOGLEVEL_MOTORMOUTH 15	/* You can't shut this one up */
56 
57 /*
58  * Default used to be hard-coded at 7, quiet used to be hardcoded at 4,
59  * we're now allowing both to be set from kernel config.
60  */
61 #define CONSOLE_LOGLEVEL_DEFAULT CONFIG_CONSOLE_LOGLEVEL_DEFAULT
62 #define CONSOLE_LOGLEVEL_QUIET	 CONFIG_CONSOLE_LOGLEVEL_QUIET
63 
64 extern int console_printk[];
65 
66 #define console_loglevel (console_printk[0])
67 #define default_message_loglevel (console_printk[1])
68 #define minimum_console_loglevel (console_printk[2])
69 #define default_console_loglevel (console_printk[3])
70 
console_silent(void)71 static inline void console_silent(void)
72 {
73 	console_loglevel = CONSOLE_LOGLEVEL_SILENT;
74 }
75 
console_verbose(void)76 static inline void console_verbose(void)
77 {
78 	if (console_loglevel)
79 		console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
80 }
81 
82 /* strlen("ratelimit") + 1 */
83 #define DEVKMSG_STR_MAX_SIZE 10
84 extern char devkmsg_log_str[];
85 struct ctl_table;
86 
87 extern int suppress_printk;
88 
89 struct va_format {
90 	const char *fmt;
91 	va_list *va;
92 };
93 
94 /*
95  * FW_BUG
96  * Add this to a message where you are sure the firmware is buggy or behaves
97  * really stupid or out of spec. Be aware that the responsible BIOS developer
98  * should be able to fix this issue or at least get a concrete idea of the
99  * problem by reading your message without the need of looking at the kernel
100  * code.
101  *
102  * Use it for definite and high priority BIOS bugs.
103  *
104  * FW_WARN
105  * Use it for not that clear (e.g. could the kernel messed up things already?)
106  * and medium priority BIOS bugs.
107  *
108  * FW_INFO
109  * Use this one if you want to tell the user or vendor about something
110  * suspicious, but generally harmless related to the firmware.
111  *
112  * Use it for information or very low priority BIOS bugs.
113  */
114 #define FW_BUG		"[Firmware Bug]: "
115 #define FW_WARN		"[Firmware Warn]: "
116 #define FW_INFO		"[Firmware Info]: "
117 
118 /*
119  * HW_ERR
120  * Add this to a message for hardware errors, so that user can report
121  * it to hardware vendor instead of LKML or software vendor.
122  */
123 #define HW_ERR		"[Hardware Error]: "
124 
125 /*
126  * DEPRECATED
127  * Add this to a message whenever you want to warn user space about the use
128  * of a deprecated aspect of an API so they can stop using it
129  */
130 #define DEPRECATED	"[Deprecated]: "
131 
132 /*
133  * Dummy printk for disabled debugging statements to use whilst maintaining
134  * gcc's format checking.
135  */
136 #define no_printk(fmt, ...)				\
137 ({							\
138 	if (0)						\
139 		printk(fmt, ##__VA_ARGS__);		\
140 	0;						\
141 })
142 
143 #ifdef CONFIG_EARLY_PRINTK
144 extern asmlinkage __printf(1, 2)
145 void early_printk(const char *fmt, ...);
146 #else
147 static inline __printf(1, 2) __cold
early_printk(const char * s,...)148 void early_printk(const char *s, ...) { }
149 #endif
150 
151 #ifdef CONFIG_PRINTK_NMI
152 extern void printk_nmi_enter(void);
153 extern void printk_nmi_exit(void);
154 extern void printk_nmi_direct_enter(void);
155 extern void printk_nmi_direct_exit(void);
156 #else
printk_nmi_enter(void)157 static inline void printk_nmi_enter(void) { }
printk_nmi_exit(void)158 static inline void printk_nmi_exit(void) { }
printk_nmi_direct_enter(void)159 static inline void printk_nmi_direct_enter(void) { }
printk_nmi_direct_exit(void)160 static inline void printk_nmi_direct_exit(void) { }
161 #endif /* PRINTK_NMI */
162 
163 struct dev_printk_info;
164 
165 #ifdef CONFIG_PRINTK
166 asmlinkage __printf(4, 0)
167 int vprintk_emit(int facility, int level,
168 		 const struct dev_printk_info *dev_info,
169 		 const char *fmt, va_list args);
170 
171 asmlinkage __printf(1, 0)
172 int vprintk(const char *fmt, va_list args);
173 
174 asmlinkage __printf(1, 2) __cold
175 int printk(const char *fmt, ...);
176 
177 /*
178  * Special printk facility for scheduler/timekeeping use only, _DO_NOT_USE_ !
179  */
180 __printf(1, 2) __cold int printk_deferred(const char *fmt, ...);
181 
182 /*
183  * Please don't use printk_ratelimit(), because it shares ratelimiting state
184  * with all other unrelated printk_ratelimit() callsites.  Instead use
185  * printk_ratelimited() or plain old __ratelimit().
186  */
187 extern int __printk_ratelimit(const char *func);
188 #define printk_ratelimit() __printk_ratelimit(__func__)
189 extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
190 				   unsigned int interval_msec);
191 
192 extern int printk_delay_msec;
193 extern int dmesg_restrict;
194 
195 extern int
196 devkmsg_sysctl_set_loglvl(struct ctl_table *table, int write, void *buf,
197 			  size_t *lenp, loff_t *ppos);
198 
199 extern void wake_up_klogd(void);
200 
201 char *log_buf_addr_get(void);
202 u32 log_buf_len_get(void);
203 void log_buf_vmcoreinfo_setup(void);
204 void __init setup_log_buf(int early);
205 __printf(1, 2) void dump_stack_set_arch_desc(const char *fmt, ...);
206 void dump_stack_print_info(const char *log_lvl);
207 void show_regs_print_info(const char *log_lvl);
208 extern asmlinkage void dump_stack_lvl(const char *log_lvl) __cold;
209 extern asmlinkage void dump_stack(void) __cold;
210 extern void printk_safe_flush(void);
211 extern void printk_safe_flush_on_panic(void);
212 #else
213 static inline __printf(1, 0)
vprintk(const char * s,va_list args)214 int vprintk(const char *s, va_list args)
215 {
216 	return 0;
217 }
218 static inline __printf(1, 2) __cold
printk(const char * s,...)219 int printk(const char *s, ...)
220 {
221 	return 0;
222 }
223 static inline __printf(1, 2) __cold
printk_deferred(const char * s,...)224 int printk_deferred(const char *s, ...)
225 {
226 	return 0;
227 }
printk_ratelimit(void)228 static inline int printk_ratelimit(void)
229 {
230 	return 0;
231 }
printk_timed_ratelimit(unsigned long * caller_jiffies,unsigned int interval_msec)232 static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies,
233 					  unsigned int interval_msec)
234 {
235 	return false;
236 }
237 
wake_up_klogd(void)238 static inline void wake_up_klogd(void)
239 {
240 }
241 
log_buf_addr_get(void)242 static inline char *log_buf_addr_get(void)
243 {
244 	return NULL;
245 }
246 
log_buf_len_get(void)247 static inline u32 log_buf_len_get(void)
248 {
249 	return 0;
250 }
251 
log_buf_vmcoreinfo_setup(void)252 static inline void log_buf_vmcoreinfo_setup(void)
253 {
254 }
255 
setup_log_buf(int early)256 static inline void setup_log_buf(int early)
257 {
258 }
259 
dump_stack_set_arch_desc(const char * fmt,...)260 static inline __printf(1, 2) void dump_stack_set_arch_desc(const char *fmt, ...)
261 {
262 }
263 
dump_stack_print_info(const char * log_lvl)264 static inline void dump_stack_print_info(const char *log_lvl)
265 {
266 }
267 
show_regs_print_info(const char * log_lvl)268 static inline void show_regs_print_info(const char *log_lvl)
269 {
270 }
271 
dump_stack_lvl(const char * log_lvl)272 static inline void dump_stack_lvl(const char *log_lvl)
273 {
274 }
275 
dump_stack(void)276 static inline void dump_stack(void)
277 {
278 }
279 
printk_safe_flush(void)280 static inline void printk_safe_flush(void)
281 {
282 }
283 
printk_safe_flush_on_panic(void)284 static inline void printk_safe_flush_on_panic(void)
285 {
286 }
287 #endif
288 
289 extern int kptr_restrict;
290 
291 /**
292  * pr_fmt - used by the pr_*() macros to generate the printk format string
293  * @fmt: format string passed from a pr_*() macro
294  *
295  * This macro can be used to generate a unified format string for pr_*()
296  * macros. A common use is to prefix all pr_*() messages in a file with a common
297  * string. For example, defining this at the top of a source file:
298  *
299  *        #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
300  *
301  * would prefix all pr_info, pr_emerg... messages in the file with the module
302  * name.
303  */
304 #ifndef pr_fmt
305 #define pr_fmt(fmt) fmt
306 #endif
307 
308 /**
309  * pr_emerg - Print an emergency-level message
310  * @fmt: format string
311  * @...: arguments for the format string
312  *
313  * This macro expands to a printk with KERN_EMERG loglevel. It uses pr_fmt() to
314  * generate the format string.
315  */
316 #define pr_emerg(fmt, ...) \
317 	printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
318 /**
319  * pr_alert - Print an alert-level message
320  * @fmt: format string
321  * @...: arguments for the format string
322  *
323  * This macro expands to a printk with KERN_ALERT loglevel. It uses pr_fmt() to
324  * generate the format string.
325  */
326 #define pr_alert(fmt, ...) \
327 	printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
328 /**
329  * pr_crit - Print a critical-level message
330  * @fmt: format string
331  * @...: arguments for the format string
332  *
333  * This macro expands to a printk with KERN_CRIT loglevel. It uses pr_fmt() to
334  * generate the format string.
335  */
336 #define pr_crit(fmt, ...) \
337 	printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
338 /**
339  * pr_err - Print an error-level message
340  * @fmt: format string
341  * @...: arguments for the format string
342  *
343  * This macro expands to a printk with KERN_ERR loglevel. It uses pr_fmt() to
344  * generate the format string.
345  */
346 #define pr_err(fmt, ...) \
347 	printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
348 /**
349  * pr_warn - Print a warning-level message
350  * @fmt: format string
351  * @...: arguments for the format string
352  *
353  * This macro expands to a printk with KERN_WARNING loglevel. It uses pr_fmt()
354  * to generate the format string.
355  */
356 #define pr_warn(fmt, ...) \
357 	printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
358 /**
359  * pr_notice - Print a notice-level message
360  * @fmt: format string
361  * @...: arguments for the format string
362  *
363  * This macro expands to a printk with KERN_NOTICE loglevel. It uses pr_fmt() to
364  * generate the format string.
365  */
366 #define pr_notice(fmt, ...) \
367 	printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
368 /**
369  * pr_info - Print an info-level message
370  * @fmt: format string
371  * @...: arguments for the format string
372  *
373  * This macro expands to a printk with KERN_INFO loglevel. It uses pr_fmt() to
374  * generate the format string.
375  */
376 #define pr_info(fmt, ...) \
377 	printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
378 
379 /**
380  * pr_cont - Continues a previous log message in the same line.
381  * @fmt: format string
382  * @...: arguments for the format string
383  *
384  * This macro expands to a printk with KERN_CONT loglevel. It should only be
385  * used when continuing a log message with no newline ('\n') enclosed. Otherwise
386  * it defaults back to KERN_DEFAULT loglevel.
387  */
388 #define pr_cont(fmt, ...) \
389 	printk(KERN_CONT fmt, ##__VA_ARGS__)
390 
391 /**
392  * pr_devel - Print a debug-level message conditionally
393  * @fmt: format string
394  * @...: arguments for the format string
395  *
396  * This macro expands to a printk with KERN_DEBUG loglevel if DEBUG is
397  * defined. Otherwise it does nothing.
398  *
399  * It uses pr_fmt() to generate the format string.
400  */
401 #ifdef DEBUG
402 #define pr_devel(fmt, ...) \
403 	printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
404 #else
405 #define pr_devel(fmt, ...) \
406 	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
407 #endif
408 
409 
410 /* If you are writing a driver, please use dev_dbg instead */
411 #if defined(CONFIG_DYNAMIC_DEBUG) || \
412 	(defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
413 #include <linux/dynamic_debug.h>
414 
415 /**
416  * pr_debug - Print a debug-level message conditionally
417  * @fmt: format string
418  * @...: arguments for the format string
419  *
420  * This macro expands to dynamic_pr_debug() if CONFIG_DYNAMIC_DEBUG is
421  * set. Otherwise, if DEBUG is defined, it's equivalent to a printk with
422  * KERN_DEBUG loglevel. If DEBUG is not defined it does nothing.
423  *
424  * It uses pr_fmt() to generate the format string (dynamic_pr_debug() uses
425  * pr_fmt() internally).
426  */
427 #define pr_debug(fmt, ...)			\
428 	dynamic_pr_debug(fmt, ##__VA_ARGS__)
429 #elif defined(DEBUG)
430 #define pr_debug(fmt, ...) \
431 	printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
432 #else
433 #define pr_debug(fmt, ...) \
434 	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
435 #endif
436 
437 /*
438  * Print a one-time message (analogous to WARN_ONCE() et al):
439  */
440 
441 #ifdef CONFIG_PRINTK
442 #define printk_once(fmt, ...)					\
443 ({								\
444 	static bool __section(".data.once") __print_once;	\
445 	bool __ret_print_once = !__print_once;			\
446 								\
447 	if (!__print_once) {					\
448 		__print_once = true;				\
449 		printk(fmt, ##__VA_ARGS__);			\
450 	}							\
451 	unlikely(__ret_print_once);				\
452 })
453 #define printk_deferred_once(fmt, ...)				\
454 ({								\
455 	static bool __section(".data.once") __print_once;	\
456 	bool __ret_print_once = !__print_once;			\
457 								\
458 	if (!__print_once) {					\
459 		__print_once = true;				\
460 		printk_deferred(fmt, ##__VA_ARGS__);		\
461 	}							\
462 	unlikely(__ret_print_once);				\
463 })
464 #else
465 #define printk_once(fmt, ...)					\
466 	no_printk(fmt, ##__VA_ARGS__)
467 #define printk_deferred_once(fmt, ...)				\
468 	no_printk(fmt, ##__VA_ARGS__)
469 #endif
470 
471 #define pr_emerg_once(fmt, ...)					\
472 	printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
473 #define pr_alert_once(fmt, ...)					\
474 	printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
475 #define pr_crit_once(fmt, ...)					\
476 	printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
477 #define pr_err_once(fmt, ...)					\
478 	printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
479 #define pr_warn_once(fmt, ...)					\
480 	printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
481 #define pr_notice_once(fmt, ...)				\
482 	printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
483 #define pr_info_once(fmt, ...)					\
484 	printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
485 /* no pr_cont_once, don't do that... */
486 
487 #if defined(DEBUG)
488 #define pr_devel_once(fmt, ...)					\
489 	printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
490 #else
491 #define pr_devel_once(fmt, ...)					\
492 	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
493 #endif
494 
495 /* If you are writing a driver, please use dev_dbg instead */
496 #if defined(DEBUG)
497 #define pr_debug_once(fmt, ...)					\
498 	printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
499 #else
500 #define pr_debug_once(fmt, ...)					\
501 	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
502 #endif
503 
504 /*
505  * ratelimited messages with local ratelimit_state,
506  * no local ratelimit_state used in the !PRINTK case
507  */
508 #ifdef CONFIG_PRINTK
509 #define printk_ratelimited(fmt, ...)					\
510 ({									\
511 	static DEFINE_RATELIMIT_STATE(_rs,				\
512 				      DEFAULT_RATELIMIT_INTERVAL,	\
513 				      DEFAULT_RATELIMIT_BURST);		\
514 									\
515 	if (__ratelimit(&_rs))						\
516 		printk(fmt, ##__VA_ARGS__);				\
517 })
518 #else
519 #define printk_ratelimited(fmt, ...)					\
520 	no_printk(fmt, ##__VA_ARGS__)
521 #endif
522 
523 #define pr_emerg_ratelimited(fmt, ...)					\
524 	printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
525 #define pr_alert_ratelimited(fmt, ...)					\
526 	printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
527 #define pr_crit_ratelimited(fmt, ...)					\
528 	printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
529 #define pr_err_ratelimited(fmt, ...)					\
530 	printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
531 #define pr_warn_ratelimited(fmt, ...)					\
532 	printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
533 #define pr_notice_ratelimited(fmt, ...)					\
534 	printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
535 #define pr_info_ratelimited(fmt, ...)					\
536 	printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
537 /* no pr_cont_ratelimited, don't do that... */
538 
539 #if defined(DEBUG)
540 #define pr_devel_ratelimited(fmt, ...)					\
541 	printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
542 #else
543 #define pr_devel_ratelimited(fmt, ...)					\
544 	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
545 #endif
546 
547 /* If you are writing a driver, please use dev_dbg instead */
548 #if defined(CONFIG_DYNAMIC_DEBUG) || \
549 	(defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
550 /* descriptor check is first to prevent flooding with "callbacks suppressed" */
551 #define pr_debug_ratelimited(fmt, ...)					\
552 do {									\
553 	static DEFINE_RATELIMIT_STATE(_rs,				\
554 				      DEFAULT_RATELIMIT_INTERVAL,	\
555 				      DEFAULT_RATELIMIT_BURST);		\
556 	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, pr_fmt(fmt));		\
557 	if (DYNAMIC_DEBUG_BRANCH(descriptor) &&				\
558 	    __ratelimit(&_rs))						\
559 		__dynamic_pr_debug(&descriptor, pr_fmt(fmt), ##__VA_ARGS__);	\
560 } while (0)
561 #elif defined(DEBUG)
562 #define pr_debug_ratelimited(fmt, ...)					\
563 	printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
564 #else
565 #define pr_debug_ratelimited(fmt, ...) \
566 	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
567 #endif
568 
569 extern const struct file_operations kmsg_fops;
570 
571 enum {
572 	DUMP_PREFIX_NONE,
573 	DUMP_PREFIX_ADDRESS,
574 	DUMP_PREFIX_OFFSET
575 };
576 extern int hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
577 			      int groupsize, char *linebuf, size_t linebuflen,
578 			      bool ascii);
579 #ifdef CONFIG_PRINTK
580 extern void print_hex_dump(const char *level, const char *prefix_str,
581 			   int prefix_type, int rowsize, int groupsize,
582 			   const void *buf, size_t len, bool ascii);
583 #else
print_hex_dump(const char * level,const char * prefix_str,int prefix_type,int rowsize,int groupsize,const void * buf,size_t len,bool ascii)584 static inline void print_hex_dump(const char *level, const char *prefix_str,
585 				  int prefix_type, int rowsize, int groupsize,
586 				  const void *buf, size_t len, bool ascii)
587 {
588 }
print_hex_dump_bytes(const char * prefix_str,int prefix_type,const void * buf,size_t len)589 static inline void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
590 					const void *buf, size_t len)
591 {
592 }
593 
594 #endif
595 
596 #if defined(CONFIG_DYNAMIC_DEBUG) || \
597 	(defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
598 #define print_hex_dump_debug(prefix_str, prefix_type, rowsize,	\
599 			     groupsize, buf, len, ascii)	\
600 	dynamic_hex_dump(prefix_str, prefix_type, rowsize,	\
601 			 groupsize, buf, len, ascii)
602 #elif defined(DEBUG)
603 #define print_hex_dump_debug(prefix_str, prefix_type, rowsize,		\
604 			     groupsize, buf, len, ascii)		\
605 	print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize,	\
606 		       groupsize, buf, len, ascii)
607 #else
print_hex_dump_debug(const char * prefix_str,int prefix_type,int rowsize,int groupsize,const void * buf,size_t len,bool ascii)608 static inline void print_hex_dump_debug(const char *prefix_str, int prefix_type,
609 					int rowsize, int groupsize,
610 					const void *buf, size_t len, bool ascii)
611 {
612 }
613 #endif
614 
615 /**
616  * print_hex_dump_bytes - shorthand form of print_hex_dump() with default params
617  * @prefix_str: string to prefix each line with;
618  *  caller supplies trailing spaces for alignment if desired
619  * @prefix_type: controls whether prefix of an offset, address, or none
620  *  is printed (%DUMP_PREFIX_OFFSET, %DUMP_PREFIX_ADDRESS, %DUMP_PREFIX_NONE)
621  * @buf: data blob to dump
622  * @len: number of bytes in the @buf
623  *
624  * Calls print_hex_dump(), with log level of KERN_DEBUG,
625  * rowsize of 16, groupsize of 1, and ASCII output included.
626  */
627 #define print_hex_dump_bytes(prefix_str, prefix_type, buf, len)	\
628 	print_hex_dump_debug(prefix_str, prefix_type, 16, 1, buf, len, true)
629 
630 #ifdef CONFIG_PRINTK
631 extern void __printk_safe_enter(void);
632 extern void __printk_safe_exit(void);
633 /*
634  * The printk_deferred_enter/exit macros are available only as a hack for
635  * some code paths that need to defer all printk console printing. Interrupts
636  * must be disabled for the deferred duration.
637  */
638 #define printk_deferred_enter __printk_safe_enter
639 #define printk_deferred_exit __printk_safe_exit
640 #else
printk_deferred_enter(void)641 static inline void printk_deferred_enter(void)
642 {
643 }
printk_deferred_exit(void)644 static inline void printk_deferred_exit(void)
645 {
646 }
647 #endif
648 
649 #endif
650