diff options
Diffstat (limited to 'include/linux/device.h')
-rw-r--r-- | include/linux/device.h | 127 |
1 files changed, 94 insertions, 33 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 0713e10571dd..516fecacf27b 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -84,9 +84,8 @@ struct device *bus_find_device_by_name(struct bus_type *bus, | |||
84 | struct device *start, | 84 | struct device *start, |
85 | const char *name); | 85 | const char *name); |
86 | 86 | ||
87 | int __must_check bus_for_each_drv(struct bus_type *bus, | 87 | int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, |
88 | struct device_driver *start, void *data, | 88 | void *data, int (*fn)(struct device_driver *, void *)); |
89 | int (*fn)(struct device_driver *, void *)); | ||
90 | 89 | ||
91 | void bus_sort_breadthfirst(struct bus_type *bus, | 90 | void bus_sort_breadthfirst(struct bus_type *bus, |
92 | int (*compare)(const struct device *a, | 91 | int (*compare)(const struct device *a, |
@@ -110,10 +109,12 @@ extern int bus_unregister_notifier(struct bus_type *bus, | |||
110 | */ | 109 | */ |
111 | #define BUS_NOTIFY_ADD_DEVICE 0x00000001 /* device added */ | 110 | #define BUS_NOTIFY_ADD_DEVICE 0x00000001 /* device added */ |
112 | #define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device removed */ | 111 | #define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device removed */ |
113 | #define BUS_NOTIFY_BOUND_DRIVER 0x00000003 /* driver bound to device */ | 112 | #define BUS_NOTIFY_BIND_DRIVER 0x00000003 /* driver about to be |
114 | #define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be | 113 | bound */ |
114 | #define BUS_NOTIFY_BOUND_DRIVER 0x00000004 /* driver bound to device */ | ||
115 | #define BUS_NOTIFY_UNBIND_DRIVER 0x00000005 /* driver about to be | ||
115 | unbound */ | 116 | unbound */ |
116 | #define BUS_NOTIFY_UNBOUND_DRIVER 0x00000005 /* driver is unbound | 117 | #define BUS_NOTIFY_UNBOUND_DRIVER 0x00000006 /* driver is unbound |
117 | from the device */ | 118 | from the device */ |
118 | 119 | ||
119 | extern struct kset *bus_get_kset(struct bus_type *bus); | 120 | extern struct kset *bus_get_kset(struct bus_type *bus); |
@@ -551,7 +552,7 @@ extern int device_for_each_child(struct device *dev, void *data, | |||
551 | int (*fn)(struct device *dev, void *data)); | 552 | int (*fn)(struct device *dev, void *data)); |
552 | extern struct device *device_find_child(struct device *dev, void *data, | 553 | extern struct device *device_find_child(struct device *dev, void *data, |
553 | int (*match)(struct device *dev, void *data)); | 554 | int (*match)(struct device *dev, void *data)); |
554 | extern int device_rename(struct device *dev, char *new_name); | 555 | extern int device_rename(struct device *dev, const char *new_name); |
555 | extern int device_move(struct device *dev, struct device *new_parent, | 556 | extern int device_move(struct device *dev, struct device *new_parent, |
556 | enum dpm_order dpm_order); | 557 | enum dpm_order dpm_order); |
557 | extern const char *device_get_devnode(struct device *dev, | 558 | extern const char *device_get_devnode(struct device *dev, |
@@ -638,43 +639,103 @@ extern void sysdev_shutdown(void); | |||
638 | 639 | ||
639 | /* debugging and troubleshooting/diagnostic helpers. */ | 640 | /* debugging and troubleshooting/diagnostic helpers. */ |
640 | extern const char *dev_driver_string(const struct device *dev); | 641 | extern const char *dev_driver_string(const struct device *dev); |
641 | #define dev_printk(level, dev, format, arg...) \ | 642 | |
642 | printk(level "%s %s: " format , dev_driver_string(dev) , \ | 643 | |
643 | dev_name(dev) , ## arg) | 644 | #ifdef CONFIG_PRINTK |
644 | 645 | ||
645 | #define dev_emerg(dev, format, arg...) \ | 646 | extern int dev_printk(const char *level, const struct device *dev, |
646 | dev_printk(KERN_EMERG , dev , format , ## arg) | 647 | const char *fmt, ...) |
647 | #define dev_alert(dev, format, arg...) \ | 648 | __attribute__ ((format (printf, 3, 4))); |
648 | dev_printk(KERN_ALERT , dev , format , ## arg) | 649 | extern int dev_emerg(const struct device *dev, const char *fmt, ...) |
649 | #define dev_crit(dev, format, arg...) \ | 650 | __attribute__ ((format (printf, 2, 3))); |
650 | dev_printk(KERN_CRIT , dev , format , ## arg) | 651 | extern int dev_alert(const struct device *dev, const char *fmt, ...) |
651 | #define dev_err(dev, format, arg...) \ | 652 | __attribute__ ((format (printf, 2, 3))); |
652 | dev_printk(KERN_ERR , dev , format , ## arg) | 653 | extern int dev_crit(const struct device *dev, const char *fmt, ...) |
653 | #define dev_warn(dev, format, arg...) \ | 654 | __attribute__ ((format (printf, 2, 3))); |
654 | dev_printk(KERN_WARNING , dev , format , ## arg) | 655 | extern int dev_err(const struct device *dev, const char *fmt, ...) |
655 | #define dev_notice(dev, format, arg...) \ | 656 | __attribute__ ((format (printf, 2, 3))); |
656 | dev_printk(KERN_NOTICE , dev , format , ## arg) | 657 | extern int dev_warn(const struct device *dev, const char *fmt, ...) |
657 | #define dev_info(dev, format, arg...) \ | 658 | __attribute__ ((format (printf, 2, 3))); |
658 | dev_printk(KERN_INFO , dev , format , ## arg) | 659 | extern int dev_notice(const struct device *dev, const char *fmt, ...) |
660 | __attribute__ ((format (printf, 2, 3))); | ||
661 | extern int _dev_info(const struct device *dev, const char *fmt, ...) | ||
662 | __attribute__ ((format (printf, 2, 3))); | ||
663 | |||
664 | #else | ||
665 | |||
666 | static inline int dev_printk(const char *level, const struct device *dev, | ||
667 | const char *fmt, ...) | ||
668 | __attribute__ ((format (printf, 3, 4))); | ||
669 | static inline int dev_printk(const char *level, const struct device *dev, | ||
670 | const char *fmt, ...) | ||
671 | { return 0; } | ||
672 | |||
673 | static inline int dev_emerg(const struct device *dev, const char *fmt, ...) | ||
674 | __attribute__ ((format (printf, 2, 3))); | ||
675 | static inline int dev_emerg(const struct device *dev, const char *fmt, ...) | ||
676 | { return 0; } | ||
677 | static inline int dev_crit(const struct device *dev, const char *fmt, ...) | ||
678 | __attribute__ ((format (printf, 2, 3))); | ||
679 | static inline int dev_crit(const struct device *dev, const char *fmt, ...) | ||
680 | { return 0; } | ||
681 | static inline int dev_alert(const struct device *dev, const char *fmt, ...) | ||
682 | __attribute__ ((format (printf, 2, 3))); | ||
683 | static inline int dev_alert(const struct device *dev, const char *fmt, ...) | ||
684 | { return 0; } | ||
685 | static inline int dev_err(const struct device *dev, const char *fmt, ...) | ||
686 | __attribute__ ((format (printf, 2, 3))); | ||
687 | static inline int dev_err(const struct device *dev, const char *fmt, ...) | ||
688 | { return 0; } | ||
689 | static inline int dev_warn(const struct device *dev, const char *fmt, ...) | ||
690 | __attribute__ ((format (printf, 2, 3))); | ||
691 | static inline int dev_warn(const struct device *dev, const char *fmt, ...) | ||
692 | { return 0; } | ||
693 | static inline int dev_notice(const struct device *dev, const char *fmt, ...) | ||
694 | __attribute__ ((format (printf, 2, 3))); | ||
695 | static inline int dev_notice(const struct device *dev, const char *fmt, ...) | ||
696 | { return 0; } | ||
697 | static inline int _dev_info(const struct device *dev, const char *fmt, ...) | ||
698 | __attribute__ ((format (printf, 2, 3))); | ||
699 | static inline int _dev_info(const struct device *dev, const char *fmt, ...) | ||
700 | { return 0; } | ||
701 | |||
702 | #endif | ||
703 | |||
704 | /* | ||
705 | * Stupid hackaround for existing uses of non-printk uses dev_info | ||
706 | * | ||
707 | * Note that the definition of dev_info below is actually _dev_info | ||
708 | * and a macro is used to avoid redefining dev_info | ||
709 | */ | ||
710 | |||
711 | #define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg) | ||
659 | 712 | ||
660 | #if defined(DEBUG) | 713 | #if defined(DEBUG) |
661 | #define dev_dbg(dev, format, arg...) \ | 714 | #define dev_dbg(dev, format, arg...) \ |
662 | dev_printk(KERN_DEBUG , dev , format , ## arg) | 715 | dev_printk(KERN_DEBUG, dev, format, ##arg) |
663 | #elif defined(CONFIG_DYNAMIC_DEBUG) | 716 | #elif defined(CONFIG_DYNAMIC_DEBUG) |
664 | #define dev_dbg(dev, format, ...) do { \ | 717 | #define dev_dbg(dev, format, ...) \ |
718 | do { \ | ||
665 | dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \ | 719 | dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \ |
666 | } while (0) | 720 | } while (0) |
667 | #else | 721 | #else |
668 | #define dev_dbg(dev, format, arg...) \ | 722 | #define dev_dbg(dev, format, arg...) \ |
669 | ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) | 723 | ({ \ |
724 | if (0) \ | ||
725 | dev_printk(KERN_DEBUG, dev, format, ##arg); \ | ||
726 | 0; \ | ||
727 | }) | ||
670 | #endif | 728 | #endif |
671 | 729 | ||
672 | #ifdef VERBOSE_DEBUG | 730 | #ifdef VERBOSE_DEBUG |
673 | #define dev_vdbg dev_dbg | 731 | #define dev_vdbg dev_dbg |
674 | #else | 732 | #else |
675 | 733 | #define dev_vdbg(dev, format, arg...) \ | |
676 | #define dev_vdbg(dev, format, arg...) \ | 734 | ({ \ |
677 | ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) | 735 | if (0) \ |
736 | dev_printk(KERN_DEBUG, dev, format, ##arg); \ | ||
737 | 0; \ | ||
738 | }) | ||
678 | #endif | 739 | #endif |
679 | 740 | ||
680 | /* | 741 | /* |