From: Michael Ellerman <michael@ellerman.id.au>
To: <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@osdl.org>, <gnb@sgi.com>, <jbaron@redhat.com>
Subject: [PATCH] Resurrect old pr_debug() semantics as pr_devel()
Date: Mon, 6 Apr 2009 14:30:03 +1000 (EST) [thread overview]
Message-ID: <4a5c6b4cd1b77ebe6d60362bc982f4dc81cba85e.1238992196.git.michael@ellerman.id.au> (raw)
pr_debug() used to produce zero code unless DEBUG was #defined. This is
now no longer the case in practice[1].
There are places where it's useful to have debugging printks, but we
don't want them to generate any code in production kernels.
So add a new macro, pr_devel(), for _devel_opment, to provide the old
semantics, ie. if the programmer doesn't explicitly enable debugging,
no code is produced.
[1]: You can turn CONFIG_DYNAMIC_DEBUG off, but it's enabled in at least
one distro kernel, so it's not really a solution.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
include/linux/kernel.h | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d9e75ec..883cd44 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -377,6 +377,15 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
#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, ...) \
+ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
+#else
+#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, ...) \
--
1.6.1.2
next reply other threads:[~2009-04-06 4:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-06 4:30 Michael Ellerman [this message]
2009-04-06 21:24 ` Jason Baron
2009-04-07 2:08 ` Michael Ellerman
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=4a5c6b4cd1b77ebe6d60362bc982f4dc81cba85e.1238992196.git.michael@ellerman.id.au \
--to=michael@ellerman.id.au \
--cc=akpm@osdl.org \
--cc=gnb@sgi.com \
--cc=jbaron@redhat.com \
--cc=linux-kernel@vger.kernel.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®