lkml.org 
[lkml]   [2011]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 25/26] dynamic_debug: add pr_fmt_dbg() for dynamic_pr_debug
Date
From: Jim Cromie <jim.cromie@gmail.com>

dynamic_pr_debug can add module, function, file, and line selectively,
so theres no need to also add them via pr_fmt. Moreover, using pr_fmt
to add KBUILD_MODNAME ": ", as is typical for pr_info etc, causes
pr_debug() to double-print those fields added by the flag-settings.

So define pr_fmt_dbg(fmt), and use it in dynamic_pr_debug(). This lets
users use pr_fmt() for pr_info and friends, without affecting pr_debug().
For non-dynamic-debug builds, pr_fmt_dbg() uses pr_fmt(), preserving
existing print info.

It also allows incrementally converting modules by dropping NAME
from pr_debug(NAME ": ...") and adding it once via pr_fmt_dbg().
Later, if/when module-name is added to dynamic-debug's default,
modules can drop their pr_fmt_dbg()s, and get it via header defns
for both non- and dynamic-debug builds.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
include/linux/dynamic_debug.h | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index 5622e04..722a4f5 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -69,11 +69,15 @@ extern int __dynamic_netdev_dbg(struct _ddebug *descriptor,
.flags = _DPRINTK_FLAGS_DEFAULT, \
}

+#ifndef pr_fmt_dbg
+#define pr_fmt_dbg(fmt) fmt
+#endif
+
#define dynamic_pr_debug(fmt, ...) \
do { \
DECLARE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT)) \
- __dynamic_pr_debug(&descriptor, pr_fmt(fmt), \
+ __dynamic_pr_debug(&descriptor, pr_fmt_dbg(fmt),\
##__VA_ARGS__); \
} while (0)

@@ -100,10 +104,16 @@ static inline int ddebug_remove_module(const char *mod)
return 0;
}

+#ifndef pr_fmt_dbg
+#define pr_fmt_dbg(fmt) pr_fmt(fmt)
+#endif
+
#define dynamic_pr_debug(fmt, ...) \
- do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0)
+ do { if (0) printk(KERN_DEBUG pr_fmt_dbg(fmt), ##__VA_ARGS__); \
+ } while (0)
#define dynamic_dev_dbg(dev, fmt, ...) \
- do { if (0) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); } while (0)
+ do { if (0) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \
+ } while (0)
#endif

#endif
--
1.7.4.4


\
 
 \ /
  Last update: 2011-09-21 23:59    [W:0.281 / U:12.608 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site