diff options
Diffstat (limited to 'include/linux/device.h')
-rw-r--r-- | include/linux/device.h | 141 |
1 files changed, 78 insertions, 63 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index c20dfbfc49b4..ffbcf95cd97d 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/lockdep.h> | 20 | #include <linux/lockdep.h> |
21 | #include <linux/compiler.h> | 21 | #include <linux/compiler.h> |
22 | #include <linux/types.h> | 22 | #include <linux/types.h> |
23 | #include <linux/module.h> | 23 | #include <linux/mutex.h> |
24 | #include <linux/pm.h> | 24 | #include <linux/pm.h> |
25 | #include <linux/atomic.h> | 25 | #include <linux/atomic.h> |
26 | #include <asm/device.h> | 26 | #include <asm/device.h> |
@@ -29,10 +29,12 @@ struct device; | |||
29 | struct device_private; | 29 | struct device_private; |
30 | struct device_driver; | 30 | struct device_driver; |
31 | struct driver_private; | 31 | struct driver_private; |
32 | struct module; | ||
32 | struct class; | 33 | struct class; |
33 | struct subsys_private; | 34 | struct subsys_private; |
34 | struct bus_type; | 35 | struct bus_type; |
35 | struct device_node; | 36 | struct device_node; |
37 | struct iommu_ops; | ||
36 | 38 | ||
37 | struct bus_attribute { | 39 | struct bus_attribute { |
38 | struct attribute attr; | 40 | struct attribute attr; |
@@ -67,6 +69,9 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *); | |||
67 | * @resume: Called to bring a device on this bus out of sleep mode. | 69 | * @resume: Called to bring a device on this bus out of sleep mode. |
68 | * @pm: Power management operations of this bus, callback the specific | 70 | * @pm: Power management operations of this bus, callback the specific |
69 | * device driver's pm-ops. | 71 | * device driver's pm-ops. |
72 | * @iommu_ops IOMMU specific operations for this bus, used to attach IOMMU | ||
73 | * driver implementations to a bus and allow the driver to do | ||
74 | * bus-specific setup | ||
70 | * @p: The private data of the driver core, only the driver core can | 75 | * @p: The private data of the driver core, only the driver core can |
71 | * touch this. | 76 | * touch this. |
72 | * | 77 | * |
@@ -96,6 +101,8 @@ struct bus_type { | |||
96 | 101 | ||
97 | const struct dev_pm_ops *pm; | 102 | const struct dev_pm_ops *pm; |
98 | 103 | ||
104 | struct iommu_ops *iommu_ops; | ||
105 | |||
99 | struct subsys_private *p; | 106 | struct subsys_private *p; |
100 | }; | 107 | }; |
101 | 108 | ||
@@ -350,6 +357,8 @@ struct class_attribute { | |||
350 | char *buf); | 357 | char *buf); |
351 | ssize_t (*store)(struct class *class, struct class_attribute *attr, | 358 | ssize_t (*store)(struct class *class, struct class_attribute *attr, |
352 | const char *buf, size_t count); | 359 | const char *buf, size_t count); |
360 | const void *(*namespace)(struct class *class, | ||
361 | const struct class_attribute *attr); | ||
353 | }; | 362 | }; |
354 | 363 | ||
355 | #define CLASS_ATTR(_name, _mode, _show, _store) \ | 364 | #define CLASS_ATTR(_name, _mode, _show, _store) \ |
@@ -614,8 +623,8 @@ static inline const char *dev_name(const struct device *dev) | |||
614 | return kobject_name(&dev->kobj); | 623 | return kobject_name(&dev->kobj); |
615 | } | 624 | } |
616 | 625 | ||
617 | extern int dev_set_name(struct device *dev, const char *name, ...) | 626 | extern __printf(2, 3) |
618 | __attribute__((format(printf, 2, 3))); | 627 | int dev_set_name(struct device *dev, const char *name, ...); |
619 | 628 | ||
620 | #ifdef CONFIG_NUMA | 629 | #ifdef CONFIG_NUMA |
621 | static inline int dev_to_node(struct device *dev) | 630 | static inline int dev_to_node(struct device *dev) |
@@ -636,6 +645,11 @@ static inline void set_dev_node(struct device *dev, int node) | |||
636 | } | 645 | } |
637 | #endif | 646 | #endif |
638 | 647 | ||
648 | static inline struct pm_subsys_data *dev_to_psd(struct device *dev) | ||
649 | { | ||
650 | return dev ? dev->power.subsys_data : NULL; | ||
651 | } | ||
652 | |||
639 | static inline unsigned int dev_get_uevent_suppress(const struct device *dev) | 653 | static inline unsigned int dev_get_uevent_suppress(const struct device *dev) |
640 | { | 654 | { |
641 | return dev->kobj.uevent_suppress; | 655 | return dev->kobj.uevent_suppress; |
@@ -710,10 +724,14 @@ extern int dev_set_drvdata(struct device *dev, void *data); | |||
710 | */ | 724 | */ |
711 | extern struct device *__root_device_register(const char *name, | 725 | extern struct device *__root_device_register(const char *name, |
712 | struct module *owner); | 726 | struct module *owner); |
713 | static inline struct device *root_device_register(const char *name) | 727 | |
714 | { | 728 | /* |
715 | return __root_device_register(name, THIS_MODULE); | 729 | * This is a macro to avoid include problems with THIS_MODULE, |
716 | } | 730 | * just as per what is done for device_schedule_callback() above. |
731 | */ | ||
732 | #define root_device_register(name) \ | ||
733 | __root_device_register(name, THIS_MODULE) | ||
734 | |||
717 | extern void root_device_unregister(struct device *root); | 735 | extern void root_device_unregister(struct device *root); |
718 | 736 | ||
719 | static inline void *dev_get_platdata(const struct device *dev) | 737 | static inline void *dev_get_platdata(const struct device *dev) |
@@ -740,10 +758,10 @@ extern struct device *device_create_vargs(struct class *cls, | |||
740 | void *drvdata, | 758 | void *drvdata, |
741 | const char *fmt, | 759 | const char *fmt, |
742 | va_list vargs); | 760 | va_list vargs); |
743 | extern struct device *device_create(struct class *cls, struct device *parent, | 761 | extern __printf(5, 6) |
744 | dev_t devt, void *drvdata, | 762 | struct device *device_create(struct class *cls, struct device *parent, |
745 | const char *fmt, ...) | 763 | dev_t devt, void *drvdata, |
746 | __attribute__((format(printf, 5, 6))); | 764 | const char *fmt, ...); |
747 | extern void device_destroy(struct class *cls, dev_t devt); | 765 | extern void device_destroy(struct class *cls, dev_t devt); |
748 | 766 | ||
749 | /* | 767 | /* |
@@ -785,61 +803,58 @@ extern const char *dev_driver_string(const struct device *dev); | |||
785 | 803 | ||
786 | #ifdef CONFIG_PRINTK | 804 | #ifdef CONFIG_PRINTK |
787 | 805 | ||
788 | extern int dev_printk(const char *level, const struct device *dev, | 806 | extern int __dev_printk(const char *level, const struct device *dev, |
789 | const char *fmt, ...) | 807 | struct va_format *vaf); |
790 | __attribute__ ((format (printf, 3, 4))); | 808 | extern __printf(3, 4) |
791 | extern int dev_emerg(const struct device *dev, const char *fmt, ...) | 809 | int dev_printk(const char *level, const struct device *dev, |
792 | __attribute__ ((format (printf, 2, 3))); | 810 | const char *fmt, ...) |
793 | extern int dev_alert(const struct device *dev, const char *fmt, ...) | 811 | ; |
794 | __attribute__ ((format (printf, 2, 3))); | 812 | extern __printf(2, 3) |
795 | extern int dev_crit(const struct device *dev, const char *fmt, ...) | 813 | int dev_emerg(const struct device *dev, const char *fmt, ...); |
796 | __attribute__ ((format (printf, 2, 3))); | 814 | extern __printf(2, 3) |
797 | extern int dev_err(const struct device *dev, const char *fmt, ...) | 815 | int dev_alert(const struct device *dev, const char *fmt, ...); |
798 | __attribute__ ((format (printf, 2, 3))); | 816 | extern __printf(2, 3) |
799 | extern int dev_warn(const struct device *dev, const char *fmt, ...) | 817 | int dev_crit(const struct device *dev, const char *fmt, ...); |
800 | __attribute__ ((format (printf, 2, 3))); | 818 | extern __printf(2, 3) |
801 | extern int dev_notice(const struct device *dev, const char *fmt, ...) | 819 | int dev_err(const struct device *dev, const char *fmt, ...); |
802 | __attribute__ ((format (printf, 2, 3))); | 820 | extern __printf(2, 3) |
803 | extern int _dev_info(const struct device *dev, const char *fmt, ...) | 821 | int dev_warn(const struct device *dev, const char *fmt, ...); |
804 | __attribute__ ((format (printf, 2, 3))); | 822 | extern __printf(2, 3) |
823 | int dev_notice(const struct device *dev, const char *fmt, ...); | ||
824 | extern __printf(2, 3) | ||
825 | int _dev_info(const struct device *dev, const char *fmt, ...); | ||
805 | 826 | ||
806 | #else | 827 | #else |
807 | 828 | ||
808 | static inline int dev_printk(const char *level, const struct device *dev, | 829 | static inline int __dev_printk(const char *level, const struct device *dev, |
809 | const char *fmt, ...) | 830 | struct va_format *vaf) |
810 | __attribute__ ((format (printf, 3, 4))); | 831 | { return 0; } |
811 | static inline int dev_printk(const char *level, const struct device *dev, | 832 | static inline __printf(3, 4) |
812 | const char *fmt, ...) | 833 | int dev_printk(const char *level, const struct device *dev, |
813 | { return 0; } | 834 | const char *fmt, ...) |
814 | 835 | { return 0; } | |
815 | static inline int dev_emerg(const struct device *dev, const char *fmt, ...) | 836 | |
816 | __attribute__ ((format (printf, 2, 3))); | 837 | static inline __printf(2, 3) |
817 | static inline int dev_emerg(const struct device *dev, const char *fmt, ...) | 838 | int dev_emerg(const struct device *dev, const char *fmt, ...) |
818 | { return 0; } | 839 | { return 0; } |
819 | static inline int dev_crit(const struct device *dev, const char *fmt, ...) | 840 | static inline __printf(2, 3) |
820 | __attribute__ ((format (printf, 2, 3))); | 841 | int dev_crit(const struct device *dev, const char *fmt, ...) |
821 | static inline int dev_crit(const struct device *dev, const char *fmt, ...) | 842 | { return 0; } |
822 | { return 0; } | 843 | static inline __printf(2, 3) |
823 | static inline int dev_alert(const struct device *dev, const char *fmt, ...) | 844 | int dev_alert(const struct device *dev, const char *fmt, ...) |
824 | __attribute__ ((format (printf, 2, 3))); | 845 | { return 0; } |
825 | static inline int dev_alert(const struct device *dev, const char *fmt, ...) | 846 | static inline __printf(2, 3) |
826 | { return 0; } | 847 | int dev_err(const struct device *dev, const char *fmt, ...) |
827 | static inline int dev_err(const struct device *dev, const char *fmt, ...) | 848 | { return 0; } |
828 | __attribute__ ((format (printf, 2, 3))); | 849 | static inline __printf(2, 3) |
829 | static inline int dev_err(const struct device *dev, const char *fmt, ...) | 850 | int dev_warn(const struct device *dev, const char *fmt, ...) |
830 | { return 0; } | 851 | { return 0; } |
831 | static inline int dev_warn(const struct device *dev, const char *fmt, ...) | 852 | static inline __printf(2, 3) |
832 | __attribute__ ((format (printf, 2, 3))); | 853 | int dev_notice(const struct device *dev, const char *fmt, ...) |
833 | static inline int dev_warn(const struct device *dev, const char *fmt, ...) | 854 | { return 0; } |
834 | { return 0; } | 855 | static inline __printf(2, 3) |
835 | static inline int dev_notice(const struct device *dev, const char *fmt, ...) | 856 | int _dev_info(const struct device *dev, const char *fmt, ...) |
836 | __attribute__ ((format (printf, 2, 3))); | 857 | { return 0; } |
837 | static inline int dev_notice(const struct device *dev, const char *fmt, ...) | ||
838 | { return 0; } | ||
839 | static inline int _dev_info(const struct device *dev, const char *fmt, ...) | ||
840 | __attribute__ ((format (printf, 2, 3))); | ||
841 | static inline int _dev_info(const struct device *dev, const char *fmt, ...) | ||
842 | { return 0; } | ||
843 | 858 | ||
844 | #endif | 859 | #endif |
845 | 860 | ||