diff options
Diffstat (limited to 'include/linux/device.h')
-rw-r--r-- | include/linux/device.h | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index df94c0de53f2..7b781a72b293 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/config.h> | 14 | #include <linux/config.h> |
15 | #include <linux/ioport.h> | 15 | #include <linux/ioport.h> |
16 | #include <linux/kobject.h> | 16 | #include <linux/kobject.h> |
17 | #include <linux/klist.h> | ||
17 | #include <linux/list.h> | 18 | #include <linux/list.h> |
18 | #include <linux/types.h> | 19 | #include <linux/types.h> |
19 | #include <linux/module.h> | 20 | #include <linux/module.h> |
@@ -44,14 +45,15 @@ struct device; | |||
44 | struct device_driver; | 45 | struct device_driver; |
45 | struct class; | 46 | struct class; |
46 | struct class_device; | 47 | struct class_device; |
47 | struct class_simple; | ||
48 | 48 | ||
49 | struct bus_type { | 49 | struct bus_type { |
50 | char * name; | 50 | const char * name; |
51 | 51 | ||
52 | struct subsystem subsys; | 52 | struct subsystem subsys; |
53 | struct kset drivers; | 53 | struct kset drivers; |
54 | struct kset devices; | 54 | struct kset devices; |
55 | struct klist klist_devices; | ||
56 | struct klist klist_drivers; | ||
55 | 57 | ||
56 | struct bus_attribute * bus_attrs; | 58 | struct bus_attribute * bus_attrs; |
57 | struct device_attribute * dev_attrs; | 59 | struct device_attribute * dev_attrs; |
@@ -98,17 +100,18 @@ extern int bus_create_file(struct bus_type *, struct bus_attribute *); | |||
98 | extern void bus_remove_file(struct bus_type *, struct bus_attribute *); | 100 | extern void bus_remove_file(struct bus_type *, struct bus_attribute *); |
99 | 101 | ||
100 | struct device_driver { | 102 | struct device_driver { |
101 | char * name; | 103 | const char * name; |
102 | struct bus_type * bus; | 104 | struct bus_type * bus; |
103 | 105 | ||
104 | struct completion unloaded; | 106 | struct completion unloaded; |
105 | struct kobject kobj; | 107 | struct kobject kobj; |
106 | struct list_head devices; | 108 | struct klist klist_devices; |
109 | struct klist_node knode_bus; | ||
107 | 110 | ||
108 | struct module * owner; | 111 | struct module * owner; |
109 | 112 | ||
110 | int (*probe) (struct device * dev); | 113 | int (*probe) (struct device * dev); |
111 | int (*remove) (struct device * dev); | 114 | int (*remove) (struct device * dev); |
112 | void (*shutdown) (struct device * dev); | 115 | void (*shutdown) (struct device * dev); |
113 | int (*suspend) (struct device * dev, pm_message_t state, u32 level); | 116 | int (*suspend) (struct device * dev, pm_message_t state, u32 level); |
114 | int (*resume) (struct device * dev, u32 level); | 117 | int (*resume) (struct device * dev, u32 level); |
@@ -137,12 +140,16 @@ struct driver_attribute driver_attr_##_name = __ATTR(_name,_mode,_show,_store) | |||
137 | extern int driver_create_file(struct device_driver *, struct driver_attribute *); | 140 | extern int driver_create_file(struct device_driver *, struct driver_attribute *); |
138 | extern void driver_remove_file(struct device_driver *, struct driver_attribute *); | 141 | extern void driver_remove_file(struct device_driver *, struct driver_attribute *); |
139 | 142 | ||
143 | extern int driver_for_each_device(struct device_driver * drv, struct device * start, | ||
144 | void * data, int (*fn)(struct device *, void *)); | ||
145 | |||
140 | 146 | ||
141 | /* | 147 | /* |
142 | * device classes | 148 | * device classes |
143 | */ | 149 | */ |
144 | struct class { | 150 | struct class { |
145 | char * name; | 151 | const char * name; |
152 | struct module * owner; | ||
146 | 153 | ||
147 | struct subsystem subsys; | 154 | struct subsystem subsys; |
148 | struct list_head children; | 155 | struct list_head children; |
@@ -185,6 +192,7 @@ struct class_device { | |||
185 | struct kobject kobj; | 192 | struct kobject kobj; |
186 | struct class * class; /* required */ | 193 | struct class * class; /* required */ |
187 | dev_t devt; /* dev_t, creates the sysfs "dev" */ | 194 | dev_t devt; /* dev_t, creates the sysfs "dev" */ |
195 | struct class_device_attribute *devt_attr; | ||
188 | struct device * dev; /* not necessary, but nice to have */ | 196 | struct device * dev; /* not necessary, but nice to have */ |
189 | void * class_data; /* class-specific data */ | 197 | void * class_data; /* class-specific data */ |
190 | 198 | ||
@@ -245,26 +253,28 @@ struct class_interface { | |||
245 | extern int class_interface_register(struct class_interface *); | 253 | extern int class_interface_register(struct class_interface *); |
246 | extern void class_interface_unregister(struct class_interface *); | 254 | extern void class_interface_unregister(struct class_interface *); |
247 | 255 | ||
248 | /* interface for class simple stuff */ | 256 | extern struct class *class_create(struct module *owner, char *name); |
249 | extern struct class_simple *class_simple_create(struct module *owner, char *name); | 257 | extern void class_destroy(struct class *cls); |
250 | extern void class_simple_destroy(struct class_simple *cs); | 258 | extern struct class_device *class_device_create(struct class *cls, dev_t devt, |
251 | extern struct class_device *class_simple_device_add(struct class_simple *cs, dev_t dev, struct device *device, const char *fmt, ...) | 259 | struct device *device, char *fmt, ...) |
252 | __attribute__((format(printf,4,5))); | 260 | __attribute__((format(printf,4,5))); |
253 | extern int class_simple_set_hotplug(struct class_simple *, | 261 | extern void class_device_destroy(struct class *cls, dev_t devt); |
254 | int (*hotplug)(struct class_device *dev, char **envp, int num_envp, char *buffer, int buffer_size)); | ||
255 | extern void class_simple_device_remove(dev_t dev); | ||
256 | 262 | ||
257 | 263 | ||
258 | struct device { | 264 | struct device { |
259 | struct list_head node; /* node in sibling list */ | 265 | struct klist klist_children; |
260 | struct list_head bus_list; /* node in bus's list */ | 266 | struct klist_node knode_parent; /* node in sibling list */ |
261 | struct list_head driver_list; | 267 | struct klist_node knode_driver; |
262 | struct list_head children; | 268 | struct klist_node knode_bus; |
263 | struct device * parent; | 269 | struct device * parent; |
264 | 270 | ||
265 | struct kobject kobj; | 271 | struct kobject kobj; |
266 | char bus_id[BUS_ID_SIZE]; /* position on parent bus */ | 272 | char bus_id[BUS_ID_SIZE]; /* position on parent bus */ |
267 | 273 | ||
274 | struct semaphore sem; /* semaphore to synchronize calls to | ||
275 | * its driver. | ||
276 | */ | ||
277 | |||
268 | struct bus_type * bus; /* type of bus device is on */ | 278 | struct bus_type * bus; /* type of bus device is on */ |
269 | struct device_driver *driver; /* which driver has allocated this | 279 | struct device_driver *driver; /* which driver has allocated this |
270 | device */ | 280 | device */ |
@@ -288,12 +298,6 @@ struct device { | |||
288 | void (*release)(struct device * dev); | 298 | void (*release)(struct device * dev); |
289 | }; | 299 | }; |
290 | 300 | ||
291 | static inline struct device * | ||
292 | list_to_dev(struct list_head *node) | ||
293 | { | ||
294 | return list_entry(node, struct device, node); | ||
295 | } | ||
296 | |||
297 | static inline void * | 301 | static inline void * |
298 | dev_get_drvdata (struct device *dev) | 302 | dev_get_drvdata (struct device *dev) |
299 | { | 303 | { |
@@ -321,7 +325,6 @@ extern int device_for_each_child(struct device *, void *, | |||
321 | * Manual binding of a device to driver. See drivers/base/bus.c | 325 | * Manual binding of a device to driver. See drivers/base/bus.c |
322 | * for information on use. | 326 | * for information on use. |
323 | */ | 327 | */ |
324 | extern int driver_probe_device(struct device_driver * drv, struct device * dev); | ||
325 | extern void device_bind_driver(struct device * dev); | 328 | extern void device_bind_driver(struct device * dev); |
326 | extern void device_release_driver(struct device * dev); | 329 | extern void device_release_driver(struct device * dev); |
327 | extern int device_attach(struct device * dev); | 330 | extern int device_attach(struct device * dev); |
@@ -332,8 +335,10 @@ extern void driver_attach(struct device_driver * drv); | |||
332 | 335 | ||
333 | struct device_attribute { | 336 | struct device_attribute { |
334 | struct attribute attr; | 337 | struct attribute attr; |
335 | ssize_t (*show)(struct device * dev, char * buf); | 338 | ssize_t (*show)(struct device *dev, struct device_attribute *attr, |
336 | ssize_t (*store)(struct device * dev, const char * buf, size_t count); | 339 | char *buf); |
340 | ssize_t (*store)(struct device *dev, struct device_attribute *attr, | ||
341 | const char *buf, size_t count); | ||
337 | }; | 342 | }; |
338 | 343 | ||
339 | #define DEVICE_ATTR(_name,_mode,_show,_store) \ | 344 | #define DEVICE_ATTR(_name,_mode,_show,_store) \ |
@@ -360,13 +365,12 @@ extern int (*platform_notify_remove)(struct device * dev); | |||
360 | */ | 365 | */ |
361 | extern struct device * get_device(struct device * dev); | 366 | extern struct device * get_device(struct device * dev); |
362 | extern void put_device(struct device * dev); | 367 | extern void put_device(struct device * dev); |
363 | extern struct device *device_find(const char *name, struct bus_type *bus); | ||
364 | 368 | ||
365 | 369 | ||
366 | /* drivers/base/platform.c */ | 370 | /* drivers/base/platform.c */ |
367 | 371 | ||
368 | struct platform_device { | 372 | struct platform_device { |
369 | char * name; | 373 | const char * name; |
370 | u32 id; | 374 | u32 id; |
371 | struct device dev; | 375 | struct device dev; |
372 | u32 num_resources; | 376 | u32 num_resources; |