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.h73
1 files changed, 48 insertions, 25 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index 26e4692f2d1a..a0cd2ced31a9 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -2,6 +2,7 @@
2 * device.h - generic, centralized driver model 2 * device.h - generic, centralized driver model
3 * 3 *
4 * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org> 4 * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org>
5 * Copyright (c) 2004-2007 Greg Kroah-Hartman <gregkh@suse.de>
5 * 6 *
6 * This file is released under the GPLv2 7 * This file is released under the GPLv2
7 * 8 *
@@ -33,9 +34,24 @@ struct device;
33struct device_driver; 34struct device_driver;
34struct class; 35struct class;
35struct class_device; 36struct class_device;
37struct bus_type;
38
39struct bus_attribute {
40 struct attribute attr;
41 ssize_t (*show)(struct bus_type *, char * buf);
42 ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
43};
44
45#define BUS_ATTR(_name,_mode,_show,_store) \
46struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store)
47
48extern int __must_check bus_create_file(struct bus_type *,
49 struct bus_attribute *);
50extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
36 51
37struct bus_type { 52struct bus_type {
38 const char * name; 53 const char * name;
54 struct module * owner;
39 55
40 struct subsystem subsys; 56 struct subsystem subsys;
41 struct kset drivers; 57 struct kset drivers;
@@ -48,6 +64,8 @@ struct bus_type {
48 struct bus_attribute * bus_attrs; 64 struct bus_attribute * bus_attrs;
49 struct device_attribute * dev_attrs; 65 struct device_attribute * dev_attrs;
50 struct driver_attribute * drv_attrs; 66 struct driver_attribute * drv_attrs;
67 struct bus_attribute drivers_autoprobe_attr;
68 struct bus_attribute drivers_probe_attr;
51 69
52 int (*match)(struct device * dev, struct device_driver * drv); 70 int (*match)(struct device * dev, struct device_driver * drv);
53 int (*uevent)(struct device *dev, char **envp, 71 int (*uevent)(struct device *dev, char **envp,
@@ -60,6 +78,9 @@ struct bus_type {
60 int (*suspend_late)(struct device * dev, pm_message_t state); 78 int (*suspend_late)(struct device * dev, pm_message_t state);
61 int (*resume_early)(struct device * dev); 79 int (*resume_early)(struct device * dev);
62 int (*resume)(struct device * dev); 80 int (*resume)(struct device * dev);
81
82 unsigned int drivers_autoprobe:1;
83 unsigned int multithread_probe:1;
63}; 84};
64 85
65extern int __must_check bus_register(struct bus_type * bus); 86extern int __must_check bus_register(struct bus_type * bus);
@@ -101,40 +122,23 @@ extern int bus_unregister_notifier(struct bus_type *bus,
101#define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be 122#define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be
102 unbound */ 123 unbound */
103 124
104/* driverfs interface for exporting bus attributes */
105
106struct bus_attribute {
107 struct attribute attr;
108 ssize_t (*show)(struct bus_type *, char * buf);
109 ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
110};
111
112#define BUS_ATTR(_name,_mode,_show,_store) \
113struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store)
114
115extern int __must_check bus_create_file(struct bus_type *,
116 struct bus_attribute *);
117extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
118
119struct device_driver { 125struct device_driver {
120 const char * name; 126 const char * name;
121 struct bus_type * bus; 127 struct bus_type * bus;
122 128
123 struct completion unloaded;
124 struct kobject kobj; 129 struct kobject kobj;
125 struct klist klist_devices; 130 struct klist klist_devices;
126 struct klist_node knode_bus; 131 struct klist_node knode_bus;
127 132
128 struct module * owner; 133 struct module * owner;
129 const char * mod_name; /* used for built-in modules */ 134 const char * mod_name; /* used for built-in modules */
135 struct module_kobject * mkobj;
130 136
131 int (*probe) (struct device * dev); 137 int (*probe) (struct device * dev);
132 int (*remove) (struct device * dev); 138 int (*remove) (struct device * dev);
133 void (*shutdown) (struct device * dev); 139 void (*shutdown) (struct device * dev);
134 int (*suspend) (struct device * dev, pm_message_t state); 140 int (*suspend) (struct device * dev, pm_message_t state);
135 int (*resume) (struct device * dev); 141 int (*resume) (struct device * dev);
136
137 unsigned int multithread_probe:1;
138}; 142};
139 143
140 144
@@ -146,7 +150,7 @@ extern void put_driver(struct device_driver * drv);
146extern struct device_driver *driver_find(const char *name, struct bus_type *bus); 150extern struct device_driver *driver_find(const char *name, struct bus_type *bus);
147extern int driver_probe_done(void); 151extern int driver_probe_done(void);
148 152
149/* driverfs interface for exporting driver attributes */ 153/* sysfs interface for exporting driver attributes */
150 154
151struct driver_attribute { 155struct driver_attribute {
152 struct attribute attr; 156 struct attribute attr;
@@ -179,10 +183,9 @@ struct class {
179 struct list_head children; 183 struct list_head children;
180 struct list_head devices; 184 struct list_head devices;
181 struct list_head interfaces; 185 struct list_head interfaces;
186 struct kset class_dirs;
182 struct semaphore sem; /* locks both the children and interfaces lists */ 187 struct semaphore sem; /* locks both the children and interfaces lists */
183 188
184 struct kobject *virtual_dir;
185
186 struct class_attribute * class_attrs; 189 struct class_attribute * class_attrs;
187 struct class_device_attribute * class_dev_attrs; 190 struct class_device_attribute * class_dev_attrs;
188 struct device_attribute * dev_attrs; 191 struct device_attribute * dev_attrs;
@@ -293,8 +296,6 @@ extern void class_device_initialize(struct class_device *);
293extern int __must_check class_device_add(struct class_device *); 296extern int __must_check class_device_add(struct class_device *);
294extern void class_device_del(struct class_device *); 297extern void class_device_del(struct class_device *);
295 298
296extern int class_device_rename(struct class_device *, char *);
297
298extern struct class_device * class_device_get(struct class_device *); 299extern struct class_device * class_device_get(struct class_device *);
299extern void class_device_put(struct class_device *); 300extern void class_device_put(struct class_device *);
300 301
@@ -328,11 +329,23 @@ extern struct class_device *class_device_create(struct class *cls,
328 __attribute__((format(printf,5,6))); 329 __attribute__((format(printf,5,6)));
329extern void class_device_destroy(struct class *cls, dev_t devt); 330extern void class_device_destroy(struct class *cls, dev_t devt);
330 331
332/*
333 * The type of device, "struct device" is embedded in. A class
334 * or bus can contain devices of different types
335 * like "partitions" and "disks", "mouse" and "event".
336 * This identifies the device type and carries type-specific
337 * information, equivalent to the kobj_type of a kobject.
338 * If "name" is specified, the uevent will contain it in
339 * the DEVTYPE variable.
340 */
331struct device_type { 341struct device_type {
332 struct device_attribute *attrs; 342 const char *name;
343 struct attribute_group **groups;
333 int (*uevent)(struct device *dev, char **envp, int num_envp, 344 int (*uevent)(struct device *dev, char **envp, int num_envp,
334 char *buffer, int buffer_size); 345 char *buffer, int buffer_size);
335 void (*release)(struct device *dev); 346 void (*release)(struct device *dev);
347 int (*suspend)(struct device * dev, pm_message_t state);
348 int (*resume)(struct device * dev);
336}; 349};
337 350
338/* interface for exporting device attributes */ 351/* interface for exporting device attributes */
@@ -354,6 +367,12 @@ extern int __must_check device_create_bin_file(struct device *dev,
354 struct bin_attribute *attr); 367 struct bin_attribute *attr);
355extern void device_remove_bin_file(struct device *dev, 368extern void device_remove_bin_file(struct device *dev,
356 struct bin_attribute *attr); 369 struct bin_attribute *attr);
370extern int device_schedule_callback_owner(struct device *dev,
371 void (*func)(struct device *), struct module *owner);
372
373/* This is a macro to avoid include problems with THIS_MODULE */
374#define device_schedule_callback(dev, func) \
375 device_schedule_callback_owner(dev, func, THIS_MODULE)
357 376
358/* device resource management */ 377/* device resource management */
359typedef void (*dr_release_t)(struct device *dev, void *res); 378typedef void (*dr_release_t)(struct device *dev, void *res);
@@ -552,7 +571,11 @@ extern const char *dev_driver_string(struct device *dev);
552#define dev_dbg(dev, format, arg...) \ 571#define dev_dbg(dev, format, arg...) \
553 dev_printk(KERN_DEBUG , dev , format , ## arg) 572 dev_printk(KERN_DEBUG , dev , format , ## arg)
554#else 573#else
555#define dev_dbg(dev, format, arg...) do { (void)(dev); } while (0) 574static inline int __attribute__ ((format (printf, 2, 3)))
575dev_dbg(struct device * dev, const char * fmt, ...)
576{
577 return 0;
578}
556#endif 579#endif
557 580
558#define dev_err(dev, format, arg...) \ 581#define dev_err(dev, format, arg...) \