Message ID | e18f5d8b8a0857a07918107f464a653234a47564.1267771398.git.joe@perches.com |
---|---|
State | Not Applicable, archived |
Delegated to: | David Miller |
Headers | show |
On Thu, 4 Mar 2010 22:56:53 -0800 Joe Perches <joe@perches.com> wrote:
> Perhaps over time the struct and local uses of dev_info should be renamed.
aww, c'mon.
y:/usr/src/linux-2.6.33> grep -r '\*dev_info;' . | wc -l
30
Half an hour, tops.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, 2010-03-04 at 23:10 -0800, Andrew Morton wrote: > On Thu, 4 Mar 2010 22:56:53 -0800 Joe Perches <joe@perches.com> wrote: > > Perhaps over time the struct and local uses of dev_info should be renamed. > aww, c'mon. > y:/usr/src/linux-2.6.33> grep -r '\*dev_info;' . | wc -l > 30 No doubt I could submit all the required changes in an hour or so, but some of the maintainers seem less than open to what they consider "churn". $ grep -rP --include=*.[ch] -l "dev_info\b\s*[^\(]" * arch/powerpc/platforms/iseries/dt.c drivers/usb/host/xhci-dbg.c drivers/usb/host/xhci.h drivers/usb/wusbcore/wusbhc.h drivers/scsi/scsi_devinfo.c drivers/staging/comedi/drivers/das08_cs.c drivers/staging/comedi/drivers/ni_daq_dio24.c drivers/staging/comedi/drivers/quatech_daqp_cs.c drivers/staging/comedi/drivers/ni_daq_700.c drivers/staging/comedi/drivers/ni_labpc_cs.c drivers/staging/comedi/drivers/cb_das16_cs.c drivers/staging/udlfb/udlfb.c drivers/media/video/sh_mobile_ceu_camera.c drivers/md/linear.h drivers/net/ksz884x.c drivers/net/bnx2x_link.c drivers/net/wireless/wl3501_cs.c drivers/net/cnic.c drivers/net/bnx2x_main.c include/linux/sfi.h include/net/bluetooth/rfcomm.h -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, 04 Mar 2010 23:23:35 -0800 Joe Perches <joe@perches.com> wrote: > On Thu, 2010-03-04 at 23:10 -0800, Andrew Morton wrote: > > On Thu, 4 Mar 2010 22:56:53 -0800 Joe Perches <joe@perches.com> wrote: > > > Perhaps over time the struct and local uses of dev_info should be renamed. > > aww, c'mon. > > y:/usr/src/linux-2.6.33> grep -r '\*dev_info;' . | wc -l > > 30 > > No doubt I could submit all the required changes in > an hour or so, but some of the maintainers seem > less than open to what they consider "churn". Well, that has to be one of the worst possible reasons? > $ grep -rP --include=*.[ch] -l "dev_info\b\s*[^\(]" * > arch/powerpc/platforms/iseries/dt.c > drivers/usb/host/xhci-dbg.c > drivers/usb/host/xhci.h > drivers/usb/wusbcore/wusbhc.h > drivers/scsi/scsi_devinfo.c > drivers/staging/comedi/drivers/das08_cs.c > drivers/staging/comedi/drivers/ni_daq_dio24.c > drivers/staging/comedi/drivers/quatech_daqp_cs.c > drivers/staging/comedi/drivers/ni_daq_700.c > drivers/staging/comedi/drivers/ni_labpc_cs.c > drivers/staging/comedi/drivers/cb_das16_cs.c > drivers/staging/udlfb/udlfb.c > drivers/media/video/sh_mobile_ceu_camera.c > drivers/md/linear.h > drivers/net/ksz884x.c > drivers/net/bnx2x_link.c > drivers/net/wireless/wl3501_cs.c > drivers/net/cnic.c > drivers/net/bnx2x_main.c > include/linux/sfi.h > include/net/bluetooth/rfcomm.h Send 'em over, please. I'll merge any stragglers directly. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
There is a macro called dev_info that prints struct device specific information. Having variables with the same name can be confusing and prevents conversion of the macro to a function. Rename the existing dev_info variables to something else in preparation to converting the dev_info macro to a function. Joe Perches (11): arch/ia64/hp/common/sba_iommu.c: Rename dev_info to adi drivers/usb/host/hwa-hc.c: Rename dev_info to hdi drivers/usb/wusbcore/wusbhc.h: Remove unused dev_info from struct wusb_port drivers/s390/block/dcssblk.c: Rename dev_info to ddi drivers/edac/amd: Rename dev_info to adi drivers/edac/cpc925_edac.c: Rename dev_info to cdi drivers/edac/e7*_edac.c: Rename dev_info to edi drivers/staging/iio: Rename dev_info to idi pvrusb2-v4l2: Rename dev_info to pdi drivers/char/mem.c: Rename dev_info to bdi drivers/uwb: Rename dev_info to wdi arch/ia64/hp/common/sba_iommu.c | 8 +- drivers/char/mem.c | 6 +- drivers/edac/amd8111_edac.c | 88 ++++---- drivers/edac/amd8131_edac.c | 86 ++++---- drivers/edac/cpc925_edac.c | 122 +++++----- drivers/edac/e752x_edac.c | 18 +- drivers/edac/e7xxx_edac.c | 8 +- drivers/media/video/pvrusb2/pvrusb2-v4l2.c | 22 +- drivers/s390/block/dcssblk.c | 328 ++++++++++++++-------------- drivers/staging/iio/accel/lis3l02dq_core.c | 4 +- drivers/staging/iio/accel/lis3l02dq_ring.c | 20 +- drivers/staging/iio/accel/sca3000_core.c | 24 +- drivers/staging/iio/adc/max1363_core.c | 36 ++-- drivers/staging/iio/adc/max1363_ring.c | 6 +- drivers/staging/iio/chrdev.h | 2 +- drivers/staging/iio/iio.h | 54 +++--- drivers/staging/iio/industrialio-core.c | 232 ++++++++++---------- drivers/staging/iio/industrialio-ring.c | 38 ++-- drivers/staging/iio/industrialio-trigger.c | 34 ++-- drivers/staging/iio/ring_generic.h | 4 +- drivers/staging/iio/trigger_consumer.h | 16 +- drivers/usb/host/hwa-hc.c | 18 +- drivers/usb/wusbcore/wusbhc.h | 10 - drivers/uwb/i1480/i1480u-wlp/lc.c | 16 +- drivers/uwb/wlp/messages.c | 40 ++-- drivers/uwb/wlp/sysfs.c | 46 ++-- drivers/uwb/wlp/wlp-lc.c | 12 +- 27 files changed, 644 insertions(+), 654 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/base/core.c b/drivers/base/core.c index 2820257..19de3ab 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1745,3 +1745,59 @@ void device_shutdown(void) } async_synchronize_full(); } + +/* + * Device logging functions + */ + +#ifdef CONFIG_PRINTK + +static int __dev_printk(const char *level, const struct device *dev, + const char *fmt, va_list args) +{ + struct va_format vaf; + + vaf.fmt = fmt; + vaf.va = &args; + return printk("%s%s %s: %pV", + level, dev_driver_string(dev), dev_name(dev), &vaf); +} + +int dev_printk(const char *level, const struct device *dev, + const char *fmt, ...) +{ + int r; + va_list args; + + va_start(args, fmt); + r = __dev_printk(level, dev, fmt, args); + va_end(args); + + return r; +} +EXPORT_SYMBOL(dev_printk); + +#define declare_dev_level(function, level) \ +int function(const struct device *dev, const char *fmt, ...) \ +{ \ + int r; \ + va_list args; \ + \ + va_start(args, fmt); \ + r = __dev_printk(level, dev, fmt, args); \ + va_end(args); \ + \ + return r; \ +} \ +EXPORT_SYMBOL(function) + +declare_dev_level(dev_emerg, KERN_EMERG); +declare_dev_level(dev_alert, KERN_ALERT); +declare_dev_level(dev_crit, KERN_CRIT); +declare_dev_level(dev_err, KERN_ERR); +declare_dev_level(dev_warn, KERN_WARNING); +declare_dev_level(dev_notice, KERN_NOTICE); +declare_dev_level(_dev_info, KERN_INFO); +/* Not dev_info because it conflicts with with existing "struct dev_info" */ + +#endif diff --git a/include/linux/device.h b/include/linux/device.h index b30527d..5948c07 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -590,43 +590,96 @@ extern void sysdev_shutdown(void); /* debugging and troubleshooting/diagnostic helpers. */ extern const char *dev_driver_string(const struct device *dev); -#define dev_printk(level, dev, format, arg...) \ - printk(level "%s %s: " format , dev_driver_string(dev) , \ - dev_name(dev) , ## arg) - -#define dev_emerg(dev, format, arg...) \ - dev_printk(KERN_EMERG , dev , format , ## arg) -#define dev_alert(dev, format, arg...) \ - dev_printk(KERN_ALERT , dev , format , ## arg) -#define dev_crit(dev, format, arg...) \ - dev_printk(KERN_CRIT , dev , format , ## arg) -#define dev_err(dev, format, arg...) \ - dev_printk(KERN_ERR , dev , format , ## arg) -#define dev_warn(dev, format, arg...) \ - dev_printk(KERN_WARNING , dev , format , ## arg) -#define dev_notice(dev, format, arg...) \ - dev_printk(KERN_NOTICE , dev , format , ## arg) -#define dev_info(dev, format, arg...) \ - dev_printk(KERN_INFO , dev , format , ## arg) + +#ifdef CONFIG_PRINTK + +extern int dev_printk(const char *level, const struct device *dev, + const char *fmt, ...) + __attribute__ ((format (printf, 3, 4))); +extern int dev_emerg(const struct device *dev, const char *fmt, ...) + __attribute__ ((format (printf, 2, 3))); +extern int dev_alert(const struct device *dev, const char *fmt, ...) + __attribute__ ((format (printf, 2, 3))); +extern int dev_crit(const struct device *dev, const char *fmt, ...) + __attribute__ ((format (printf, 2, 3))); +extern int dev_err(const struct device *dev, const char *fmt, ...) + __attribute__ ((format (printf, 2, 3))); +extern int dev_warn(const struct device *dev, const char *fmt, ...) + __attribute__ ((format (printf, 2, 3))); +extern int dev_notice(const struct device *dev, const char *fmt, ...) + __attribute__ ((format (printf, 2, 3))); +extern int _dev_info(const struct device *dev, const char *fmt, ...) + __attribute__ ((format (printf, 2, 3))); + +#else + +static inline int dev_printk(const char *level, const struct device *dev, + const char *fmt, ...) + __attribute__ ((format (printf, 3, 4))); +static inline int dev_printk(const char *level, const struct device *dev, + const char *fmt, ...) + { return 0; } + +static inline int dev_emerg(const struct device *dev, const char *s, ...) + __attribute__ ((format (printf, 2, 3))); +static inline int dev_emerg(const struct device *dev, const char *s, ...) + { return 0; } +static inline int dev_crit(const struct device *dev, const char *s, ...) + __attribute__ ((format (printf, 2, 3))); +static inline int dev_crit(const struct device *dev, const char *s, ...) + { return 0; } +static inline int dev_alert(const struct device *dev, const char *s, ...) + __attribute__ ((format (printf, 2, 3))); +static inline int dev_alert(const struct device *dev, const char *s, ...) + { return 0; } +static inline int dev_err(const struct device *dev, const char *s, ...) + __attribute__ ((format (printf, 2, 3))); +static inline int dev_err(const struct device *dev, const char *s, ...) + { return 0; } +static inline int dev_warn(const struct device *dev, const char *s, ...) + __attribute__ ((format (printf, 2, 3))); +static inline int dev_warn(const struct device *dev, const char *s, ...) + { return 0; } +static inline int dev_notice(const struct device *dev, const char *s, ...) + __attribute__ ((format (printf, 2, 3))); +static inline int dev_notice(const struct device *dev, const char *s, ...) + { return 0; } +static inline int _dev_info(const struct device *dev, const char *s, ...) + __attribute__ ((format (printf, 2, 3))); +static inline int _dev_info(const struct device *dev, const char *s, ...) + { return 0; } + +#endif + +#define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg) +/* workaround for existing struct dev_info and variable dev_info uses */ #if defined(DEBUG) #define dev_dbg(dev, format, arg...) \ - dev_printk(KERN_DEBUG , dev , format , ## arg) + dev_printk(KERN_DEBUG, dev, format, ##arg) #elif defined(CONFIG_DYNAMIC_DEBUG) -#define dev_dbg(dev, format, ...) do { \ +#define dev_dbg(dev, format, ...) \ +do { \ dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \ - } while (0) +} while (0) #else -#define dev_dbg(dev, format, arg...) \ - ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) +#define dev_dbg(dev, format, arg...) \ +({ \ + if (0) \ + dev_printk(KERN_DEBUG, dev, format, ##arg); \ + 0; \ +}) #endif #ifdef VERBOSE_DEBUG #define dev_vdbg dev_dbg #else - -#define dev_vdbg(dev, format, arg...) \ - ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) +#define dev_vdbg(dev, format, arg...) \ +({ \ + if (0) \ + dev_printk(KERN_DEBUG, dev, format, ##arg); \ + 0; \ +}) #endif /*
Save ~60k in a defconfig Use %pV and struct va_format Format arguments are verified before printk There are existing "struct dev_info" declarations as well as local variables named dev_info so the dev_info macro to function conversion is instead called _dev_info and a macro is used to call _dev_info Perhaps over time the struct and local uses of dev_info should be renamed. Signed-off-by: Joe Perches <joe@perches.com> --- drivers/base/core.c | 56 +++++++++++++++++++++++++ include/linux/device.h | 105 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 135 insertions(+), 26 deletions(-)