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