From: Joe Perches <joe@perches.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 05/14] kernel.h: printk neatening
Date: Wed, 16 Dec 2009 00:09:04 -0800 [thread overview]
Message-ID: <86bb4429e867e5b4de4a07752883ebfa4fdec074.1260949674.git.joe@perches.com> (raw)
In-Reply-To: <cover.1260949674.git.joe@perches.com>
Make a few printk elements a bit more consistent
Remove trailing backslashes from static inline prototype
Use fmt and ##__VA_ARGS__ in printk_once
Make statement expressions multiline
Use tabs for #define foo bar
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/kernel.h | 90 ++++++++++++++++++++++++++++--------------------
1 files changed, 53 insertions(+), 37 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 75e7439..f7144b1 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -385,10 +385,10 @@ extern const char linux_proc_banner[];
extern int console_printk[];
-#define console_loglevel (console_printk[0])
-#define default_message_loglevel (console_printk[1])
-#define minimum_console_loglevel (console_printk[2])
-#define default_console_loglevel (console_printk[3])
+#define console_loglevel (console_printk[0])
+#define default_message_loglevel (console_printk[1])
+#define minimum_console_loglevel (console_printk[2])
+#define default_console_loglevel (console_printk[3])
/*
* FW_BUG
@@ -430,12 +430,13 @@ extern int printk_delay_msec;
/*
* Print a one-time message (analogous to WARN_ONCE() et al):
*/
-#define printk_once(x...) ({ \
+#define printk_once(fmt, ...) \
+({ \
static bool __print_once; \
\
if (!__print_once) { \
__print_once = true; \
- printk(x); \
+ printk(fmt, ##__VA_ARGS__); \
} \
})
@@ -448,12 +449,14 @@ static inline int printk(const char *s, ...)
__attribute__ ((format (printf, 1, 2)));
static inline int __cold printk(const char *s, ...) { return 0; }
static inline int printk_ratelimit(void) { return 0; }
-static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \
- unsigned int interval_msec) \
- { return false; }
+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: */
-#define printk_once(x...) printk(x)
+#define printk_once(fmt, ...) printk(fmt, ##__VA_ARGS__)
static inline void log_buf_kexec_setup(void)
{
@@ -506,43 +509,51 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
#define pr_fmt(fmt) fmt
#endif
-#define pr_emerg(fmt, ...) \
+#define pr_emerg(fmt, ...) \
printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_alert(fmt, ...) \
+#define pr_alert(fmt, ...) \
printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_crit(fmt, ...) \
+#define pr_crit(fmt, ...) \
printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_err(fmt, ...) \
+#define pr_err(fmt, ...) \
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_warning(fmt, ...) \
+#define pr_warning(fmt, ...) \
printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_notice(fmt, ...) \
+#define pr_notice(fmt, ...) \
printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_info(fmt, ...) \
+#define pr_info(fmt, ...) \
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_cont(fmt, ...) \
+#define pr_cont(fmt, ...) \
printk(KERN_CONT fmt, ##__VA_ARGS__)
/* pr_devel() should produce zero code unless DEBUG is defined */
#ifdef DEBUG
-#define pr_devel(fmt, ...) \
+#define pr_devel(fmt, ...) \
printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#else
-#define pr_devel(fmt, ...) \
- ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
+#define pr_devel(fmt, ...) \
+({ \
+ if (0) \
+ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
+ 0; \
+})
#endif
/* If you are writing a driver, please use dev_dbg instead */
#if defined(DEBUG)
-#define pr_debug(fmt, ...) \
+#define pr_debug(fmt, ...) \
printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#elif defined(CONFIG_DYNAMIC_DEBUG)
/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
-#define pr_debug(fmt, ...) \
+#define pr_debug(fmt, ...) \
dynamic_pr_debug(fmt, ##__VA_ARGS__)
#else
-#define pr_debug(fmt, ...) \
- ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
+#define pr_debug(fmt, ...) \
+({ \
+ if (0) \
+ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
+ 0; \
+})
#endif
/*
@@ -550,7 +561,8 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
* no local ratelimit_state used in the !PRINTK case
*/
#ifdef CONFIG_PRINTK
-#define printk_ratelimited(fmt, ...) ({ \
+#define printk_ratelimited(fmt, ...) \
+({ \
static struct ratelimit_state _rs = { \
.interval = DEFAULT_RATELIMIT_INTERVAL, \
.burst = DEFAULT_RATELIMIT_BURST, \
@@ -564,29 +576,33 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
#define printk_ratelimited printk
#endif
-#define pr_emerg_ratelimited(fmt, ...) \
+#define pr_emerg_ratelimited(fmt, ...) \
printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_alert_ratelimited(fmt, ...) \
+#define pr_alert_ratelimited(fmt, ...) \
printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_crit_ratelimited(fmt, ...) \
+#define pr_crit_ratelimited(fmt, ...) \
printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_err_ratelimited(fmt, ...) \
+#define pr_err_ratelimited(fmt, ...) \
printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_warning_ratelimited(fmt, ...) \
+#define pr_warning_ratelimited(fmt, ...) \
printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_notice_ratelimited(fmt, ...) \
+#define pr_notice_ratelimited(fmt, ...) \
printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_info_ratelimited(fmt, ...) \
+#define pr_info_ratelimited(fmt, ...) \
printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
/* no pr_cont_ratelimited, don't do that... */
/* If you are writing a driver, please use dev_dbg instead */
#if defined(DEBUG)
-#define pr_debug_ratelimited(fmt, ...) \
+#define pr_debug_ratelimited(fmt, ...) \
printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#else
-#define pr_debug_ratelimited(fmt, ...) \
- ({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \
- ##__VA_ARGS__); 0; })
+#define pr_debug_ratelimited(fmt, ...) \
+({ \
+ if (0) \
+ printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \
+ ##__VA_ARGS__); \
+ 0; \
+})
#endif
/*
--
1.6.6.rc0.57.gad7a
next prev parent reply other threads:[~2009-12-16 8:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
2009-12-16 8:09 ` [PATCH 01/14] kernel.h: Consolidate console and logging functions and defines Joe Perches
2009-12-16 8:09 ` [PATCH 02/14] kernel.h: Checkpatch cleaning Joe Perches
2009-12-16 8:09 ` [PATCH 03/14] kernel.h: ARRAY_SIZE neatening Joe Perches
2009-12-16 8:09 ` [PATCH 04/14] kernel.h: Add argument names to strtoXX, Xscanf prototypes Joe Perches
2009-12-16 8:09 ` Joe Perches [this message]
2009-12-16 8:09 ` [PATCH 06/14] drivers/firmware/iscsi_ibft.c: Use %pI4 to print netmask Joe Perches
2009-12-16 8:09 ` [PATCH 07/14] kernel.h: Move NIPQUAD and NIPQUAD_FMT to in.h Joe Perches
2009-12-16 8:09 ` [PATCH 08/14] kernel.h: Group math and limits functions, indent function args Joe Perches
2009-12-16 8:09 ` [PATCH 09/14] kernel.h: Don't use NORET_AND just use noreturn, instead Joe Perches
2009-12-16 8:09 ` [PATCH 10/14] kernel.h: Remove ATTRIB_NORET, use __attribute__((noreturn)) Joe Perches
2009-12-16 8:09 ` [PATCH 11/14] kernel.h: Remove uses of NORET_TYPE Joe Perches
2009-12-16 8:09 ` [PATCH 12/14] kernel.h: Add pr_<level>_once Joe Perches
2009-12-16 8:09 ` [PATCH 13/14] kernel.h: Kernel address utility aggregation and other neatening Joe Perches
2009-12-16 8:09 ` [PATCH 14/14] kernel/exit.c and kernel/panic.c: Remove unused NORET_TYPE Joe Perches
2009-12-16 18:51 ` Peter Zijlstra
2009-12-16 18:53 ` Peter Zijlstra
2009-12-17 20:52 ` [PATCH 00/14] kernel.h cleanups Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86bb4429e867e5b4de4a07752883ebfa4fdec074.1260949674.git.joe@perches.com \
--to=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®