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