Commit 5264f2f7 authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

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: default avatarJoe Perches <joe@perches.com>
Cc: Matt Mackall <mpm@selenic.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7d1e91ae
...@@ -76,11 +76,27 @@ struct va_format { ...@@ -76,11 +76,27 @@ struct va_format {
*/ */
#define HW_ERR "[Hardware Error]: " #define HW_ERR "[Hardware Error]: "
/*
* Dummy printk for disabled debugging statements to use whilst maintaining
* gcc's format and side-effect checking.
*/
static inline __attribute__ ((format (printf, 1, 2)))
int no_printk(const char *fmt, ...)
{
return 0;
}
extern asmlinkage __attribute__ ((format (printf, 1, 2)))
void early_printk(const char *fmt, ...);
extern int printk_needs_cpu(int cpu);
extern void printk_tick(void);
#ifdef CONFIG_PRINTK #ifdef CONFIG_PRINTK
asmlinkage int vprintk(const char *fmt, va_list args) asmlinkage __attribute__ ((format (printf, 1, 0)))
__attribute__ ((format (printf, 1, 0))); int vprintk(const char *fmt, va_list args);
asmlinkage int printk(const char * fmt, ...) asmlinkage __attribute__ ((format (printf, 1, 2))) __cold
__attribute__ ((format (printf, 1, 2))) __cold; int printk(const char *fmt, ...);
/* /*
* Please don't use printk_ratelimit(), because it shares ratelimiting state * Please don't use printk_ratelimit(), because it shares ratelimiting state
...@@ -110,38 +126,34 @@ extern int kptr_restrict; ...@@ -110,38 +126,34 @@ extern int kptr_restrict;
void log_buf_kexec_setup(void); void log_buf_kexec_setup(void);
#else #else
static inline int vprintk(const char *s, va_list args) static inline __attribute__ ((format (printf, 1, 0)))
__attribute__ ((format (printf, 1, 0))); int vprintk(const char *s, va_list args)
static inline int vprintk(const char *s, va_list args) { return 0; } {
static inline int printk(const char *s, ...) return 0;
__attribute__ ((format (printf, 1, 2))); }
static inline int __cold printk(const char *s, ...) { return 0; } static inline __attribute__ ((format (printf, 1, 2))) __cold
static inline int printk_ratelimit(void) { return 0; } int printk(const char *s, ...)
static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ {
unsigned int interval_msec) \ return 0;
{ return false; } }
static inline int printk_ratelimit(void)
{
return 0;
}
static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies,
unsigned int interval_msec)
{
return false;
}
/* No effect, but we still get type checking even in the !PRINTK case: */ /* No effect, but we still get type checking even in the !PRINTK case: */
#define printk_once(x...) printk(x) #define printk_once(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
static inline void log_buf_kexec_setup(void) static inline void log_buf_kexec_setup(void)
{ {
} }
#endif #endif
/*
* Dummy printk for disabled debugging statements to use whilst maintaining
* gcc's format and side-effect checking.
*/
static inline __attribute__ ((format (printf, 1, 2)))
int no_printk(const char *s, ...) { return 0; }
extern int printk_needs_cpu(int cpu);
extern void printk_tick(void);
extern void asmlinkage __attribute__((format(printf, 1, 2)))
early_printk(const char *fmt, ...);
extern void dump_stack(void) __cold; extern void dump_stack(void) __cold;
enum { enum {
...@@ -186,7 +198,7 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type, ...@@ -186,7 +198,7 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#else #else
#define pr_devel(fmt, ...) \ #define pr_devel(fmt, ...) \
({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#endif #endif
/* If you are writing a driver, please use dev_dbg instead */ /* 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,7 +211,7 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
dynamic_pr_debug(fmt, ##__VA_ARGS__) dynamic_pr_debug(fmt, ##__VA_ARGS__)
#else #else
#define pr_debug(fmt, ...) \ #define pr_debug(fmt, ...) \
({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#endif #endif
/* /*
...@@ -242,8 +254,7 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type, ...@@ -242,8 +254,7 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#else #else
#define pr_debug_ratelimited(fmt, ...) \ #define pr_debug_ratelimited(fmt, ...) \
({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \ no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
##__VA_ARGS__); 0; })
#endif #endif
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment