diff options
| author | Joe Perches <joe@perches.com> | 2010-06-26 21:02:34 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2010-07-04 13:40:17 -0400 |
| commit | 99bcf217183e02ebae46373896fba7f12d588001 (patch) | |
| tree | 03210a8c57e33b2b5073f80f9a7f818c84f4c83a /include/linux | |
| parent | 7db6f5fb65a82af03229eef104dc9899c5eecf33 (diff) | |
device.h drivers/base/core.c Convert dev_<level> logging macros to functions
Reduces an x86 defconfig text and data ~55k, .6% smaller.
$ size vmlinux*
text data bss dec hex filename
7205273 716016 1366288 9287577 8db799 vmlinux
7258890 719768 1366288 9344946 8e97b2 vmlinux.master
Uses %pV and struct va_format
Format arguments are verified before printk
The dev_info macro is converted to _dev_info because there are
existing uses of variables named dev_info in the kernel tree
like drivers/net/pcmcia/pcnet_cs.c
A dev_info macro is created to call _dev_info
Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/device.h | 112 |
1 files changed, 86 insertions, 26 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 0713e10571dd..6a8276f683b6 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -638,43 +638,103 @@ extern void sysdev_shutdown(void); | |||
| 638 | 638 | ||
| 639 | /* debugging and troubleshooting/diagnostic helpers. */ | 639 | /* debugging and troubleshooting/diagnostic helpers. */ |
| 640 | extern const char *dev_driver_string(const struct device *dev); | 640 | extern const char *dev_driver_string(const struct device *dev); |
| 641 | #define dev_printk(level, dev, format, arg...) \ | 641 | |
| 642 | printk(level "%s %s: " format , dev_driver_string(dev) , \ | 642 | |
| 643 | dev_name(dev) , ## arg) | 643 | #ifdef CONFIG_PRINTK |
| 644 | 644 | ||
| 645 | #define dev_emerg(dev, format, arg...) \ | 645 | extern int dev_printk(const char *level, const struct device *dev, |
| 646 | dev_printk(KERN_EMERG , dev , format , ## arg) | 646 | const char *fmt, ...) |
| 647 | #define dev_alert(dev, format, arg...) \ | 647 | __attribute__ ((format (printf, 3, 4))); |
| 648 | dev_printk(KERN_ALERT , dev , format , ## arg) | 648 | extern int dev_emerg(const struct device *dev, const char *fmt, ...) |
| 649 | #define dev_crit(dev, format, arg...) \ | 649 | __attribute__ ((format (printf, 2, 3))); |
| 650 | dev_printk(KERN_CRIT , dev , format , ## arg) | 650 | extern int dev_alert(const struct device *dev, const char *fmt, ...) |
| 651 | #define dev_err(dev, format, arg...) \ | 651 | __attribute__ ((format (printf, 2, 3))); |
| 652 | dev_printk(KERN_ERR , dev , format , ## arg) | 652 | extern int dev_crit(const struct device *dev, const char *fmt, ...) |
| 653 | #define dev_warn(dev, format, arg...) \ | 653 | __attribute__ ((format (printf, 2, 3))); |
| 654 | dev_printk(KERN_WARNING , dev , format , ## arg) | 654 | extern int dev_err(const struct device *dev, const char *fmt, ...) |
| 655 | #define dev_notice(dev, format, arg...) \ | 655 | __attribute__ ((format (printf, 2, 3))); |
| 656 | dev_printk(KERN_NOTICE , dev , format , ## arg) | 656 | extern int dev_warn(const struct device *dev, const char *fmt, ...) |
| 657 | #define dev_info(dev, format, arg...) \ | 657 | __attribute__ ((format (printf, 2, 3))); |
| 658 | dev_printk(KERN_INFO , dev , format , ## arg) | 658 | extern int dev_notice(const struct device *dev, const char *fmt, ...) |
| 659 | __attribute__ ((format (printf, 2, 3))); | ||
| 660 | extern int _dev_info(const struct device *dev, const char *fmt, ...) | ||
| 661 | __attribute__ ((format (printf, 2, 3))); | ||
| 662 | |||
| 663 | #else | ||
| 664 | |||
| 665 | static inline int dev_printk(const char *level, const struct device *dev, | ||
| 666 | const char *fmt, ...) | ||
| 667 | __attribute__ ((format (printf, 3, 4))); | ||
| 668 | static inline int dev_printk(const char *level, const struct device *dev, | ||
| 669 | const char *fmt, ...) | ||
| 670 | { return 0; } | ||
| 671 | |||
| 672 | static inline int dev_emerg(const struct device *dev, const char *fmt, ...) | ||
| 673 | __attribute__ ((format (printf, 2, 3))); | ||
| 674 | static inline int dev_emerg(const struct device *dev, const char *fmt, ...) | ||
| 675 | { return 0; } | ||
| 676 | static inline int dev_crit(const struct device *dev, const char *fmt, ...) | ||
| 677 | __attribute__ ((format (printf, 2, 3))); | ||
| 678 | static inline int dev_crit(const struct device *dev, const char *fmt, ...) | ||
| 679 | { return 0; } | ||
| 680 | static inline int dev_alert(const struct device *dev, const char *fmt, ...) | ||
| 681 | __attribute__ ((format (printf, 2, 3))); | ||
| 682 | static inline int dev_alert(const struct device *dev, const char *fmt, ...) | ||
| 683 | { return 0; } | ||
| 684 | static inline int dev_err(const struct device *dev, const char *fmt, ...) | ||
| 685 | __attribute__ ((format (printf, 2, 3))); | ||
| 686 | static inline int dev_err(const struct device *dev, const char *fmt, ...) | ||
| 687 | { return 0; } | ||
| 688 | static inline int dev_warn(const struct device *dev, const char *fmt, ...) | ||
| 689 | __attribute__ ((format (printf, 2, 3))); | ||
| 690 | static inline int dev_warn(const struct device *dev, const char *fmt, ...) | ||
| 691 | { return 0; } | ||
| 692 | static inline int dev_notice(const struct device *dev, const char *fmt, ...) | ||
| 693 | __attribute__ ((format (printf, 2, 3))); | ||
| 694 | static inline int dev_notice(const struct device *dev, const char *fmt, ...) | ||
| 695 | { return 0; } | ||
| 696 | static inline int _dev_info(const struct device *dev, const char *fmt, ...) | ||
| 697 | __attribute__ ((format (printf, 2, 3))); | ||
| 698 | static inline int _dev_info(const struct device *dev, const char *fmt, ...) | ||
| 699 | { return 0; } | ||
| 700 | |||
| 701 | #endif | ||
| 702 | |||
| 703 | /* | ||
| 704 | * Stupid hackaround for existing uses of non-printk uses dev_info | ||
| 705 | * | ||
| 706 | * Note that the definition of dev_info below is actually _dev_info | ||
| 707 | * and a macro is used to avoid redefining dev_info | ||
| 708 | */ | ||
| 709 | |||
| 710 | #define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg) | ||
| 659 | 711 | ||
| 660 | #if defined(DEBUG) | 712 | #if defined(DEBUG) |
| 661 | #define dev_dbg(dev, format, arg...) \ | 713 | #define dev_dbg(dev, format, arg...) \ |
| 662 | dev_printk(KERN_DEBUG , dev , format , ## arg) | 714 | dev_printk(KERN_DEBUG, dev, format, ##arg) |
| 663 | #elif defined(CONFIG_DYNAMIC_DEBUG) | 715 | #elif defined(CONFIG_DYNAMIC_DEBUG) |
| 664 | #define dev_dbg(dev, format, ...) do { \ | 716 | #define dev_dbg(dev, format, ...) \ |
| 717 | do { \ | ||
| 665 | dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \ | 718 | dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \ |
| 666 | } while (0) | 719 | } while (0) |
| 667 | #else | 720 | #else |
| 668 | #define dev_dbg(dev, format, arg...) \ | 721 | #define dev_dbg(dev, format, arg...) \ |
| 669 | ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) | 722 | ({ \ |
| 723 | if (0) \ | ||
| 724 | dev_printk(KERN_DEBUG, dev, format, ##arg); \ | ||
| 725 | 0; \ | ||
| 726 | }) | ||
| 670 | #endif | 727 | #endif |
| 671 | 728 | ||
| 672 | #ifdef VERBOSE_DEBUG | 729 | #ifdef VERBOSE_DEBUG |
| 673 | #define dev_vdbg dev_dbg | 730 | #define dev_vdbg dev_dbg |
| 674 | #else | 731 | #else |
| 675 | 732 | #define dev_vdbg(dev, format, arg...) \ | |
| 676 | #define dev_vdbg(dev, format, arg...) \ | 733 | ({ \ |
| 677 | ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) | 734 | if (0) \ |
| 735 | dev_printk(KERN_DEBUG, dev, format, ##arg); \ | ||
| 736 | 0; \ | ||
| 737 | }) | ||
| 678 | #endif | 738 | #endif |
| 679 | 739 | ||
| 680 | /* | 740 | /* |
