aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2011-01-12 19:59:45 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-13 11:03:09 -0500
commit5264f2f75d8678f3e9683042a4639baa5884bda9 (patch)
tree1c50abbe3179ece00cbb14623d7724602fa17f8c
parent7d1e91aeb317c3c747369d8594fc1b742c265a07 (diff)
include/linux/printk.h: use and neaten no_printk
- Move no_printk above first CONFIG_PRINTK block so it can be used by printk_once. - Convert statement expression if (0) printk macros to no_printk. - Convert printk_once(x...) to more normally used (fmt, ...) fmt, ##__VA_ARGS__. - Standardize __attribute__ use. - Expand single line inline functions. - Remove space before pointer. Signed-off-by: Joe Perches <joe@perches.com> Cc: Matt Mackall <mpm@selenic.com> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/printk.h75
1 files changed, 43 insertions, 32 deletions
diff --git a/include/linux/printk.h b/include/linux/printk.h
index b71131116878..4788c2887e65 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -76,11 +76,27 @@ struct va_format {
76 */ 76 */
77#define HW_ERR "[Hardware Error]: " 77#define HW_ERR "[Hardware Error]: "
78 78
79/*
80 * Dummy printk for disabled debugging statements to use whilst maintaining
81 * gcc's format and side-effect checking.
82 */
83static inline __attribute__ ((format (printf, 1, 2)))
84int no_printk(const char *fmt, ...)
85{
86 return 0;
87}
88
89extern asmlinkage __attribute__ ((format (printf, 1, 2)))
90void early_printk(const char *fmt, ...);
91
92extern int printk_needs_cpu(int cpu);
93extern void printk_tick(void);
94
79#ifdef CONFIG_PRINTK 95#ifdef CONFIG_PRINTK
80asmlinkage int vprintk(const char *fmt, va_list args) 96asmlinkage __attribute__ ((format (printf, 1, 0)))
81 __attribute__ ((format (printf, 1, 0))); 97int vprintk(const char *fmt, va_list args);
82asmlinkage int printk(const char * fmt, ...) 98asmlinkage __attribute__ ((format (printf, 1, 2))) __cold
83 __attribute__ ((format (printf, 1, 2))) __cold; 99int printk(const char *fmt, ...);
84 100
85/* 101/*
86 * Please don't use printk_ratelimit(), because it shares ratelimiting state 102 * Please don't use printk_ratelimit(), because it shares ratelimiting state
@@ -110,38 +126,34 @@ extern int kptr_restrict;
110 126
111void log_buf_kexec_setup(void); 127void log_buf_kexec_setup(void);
112#else 128#else
113static inline int vprintk(const char *s, va_list args) 129static inline __attribute__ ((format (printf, 1, 0)))
114 __attribute__ ((format (printf, 1, 0))); 130int vprintk(const char *s, va_list args)
115static inline int vprintk(const char *s, va_list args) { return 0; } 131{
116static inline int printk(const char *s, ...) 132 return 0;
117 __attribute__ ((format (printf, 1, 2))); 133}
118static inline int __cold printk(const char *s, ...) { return 0; } 134static inline __attribute__ ((format (printf, 1, 2))) __cold
119static inline int printk_ratelimit(void) { return 0; } 135int printk(const char *s, ...)
120static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ 136{
121 unsigned int interval_msec) \ 137 return 0;
122 { return false; } 138}
139static inline int printk_ratelimit(void)
140{
141 return 0;
142}
143static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies,
144 unsigned int interval_msec)
145{
146 return false;
147}
123 148
124/* No effect, but we still get type checking even in the !PRINTK case: */ 149/* No effect, but we still get type checking even in the !PRINTK case: */
125#define printk_once(x...) printk(x) 150#define printk_once(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
126 151
127static inline void log_buf_kexec_setup(void) 152static inline void log_buf_kexec_setup(void)
128{ 153{
129} 154}
130#endif 155#endif
131 156
132/*
133 * Dummy printk for disabled debugging statements to use whilst maintaining
134 * gcc's format and side-effect checking.
135 */
136static inline __attribute__ ((format (printf, 1, 2)))
137int no_printk(const char *s, ...) { return 0; }
138
139extern int printk_needs_cpu(int cpu);
140extern void printk_tick(void);
141
142extern void asmlinkage __attribute__((format(printf, 1, 2)))
143 early_printk(const char *fmt, ...);
144
145extern void dump_stack(void) __cold; 157extern void dump_stack(void) __cold;
146 158
147enum { 159enum {
@@ -186,7 +198,7 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
186 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) 198 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
187#else 199#else
188#define pr_devel(fmt, ...) \ 200#define pr_devel(fmt, ...) \
189 ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) 201 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
190#endif 202#endif
191 203
192/* If you are writing a driver, please use dev_dbg instead */ 204/* If you are writing a driver, please use dev_dbg instead */
@@ -199,7 +211,7 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
199 dynamic_pr_debug(fmt, ##__VA_ARGS__) 211 dynamic_pr_debug(fmt, ##__VA_ARGS__)
200#else 212#else
201#define pr_debug(fmt, ...) \ 213#define pr_debug(fmt, ...) \
202 ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) 214 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
203#endif 215#endif
204 216
205/* 217/*
@@ -242,8 +254,7 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
242 printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) 254 printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
243#else 255#else
244#define pr_debug_ratelimited(fmt, ...) \ 256#define pr_debug_ratelimited(fmt, ...) \
245 ({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \ 257 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
246 ##__VA_ARGS__); 0; })
247#endif 258#endif
248 259
249#endif 260#endif