Return-path: Received: from mail.perches.com ([173.55.12.10]:3354 "EHLO mail.perches.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750725Ab1F3E2o (ORCPT ); Thu, 30 Jun 2011 00:28:44 -0400 Subject: RFC: Add __dynamic_dev_dbg From: Joe Perches To: Aloisio Almeida Cc: Jason Baron , Marcel Holtmann , linville@tuxdriver.com, linux-wireless@vger.kernel.org, sameo@linux.intel.com, johannes@sipsolutions.net, lauro.venancio@openbossa.org, marcio.macedo@openbossa.org, Waldemar.Rymarkiewicz@tieto.com, padovan@profusion.mobi, rdunlap@xenotime.net In-Reply-To: References: <1309285246-8495-1-git-send-email-aloisio.almeida@openbossa.org> <1309285246-8495-2-git-send-email-aloisio.almeida@openbossa.org> <1309292325.29598.9.camel@Joe-Laptop> <1309311096.2208.33.camel@aeonflux> <1309312164.29598.53.camel@Joe-Laptop> <1309370457.2208.48.camel@aeonflux> <1309391163.29598.92.camel@Joe-Laptop> Content-Type: text/plain; charset="UTF-8" Date: Wed, 29 Jun 2011 21:28:42 -0700 Message-ID: <1309408122.1726.13.camel@Joe-Laptop> (sfid-20110630_062847_944107_B0FF7DB4) Mime-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org List-ID: On Thu, 2011-06-30 at 00:26 -0300, Aloisio Almeida wrote: > It's stored but not retrieved. If you check lib/dynamic_debug.c you > see that only __dynamic_pr_debug() (called by dynamic_pr_debug() ) > adds such information on prints. The dev_printk() does not check > _DPRINTK_FLAGS_INCL_* flags. That seems enough easy to fix. Jason? How does this look? --- drivers/base/core.c | 5 +++-- include/linux/device.h | 5 +++++ include/linux/dynamic_debug.h | 10 ++++++++-- lib/dynamic_debug.c | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index bc8729d..82c8654 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1764,8 +1764,8 @@ void device_shutdown(void) #ifdef CONFIG_PRINTK -static int __dev_printk(const char *level, const struct device *dev, - struct va_format *vaf) +int __dev_printk(const char *level, const struct device *dev, + struct va_format *vaf) { if (!dev) return printk("%s(NULL device *): %pV", level, vaf); @@ -1773,6 +1773,7 @@ static int __dev_printk(const char *level, const struct device *dev, return printk("%s%s %s: %pV", level, dev_driver_string(dev), dev_name(dev), vaf); } +EXPORT_SYMBOL(__dev_printk); int dev_printk(const char *level, const struct device *dev, const char *fmt, ...) diff --git a/include/linux/device.h b/include/linux/device.h index e4f62d8..53711f2 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); #ifdef CONFIG_PRINTK +extern int __dev_printk(const char *level, const struct device *dev, + struct va_format *vaf); extern int dev_printk(const char *level, const struct device *dev, const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); @@ -805,6 +807,9 @@ extern int _dev_info(const struct device *dev, const char *fmt, ...) #else +static inline int __dev_printk(const char *level, const struct device *dev, + struct va_format *vaf) + { return 0; } static inline int dev_printk(const char *level, const struct device *dev, const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index e747ecd..bdf1531 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); extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); +struct device; + +extern int __dynamic_dev_dbg(struct _ddebug *descriptor, + const struct device *dev, + const char *fmt, ...) + __attribute__ ((format (printf, 3, 4))); + #define dynamic_pr_debug(fmt, ...) do { \ static struct _ddebug descriptor \ __used \ @@ -57,7 +64,6 @@ extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) __dynamic_pr_debug(&descriptor, pr_fmt(fmt), ##__VA_ARGS__); \ } while (0) - #define dynamic_dev_dbg(dev, fmt, ...) do { \ static struct _ddebug descriptor \ __used \ @@ -65,7 +71,7 @@ extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \ _DPRINTK_FLAGS_DEFAULT }; \ if (unlikely(descriptor.enabled)) \ - dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ + __dynamic_dev_dbg(&descriptor, dev, fmt, ##__VA_ARGS__); \ } while (0) #else diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 75ca78f..5c5f8f9 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -30,6 +30,7 @@ #include #include #include +#include extern struct _ddebug __start___verbose[]; extern struct _ddebug __stop___verbose[]; @@ -456,6 +457,43 @@ int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) } EXPORT_SYMBOL(__dynamic_pr_debug); +int __dynamic_dev_dbg(struct _ddebug *descriptor, + const struct device *dev, const char *fmt, ...) +{ + struct va_format vaf; + va_list args; + int res; + + BUG_ON(!descriptor); + BUG_ON(!fmt); + + va_start(args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; + + res = printk(KERN_DEBUG); + if (descriptor->flags & _DPRINTK_FLAGS_INCL_TID) { + if (in_interrupt()) + res += printk(KERN_CONT " "); + else + res += printk(KERN_CONT "[%d] ", task_pid_vnr(current)); + } + if (descriptor->flags & _DPRINTK_FLAGS_INCL_MODNAME) + res += printk(KERN_CONT "%s:", descriptor->modname); + if (descriptor->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) + res += printk(KERN_CONT "%s:", descriptor->function); + if (descriptor->flags & _DPRINTK_FLAGS_INCL_LINENO) + res += printk(KERN_CONT "%d ", descriptor->lineno); + + res += __dev_printk("", dev, &vaf); + + va_end(args); + + return res; +} +EXPORT_SYMBOL(__dynamic_dev_dbg); + static __initdata char ddebug_setup_string[1024]; static __init int ddebug_setup_query(char *str) {