xref: /openbmc/u-boot/include/linux/printk.h (revision b44b30260ffa3dc82f4bb98b022483bb09e95353)
1*b44b3026SMasahiro Yamada #ifndef __KERNEL_PRINTK__
2*b44b3026SMasahiro Yamada #define __KERNEL_PRINTK__
3*b44b3026SMasahiro Yamada 
4*b44b3026SMasahiro Yamada #include <stdio.h>
5*b44b3026SMasahiro Yamada #include <linux/compiler.h>
6*b44b3026SMasahiro Yamada 
7*b44b3026SMasahiro Yamada #define KERN_EMERG
8*b44b3026SMasahiro Yamada #define KERN_ALERT
9*b44b3026SMasahiro Yamada #define KERN_CRIT
10*b44b3026SMasahiro Yamada #define KERN_ERR
11*b44b3026SMasahiro Yamada #define KERN_WARNING
12*b44b3026SMasahiro Yamada #define KERN_NOTICE
13*b44b3026SMasahiro Yamada #define KERN_INFO
14*b44b3026SMasahiro Yamada #define KERN_DEBUG
15*b44b3026SMasahiro Yamada #define KERN_CONT
16*b44b3026SMasahiro Yamada 
17*b44b3026SMasahiro Yamada #define printk(fmt, ...) \
18*b44b3026SMasahiro Yamada 	printf(fmt, ##__VA_ARGS__)
19*b44b3026SMasahiro Yamada 
20*b44b3026SMasahiro Yamada /*
21*b44b3026SMasahiro Yamada  * Dummy printk for disabled debugging statements to use whilst maintaining
22*b44b3026SMasahiro Yamada  * gcc's format checking.
23*b44b3026SMasahiro Yamada  */
24*b44b3026SMasahiro Yamada #define no_printk(fmt, ...)				\
25*b44b3026SMasahiro Yamada ({							\
26*b44b3026SMasahiro Yamada 	if (0)						\
27*b44b3026SMasahiro Yamada 		printk(fmt, ##__VA_ARGS__);		\
28*b44b3026SMasahiro Yamada 	0;						\
29*b44b3026SMasahiro Yamada })
30*b44b3026SMasahiro Yamada 
31*b44b3026SMasahiro Yamada #define __printk(level, fmt, ...)					\
32*b44b3026SMasahiro Yamada ({									\
33*b44b3026SMasahiro Yamada 	level < CONFIG_LOGLEVEL ? printk(fmt, ##__VA_ARGS__) : 0;	\
34*b44b3026SMasahiro Yamada })
35*b44b3026SMasahiro Yamada 
36*b44b3026SMasahiro Yamada #ifndef pr_fmt
37*b44b3026SMasahiro Yamada #define pr_fmt(fmt) fmt
38*b44b3026SMasahiro Yamada #endif
39*b44b3026SMasahiro Yamada 
40*b44b3026SMasahiro Yamada #define pr_emerg(fmt, ...) \
41*b44b3026SMasahiro Yamada 	__printk(0, pr_fmt(fmt), ##__VA_ARGS__)
42*b44b3026SMasahiro Yamada #define pr_alert(fmt, ...) \
43*b44b3026SMasahiro Yamada 	__printk(1, pr_fmt(fmt), ##__VA_ARGS__)
44*b44b3026SMasahiro Yamada #define pr_crit(fmt, ...) \
45*b44b3026SMasahiro Yamada 	__printk(2, pr_fmt(fmt), ##__VA_ARGS__)
46*b44b3026SMasahiro Yamada #define pr_err(fmt, ...) \
47*b44b3026SMasahiro Yamada 	__printk(3, pr_fmt(fmt), ##__VA_ARGS__)
48*b44b3026SMasahiro Yamada #define pr_warning(fmt, ...) \
49*b44b3026SMasahiro Yamada 	__printk(4, pr_fmt(fmt), ##__VA_ARGS__)
50*b44b3026SMasahiro Yamada #define pr_warn pr_warning
51*b44b3026SMasahiro Yamada #define pr_notice(fmt, ...) \
52*b44b3026SMasahiro Yamada 	__printk(5, pr_fmt(fmt), ##__VA_ARGS__)
53*b44b3026SMasahiro Yamada #define pr_info(fmt, ...) \
54*b44b3026SMasahiro Yamada 	__printk(6, pr_fmt(fmt), ##__VA_ARGS__)
55*b44b3026SMasahiro Yamada 
56*b44b3026SMasahiro Yamada #define pr_cont(fmt, ...) \
57*b44b3026SMasahiro Yamada 	printk(fmt, ##__VA_ARGS__)
58*b44b3026SMasahiro Yamada 
59*b44b3026SMasahiro Yamada /* pr_devel() should produce zero code unless DEBUG is defined */
60*b44b3026SMasahiro Yamada #ifdef DEBUG
61*b44b3026SMasahiro Yamada #define pr_devel(fmt, ...) \
62*b44b3026SMasahiro Yamada 	__printk(7, pr_fmt(fmt), ##__VA_ARGS__)
63*b44b3026SMasahiro Yamada #else
64*b44b3026SMasahiro Yamada #define pr_devel(fmt, ...) \
65*b44b3026SMasahiro Yamada 	no_printk(pr_fmt(fmt), ##__VA_ARGS__)
66*b44b3026SMasahiro Yamada #endif
67*b44b3026SMasahiro Yamada 
68*b44b3026SMasahiro Yamada #ifdef DEBUG
69*b44b3026SMasahiro Yamada #define pr_debug(fmt, ...) \
70*b44b3026SMasahiro Yamada 	__printk(7, pr_fmt(fmt), ##__VA_ARGS__)
71*b44b3026SMasahiro Yamada #else
72*b44b3026SMasahiro Yamada #define pr_debug(fmt, ...) \
73*b44b3026SMasahiro Yamada 	no_printk(pr_fmt(fmt), ##__VA_ARGS__)
74*b44b3026SMasahiro Yamada #endif
75*b44b3026SMasahiro Yamada 
76*b44b3026SMasahiro Yamada #define printk_once(fmt, ...) \
77*b44b3026SMasahiro Yamada 	printk(fmt, ##__VA_ARGS__)
78*b44b3026SMasahiro Yamada 
79*b44b3026SMasahiro Yamada #endif
80