diff options
Diffstat (limited to 'include/linux/device.h')
-rw-r--r-- | include/linux/device.h | 63 |
1 files changed, 39 insertions, 24 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index ed4e39f2c423..aca31bf7d8ed 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -2,7 +2,8 @@ | |||
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 | * Copyright (c) 2004-2009 Greg Kroah-Hartman <gregkh@suse.de> |
6 | * Copyright (c) 2008-2009 Novell Inc. | ||
6 | * | 7 | * |
7 | * This file is released under the GPLv2 | 8 | * This file is released under the GPLv2 |
8 | * | 9 | * |
@@ -25,8 +26,6 @@ | |||
25 | #include <asm/atomic.h> | 26 | #include <asm/atomic.h> |
26 | #include <asm/device.h> | 27 | #include <asm/device.h> |
27 | 28 | ||
28 | #define BUS_ID_SIZE 20 | ||
29 | |||
30 | struct device; | 29 | struct device; |
31 | struct device_private; | 30 | struct device_private; |
32 | struct device_driver; | 31 | struct device_driver; |
@@ -64,7 +63,7 @@ struct bus_type { | |||
64 | int (*suspend)(struct device *dev, pm_message_t state); | 63 | int (*suspend)(struct device *dev, pm_message_t state); |
65 | int (*resume)(struct device *dev); | 64 | int (*resume)(struct device *dev); |
66 | 65 | ||
67 | struct dev_pm_ops *pm; | 66 | const struct dev_pm_ops *pm; |
68 | 67 | ||
69 | struct bus_type_private *p; | 68 | struct bus_type_private *p; |
70 | }; | 69 | }; |
@@ -132,9 +131,9 @@ struct device_driver { | |||
132 | void (*shutdown) (struct device *dev); | 131 | void (*shutdown) (struct device *dev); |
133 | int (*suspend) (struct device *dev, pm_message_t state); | 132 | int (*suspend) (struct device *dev, pm_message_t state); |
134 | int (*resume) (struct device *dev); | 133 | int (*resume) (struct device *dev); |
135 | struct attribute_group **groups; | 134 | const struct attribute_group **groups; |
136 | 135 | ||
137 | struct dev_pm_ops *pm; | 136 | const struct dev_pm_ops *pm; |
138 | 137 | ||
139 | struct driver_private *p; | 138 | struct driver_private *p; |
140 | }; | 139 | }; |
@@ -194,7 +193,7 @@ struct class { | |||
194 | struct kobject *dev_kobj; | 193 | struct kobject *dev_kobj; |
195 | 194 | ||
196 | int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); | 195 | int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); |
197 | char *(*nodename)(struct device *dev); | 196 | char *(*devnode)(struct device *dev, mode_t *mode); |
198 | 197 | ||
199 | void (*class_release)(struct class *class); | 198 | void (*class_release)(struct class *class); |
200 | void (*dev_release)(struct device *dev); | 199 | void (*dev_release)(struct device *dev); |
@@ -202,7 +201,8 @@ struct class { | |||
202 | int (*suspend)(struct device *dev, pm_message_t state); | 201 | int (*suspend)(struct device *dev, pm_message_t state); |
203 | int (*resume)(struct device *dev); | 202 | int (*resume)(struct device *dev); |
204 | 203 | ||
205 | struct dev_pm_ops *pm; | 204 | const struct dev_pm_ops *pm; |
205 | |||
206 | struct class_private *p; | 206 | struct class_private *p; |
207 | }; | 207 | }; |
208 | 208 | ||
@@ -225,6 +225,14 @@ extern void class_unregister(struct class *class); | |||
225 | __class_register(class, &__key); \ | 225 | __class_register(class, &__key); \ |
226 | }) | 226 | }) |
227 | 227 | ||
228 | struct class_compat; | ||
229 | struct class_compat *class_compat_register(const char *name); | ||
230 | void class_compat_unregister(struct class_compat *cls); | ||
231 | int class_compat_create_link(struct class_compat *cls, struct device *dev, | ||
232 | struct device *device_link); | ||
233 | void class_compat_remove_link(struct class_compat *cls, struct device *dev, | ||
234 | struct device *device_link); | ||
235 | |||
228 | extern void class_dev_iter_init(struct class_dev_iter *iter, | 236 | extern void class_dev_iter_init(struct class_dev_iter *iter, |
229 | struct class *class, | 237 | struct class *class, |
230 | struct device *start, | 238 | struct device *start, |
@@ -288,12 +296,12 @@ extern void class_destroy(struct class *cls); | |||
288 | */ | 296 | */ |
289 | struct device_type { | 297 | struct device_type { |
290 | const char *name; | 298 | const char *name; |
291 | struct attribute_group **groups; | 299 | const struct attribute_group **groups; |
292 | int (*uevent)(struct device *dev, struct kobj_uevent_env *env); | 300 | int (*uevent)(struct device *dev, struct kobj_uevent_env *env); |
293 | char *(*nodename)(struct device *dev); | 301 | char *(*devnode)(struct device *dev, mode_t *mode); |
294 | void (*release)(struct device *dev); | 302 | void (*release)(struct device *dev); |
295 | 303 | ||
296 | struct dev_pm_ops *pm; | 304 | const struct dev_pm_ops *pm; |
297 | }; | 305 | }; |
298 | 306 | ||
299 | /* interface for exporting device attributes */ | 307 | /* interface for exporting device attributes */ |
@@ -382,7 +390,6 @@ struct device { | |||
382 | struct bus_type *bus; /* type of bus device is on */ | 390 | struct bus_type *bus; /* type of bus device is on */ |
383 | struct device_driver *driver; /* which driver has allocated this | 391 | struct device_driver *driver; /* which driver has allocated this |
384 | device */ | 392 | device */ |
385 | void *driver_data; /* data private to the driver */ | ||
386 | void *platform_data; /* Platform specific data, device | 393 | void *platform_data; /* Platform specific data, device |
387 | core doesn't touch it */ | 394 | core doesn't touch it */ |
388 | struct dev_pm_info power; | 395 | struct dev_pm_info power; |
@@ -413,7 +420,7 @@ struct device { | |||
413 | 420 | ||
414 | struct klist_node knode_class; | 421 | struct klist_node knode_class; |
415 | struct class *class; | 422 | struct class *class; |
416 | struct attribute_group **groups; /* optional groups */ | 423 | const struct attribute_group **groups; /* optional groups */ |
417 | 424 | ||
418 | void (*release)(struct device *dev); | 425 | void (*release)(struct device *dev); |
419 | }; | 426 | }; |
@@ -448,16 +455,6 @@ static inline void set_dev_node(struct device *dev, int node) | |||
448 | } | 455 | } |
449 | #endif | 456 | #endif |
450 | 457 | ||
451 | static inline void *dev_get_drvdata(const struct device *dev) | ||
452 | { | ||
453 | return dev->driver_data; | ||
454 | } | ||
455 | |||
456 | static inline void dev_set_drvdata(struct device *dev, void *data) | ||
457 | { | ||
458 | dev->driver_data = data; | ||
459 | } | ||
460 | |||
461 | static inline unsigned int dev_get_uevent_suppress(const struct device *dev) | 458 | static inline unsigned int dev_get_uevent_suppress(const struct device *dev) |
462 | { | 459 | { |
463 | return dev->kobj.uevent_suppress; | 460 | return dev->kobj.uevent_suppress; |
@@ -490,7 +487,10 @@ extern struct device *device_find_child(struct device *dev, void *data, | |||
490 | extern int device_rename(struct device *dev, char *new_name); | 487 | extern int device_rename(struct device *dev, char *new_name); |
491 | extern int device_move(struct device *dev, struct device *new_parent, | 488 | extern int device_move(struct device *dev, struct device *new_parent, |
492 | enum dpm_order dpm_order); | 489 | enum dpm_order dpm_order); |
493 | extern const char *device_get_nodename(struct device *dev, const char **tmp); | 490 | extern const char *device_get_devnode(struct device *dev, |
491 | mode_t *mode, const char **tmp); | ||
492 | extern void *dev_get_drvdata(const struct device *dev); | ||
493 | extern void dev_set_drvdata(struct device *dev, void *data); | ||
494 | 494 | ||
495 | /* | 495 | /* |
496 | * Root device objects for grouping under /sys/devices | 496 | * Root device objects for grouping under /sys/devices |
@@ -503,6 +503,11 @@ static inline struct device *root_device_register(const char *name) | |||
503 | } | 503 | } |
504 | extern void root_device_unregister(struct device *root); | 504 | extern void root_device_unregister(struct device *root); |
505 | 505 | ||
506 | static inline void *dev_get_platdata(const struct device *dev) | ||
507 | { | ||
508 | return dev->platform_data; | ||
509 | } | ||
510 | |||
506 | /* | 511 | /* |
507 | * Manual binding of a device to driver. See drivers/base/bus.c | 512 | * Manual binding of a device to driver. See drivers/base/bus.c |
508 | * for information on use. | 513 | * for information on use. |
@@ -548,6 +553,16 @@ extern void put_device(struct device *dev); | |||
548 | 553 | ||
549 | extern void wait_for_device_probe(void); | 554 | extern void wait_for_device_probe(void); |
550 | 555 | ||
556 | #ifdef CONFIG_DEVTMPFS | ||
557 | extern int devtmpfs_create_node(struct device *dev); | ||
558 | extern int devtmpfs_delete_node(struct device *dev); | ||
559 | extern int devtmpfs_mount(const char *mountpoint); | ||
560 | #else | ||
561 | static inline int devtmpfs_create_node(struct device *dev) { return 0; } | ||
562 | static inline int devtmpfs_delete_node(struct device *dev) { return 0; } | ||
563 | static inline int devtmpfs_mount(const char *mountpoint) { return 0; } | ||
564 | #endif | ||
565 | |||
551 | /* drivers/base/power/shutdown.c */ | 566 | /* drivers/base/power/shutdown.c */ |
552 | extern void device_shutdown(void); | 567 | extern void device_shutdown(void); |
553 | 568 | ||