aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2011-08-11 14:36:21 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-08-22 21:23:04 -0400
commitcbc4663552ee476f57933920d782222d94878e7e (patch)
tree7fa60ec28e53114d239137b7cea65c66da15040c
parent25b8a88c10770e8c3f14bf2e222691dc6e79de78 (diff)
dynamic_debug: Add __dynamic_dev_dbg
Unlike dynamic_pr_debug, dynamic uses of dev_dbg can not currently add task_pid/KBUILD_MODNAME/__func__/__LINE__ to selected debug output. Add a new function similar to dynamic_pr_debug to optionally emit these prefixes. Cc: Aloisio Almeida <aloisio.almeida@openbossa.org> Noticed-by: Aloisio Almeida <aloisio.almeida@openbossa.org> Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Jason Baron <jbaron@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/base/core.c5
-rw-r--r--include/linux/device.h5
-rw-r--r--include/linux/dynamic_debug.h10
-rw-r--r--lib/dynamic_debug.c38
4 files changed, 54 insertions, 4 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index bc8729d603a7..82c865452c70 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1764,8 +1764,8 @@ void device_shutdown(void)
1764 1764
1765#ifdef CONFIG_PRINTK 1765#ifdef CONFIG_PRINTK
1766 1766
1767static int __dev_printk(const char *level, const struct device *dev, 1767int __dev_printk(const char *level, const struct device *dev,
1768 struct va_format *vaf) 1768 struct va_format *vaf)
1769{ 1769{
1770 if (!dev) 1770 if (!dev)
1771 return printk("%s(NULL device *): %pV", level, vaf); 1771 return printk("%s(NULL device *): %pV", level, vaf);
@@ -1773,6 +1773,7 @@ static int __dev_printk(const char *level, const struct device *dev,
1773 return printk("%s%s %s: %pV", 1773 return printk("%s%s %s: %pV",
1774 level, dev_driver_string(dev), dev_name(dev), vaf); 1774 level, dev_driver_string(dev), dev_name(dev), vaf);
1775} 1775}
1776EXPORT_SYMBOL(__dev_printk);
1776 1777
1777int dev_printk(const char *level, const struct device *dev, 1778int dev_printk(const char *level, const struct device *dev,
1778 const char *fmt, ...) 1779 const char *fmt, ...)
diff --git a/include/linux/device.h b/include/linux/device.h
index c20dfbfc49b4..4639419522da 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -785,6 +785,8 @@ extern const char *dev_driver_string(const struct device *dev);
785 785
786#ifdef CONFIG_PRINTK 786#ifdef CONFIG_PRINTK
787 787
788extern int __dev_printk(const char *level, const struct device *dev,
789 struct va_format *vaf);
788extern int dev_printk(const char *level, const struct device *dev, 790extern int dev_printk(const char *level, const struct device *dev,
789 const char *fmt, ...) 791 const char *fmt, ...)
790 __attribute__ ((format (printf, 3, 4))); 792 __attribute__ ((format (printf, 3, 4)));
@@ -805,6 +807,9 @@ extern int _dev_info(const struct device *dev, const char *fmt, ...)
805 807
806#else 808#else
807 809
810static inline int __dev_printk(const char *level, const struct device *dev,
811 struct va_format *vaf)
812 { return 0; }
808static inline int dev_printk(const char *level, const struct device *dev, 813static inline int dev_printk(const char *level, const struct device *dev,
809 const char *fmt, ...) 814 const char *fmt, ...)
810 __attribute__ ((format (printf, 3, 4))); 815 __attribute__ ((format (printf, 3, 4)));
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index e747ecd48e1c..bdf15319944e 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -47,6 +47,13 @@ extern int ddebug_remove_module(const char *mod_name);
47extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) 47extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
48 __attribute__ ((format (printf, 2, 3))); 48 __attribute__ ((format (printf, 2, 3)));
49 49
50struct device;
51
52extern int __dynamic_dev_dbg(struct _ddebug *descriptor,
53 const struct device *dev,
54 const char *fmt, ...)
55 __attribute__ ((format (printf, 3, 4)));
56
50#define dynamic_pr_debug(fmt, ...) do { \ 57#define dynamic_pr_debug(fmt, ...) do { \
51 static struct _ddebug descriptor \ 58 static struct _ddebug descriptor \
52 __used \ 59 __used \
@@ -57,7 +64,6 @@ extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
57 __dynamic_pr_debug(&descriptor, pr_fmt(fmt), ##__VA_ARGS__); \ 64 __dynamic_pr_debug(&descriptor, pr_fmt(fmt), ##__VA_ARGS__); \
58 } while (0) 65 } while (0)
59 66
60
61#define dynamic_dev_dbg(dev, fmt, ...) do { \ 67#define dynamic_dev_dbg(dev, fmt, ...) do { \
62 static struct _ddebug descriptor \ 68 static struct _ddebug descriptor \
63 __used \ 69 __used \
@@ -65,7 +71,7 @@ extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
65 { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \ 71 { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \
66 _DPRINTK_FLAGS_DEFAULT }; \ 72 _DPRINTK_FLAGS_DEFAULT }; \
67 if (unlikely(descriptor.enabled)) \ 73 if (unlikely(descriptor.enabled)) \
68 dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ 74 __dynamic_dev_dbg(&descriptor, dev, fmt, ##__VA_ARGS__); \
69 } while (0) 75 } while (0)
70 76
71#else 77#else
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 75ca78f3a8c9..63b6f95ac552 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -30,6 +30,7 @@
30#include <linux/jump_label.h> 30#include <linux/jump_label.h>
31#include <linux/hardirq.h> 31#include <linux/hardirq.h>
32#include <linux/sched.h> 32#include <linux/sched.h>
33#include <linux/device.h>
33 34
34extern struct _ddebug __start___verbose[]; 35extern struct _ddebug __start___verbose[];
35extern struct _ddebug __stop___verbose[]; 36extern struct _ddebug __stop___verbose[];
@@ -456,6 +457,43 @@ int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
456} 457}
457EXPORT_SYMBOL(__dynamic_pr_debug); 458EXPORT_SYMBOL(__dynamic_pr_debug);
458 459
460int __dynamic_dev_dbg(struct _ddebug *descriptor,
461 const struct device *dev, const char *fmt, ...)
462{
463 struct va_format vaf;
464 va_list args;
465 int res;
466
467 BUG_ON(!descriptor);
468 BUG_ON(!fmt);
469
470 va_start(args, fmt);
471
472 vaf.fmt = fmt;
473 vaf.va = &args;
474
475 res = printk(KERN_DEBUG);
476 if (descriptor->flags & _DPRINTK_FLAGS_INCL_TID) {
477 if (in_interrupt())
478 res += printk(KERN_CONT "<intr> ");
479 else
480 res += printk(KERN_CONT "[%d] ", task_pid_vnr(current));
481 }
482 if (descriptor->flags & _DPRINTK_FLAGS_INCL_MODNAME)
483 res += printk(KERN_CONT "%s:", descriptor->modname);
484 if (descriptor->flags & _DPRINTK_FLAGS_INCL_FUNCNAME)
485 res += printk(KERN_CONT "%s:", descriptor->function);
486 if (descriptor->flags & _DPRINTK_FLAGS_INCL_LINENO)
487 res += printk(KERN_CONT "%d ", descriptor->lineno);
488
489 res += __dev_printk(KERN_CONT, dev, &vaf);
490
491 va_end(args);
492
493 return res;
494}
495EXPORT_SYMBOL(__dynamic_dev_dbg);
496
459static __initdata char ddebug_setup_string[1024]; 497static __initdata char ddebug_setup_string[1024];
460static __init int ddebug_setup_query(char *str) 498static __init int ddebug_setup_query(char *str)
461{ 499{