aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/device.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/device.h')
-rw-r--r--include/linux/device.h141
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;
29struct device_private; 29struct device_private;
30struct device_driver; 30struct device_driver;
31struct driver_private; 31struct driver_private;
32struct module;
32struct class; 33struct class;
33struct subsys_private; 34struct subsys_private;
34struct bus_type; 35struct bus_type;
35struct device_node; 36struct device_node;
37struct iommu_ops;
36 38
37struct bus_attribute { 39struct 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
617extern int dev_set_name(struct device *dev, const char *name, ...) 626extern __printf(2, 3)
618 __attribute__((format(printf, 2, 3))); 627int dev_set_name(struct device *dev, const char *name, ...);
619 628
620#ifdef CONFIG_NUMA 629#ifdef CONFIG_NUMA
621static inline int dev_to_node(struct device *dev) 630static 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
648static inline struct pm_subsys_data *dev_to_psd(struct device *dev)
649{
650 return dev ? dev->power.subsys_data : NULL;
651}
652
639static inline unsigned int dev_get_uevent_suppress(const struct device *dev) 653static 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 */
711extern struct device *__root_device_register(const char *name, 725extern struct device *__root_device_register(const char *name,
712 struct module *owner); 726 struct module *owner);
713static 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
717extern void root_device_unregister(struct device *root); 735extern void root_device_unregister(struct device *root);
718 736
719static inline void *dev_get_platdata(const struct device *dev) 737static 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);
743extern struct device *device_create(struct class *cls, struct device *parent, 761extern __printf(5, 6)
744 dev_t devt, void *drvdata, 762struct 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, ...);
747extern void device_destroy(struct class *cls, dev_t devt); 765extern 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
788extern int dev_printk(const char *level, const struct device *dev, 806extern 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))); 808extern __printf(3, 4)
791extern int dev_emerg(const struct device *dev, const char *fmt, ...) 809int dev_printk(const char *level, const struct device *dev,
792 __attribute__ ((format (printf, 2, 3))); 810 const char *fmt, ...)
793extern int dev_alert(const struct device *dev, const char *fmt, ...) 811 ;
794 __attribute__ ((format (printf, 2, 3))); 812extern __printf(2, 3)
795extern int dev_crit(const struct device *dev, const char *fmt, ...) 813int dev_emerg(const struct device *dev, const char *fmt, ...);
796 __attribute__ ((format (printf, 2, 3))); 814extern __printf(2, 3)
797extern int dev_err(const struct device *dev, const char *fmt, ...) 815int dev_alert(const struct device *dev, const char *fmt, ...);
798 __attribute__ ((format (printf, 2, 3))); 816extern __printf(2, 3)
799extern int dev_warn(const struct device *dev, const char *fmt, ...) 817int dev_crit(const struct device *dev, const char *fmt, ...);
800 __attribute__ ((format (printf, 2, 3))); 818extern __printf(2, 3)
801extern int dev_notice(const struct device *dev, const char *fmt, ...) 819int dev_err(const struct device *dev, const char *fmt, ...);
802 __attribute__ ((format (printf, 2, 3))); 820extern __printf(2, 3)
803extern int _dev_info(const struct device *dev, const char *fmt, ...) 821int dev_warn(const struct device *dev, const char *fmt, ...);
804 __attribute__ ((format (printf, 2, 3))); 822extern __printf(2, 3)
823int dev_notice(const struct device *dev, const char *fmt, ...);
824extern __printf(2, 3)
825int _dev_info(const struct device *dev, const char *fmt, ...);
805 826
806#else 827#else
807 828
808static inline int dev_printk(const char *level, const struct device *dev, 829static 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; }
811static inline int dev_printk(const char *level, const struct device *dev, 832static inline __printf(3, 4)
812 const char *fmt, ...) 833int dev_printk(const char *level, const struct device *dev,
813 { return 0; } 834 const char *fmt, ...)
814 835{ return 0; }
815static inline int dev_emerg(const struct device *dev, const char *fmt, ...) 836
816 __attribute__ ((format (printf, 2, 3))); 837static inline __printf(2, 3)
817static inline int dev_emerg(const struct device *dev, const char *fmt, ...) 838int dev_emerg(const struct device *dev, const char *fmt, ...)
818 { return 0; } 839{ return 0; }
819static inline int dev_crit(const struct device *dev, const char *fmt, ...) 840static inline __printf(2, 3)
820 __attribute__ ((format (printf, 2, 3))); 841int dev_crit(const struct device *dev, const char *fmt, ...)
821static inline int dev_crit(const struct device *dev, const char *fmt, ...) 842{ return 0; }
822 { return 0; } 843static inline __printf(2, 3)
823static inline int dev_alert(const struct device *dev, const char *fmt, ...) 844int dev_alert(const struct device *dev, const char *fmt, ...)
824 __attribute__ ((format (printf, 2, 3))); 845{ return 0; }
825static inline int dev_alert(const struct device *dev, const char *fmt, ...) 846static inline __printf(2, 3)
826 { return 0; } 847int dev_err(const struct device *dev, const char *fmt, ...)
827static inline int dev_err(const struct device *dev, const char *fmt, ...) 848{ return 0; }
828 __attribute__ ((format (printf, 2, 3))); 849static inline __printf(2, 3)
829static inline int dev_err(const struct device *dev, const char *fmt, ...) 850int dev_warn(const struct device *dev, const char *fmt, ...)
830 { return 0; } 851{ return 0; }
831static inline int dev_warn(const struct device *dev, const char *fmt, ...) 852static inline __printf(2, 3)
832 __attribute__ ((format (printf, 2, 3))); 853int dev_notice(const struct device *dev, const char *fmt, ...)
833static inline int dev_warn(const struct device *dev, const char *fmt, ...) 854{ return 0; }
834 { return 0; } 855static inline __printf(2, 3)
835static inline int dev_notice(const struct device *dev, const char *fmt, ...) 856int _dev_info(const struct device *dev, const char *fmt, ...)
836 __attribute__ ((format (printf, 2, 3))); 857{ return 0; }
837static inline int dev_notice(const struct device *dev, const char *fmt, ...)
838 { return 0; }
839static inline int _dev_info(const struct device *dev, const char *fmt, ...)
840 __attribute__ ((format (printf, 2, 3)));
841static inline int _dev_info(const struct device *dev, const char *fmt, ...)
842 { return 0; }
843 858
844#endif 859#endif
845 860