printk.h 18 KB

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