diff options
Diffstat (limited to 'include/linux/device.h')
| -rw-r--r-- | include/linux/device.h | 69 |
1 files changed, 45 insertions, 24 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 5cf30e95c8b6..a0cd2ced31a9 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -34,9 +34,24 @@ struct device; | |||
| 34 | struct device_driver; | 34 | struct device_driver; |
| 35 | struct class; | 35 | struct class; |
| 36 | struct class_device; | 36 | struct class_device; |
| 37 | struct bus_type; | ||
| 38 | |||
| 39 | struct 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) \ | ||
| 46 | struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store) | ||
| 47 | |||
| 48 | extern int __must_check bus_create_file(struct bus_type *, | ||
| 49 | struct bus_attribute *); | ||
| 50 | extern void bus_remove_file(struct bus_type *, struct bus_attribute *); | ||
| 37 | 51 | ||
| 38 | struct bus_type { | 52 | struct bus_type { |
| 39 | const char * name; | 53 | const char * name; |
| 54 | struct module * owner; | ||
| 40 | 55 | ||
| 41 | struct subsystem subsys; | 56 | struct subsystem subsys; |
| 42 | struct kset drivers; | 57 | struct kset drivers; |
| @@ -49,6 +64,8 @@ struct bus_type { | |||
| 49 | struct bus_attribute * bus_attrs; | 64 | struct bus_attribute * bus_attrs; |
| 50 | struct device_attribute * dev_attrs; | 65 | struct device_attribute * dev_attrs; |
| 51 | 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; | ||
| 52 | 69 | ||
| 53 | int (*match)(struct device * dev, struct device_driver * drv); | 70 | int (*match)(struct device * dev, struct device_driver * drv); |
| 54 | int (*uevent)(struct device *dev, char **envp, | 71 | int (*uevent)(struct device *dev, char **envp, |
| @@ -61,6 +78,9 @@ struct bus_type { | |||
| 61 | int (*suspend_late)(struct device * dev, pm_message_t state); | 78 | int (*suspend_late)(struct device * dev, pm_message_t state); |
| 62 | int (*resume_early)(struct device * dev); | 79 | int (*resume_early)(struct device * dev); |
| 63 | int (*resume)(struct device * dev); | 80 | int (*resume)(struct device * dev); |
| 81 | |||
| 82 | unsigned int drivers_autoprobe:1; | ||
| 83 | unsigned int multithread_probe:1; | ||
| 64 | }; | 84 | }; |
| 65 | 85 | ||
| 66 | extern int __must_check bus_register(struct bus_type * bus); | 86 | extern int __must_check bus_register(struct bus_type * bus); |
| @@ -102,26 +122,10 @@ extern int bus_unregister_notifier(struct bus_type *bus, | |||
| 102 | #define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be | 122 | #define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be |
| 103 | unbound */ | 123 | unbound */ |
| 104 | 124 | ||
| 105 | /* sysfs interface for exporting bus attributes */ | ||
| 106 | |||
| 107 | struct bus_attribute { | ||
| 108 | struct attribute attr; | ||
| 109 | ssize_t (*show)(struct bus_type *, char * buf); | ||
| 110 | ssize_t (*store)(struct bus_type *, const char * buf, size_t count); | ||
| 111 | }; | ||
| 112 | |||
| 113 | #define BUS_ATTR(_name,_mode,_show,_store) \ | ||
| 114 | struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store) | ||
| 115 | |||
| 116 | extern int __must_check bus_create_file(struct bus_type *, | ||
| 117 | struct bus_attribute *); | ||
| 118 | extern void bus_remove_file(struct bus_type *, struct bus_attribute *); | ||
| 119 | |||
| 120 | struct device_driver { | 125 | struct device_driver { |
| 121 | const char * name; | 126 | const char * name; |
| 122 | struct bus_type * bus; | 127 | struct bus_type * bus; |
| 123 | 128 | ||
| 124 | struct completion unloaded; | ||
| 125 | struct kobject kobj; | 129 | struct kobject kobj; |
| 126 | struct klist klist_devices; | 130 | struct klist klist_devices; |
| 127 | struct klist_node knode_bus; | 131 | struct klist_node knode_bus; |
| @@ -135,8 +139,6 @@ struct device_driver { | |||
| 135 | void (*shutdown) (struct device * dev); | 139 | void (*shutdown) (struct device * dev); |
| 136 | int (*suspend) (struct device * dev, pm_message_t state); | 140 | int (*suspend) (struct device * dev, pm_message_t state); |
| 137 | int (*resume) (struct device * dev); | 141 | int (*resume) (struct device * dev); |
| 138 | |||
| 139 | unsigned int multithread_probe:1; | ||
| 140 | }; | 142 | }; |
| 141 | 143 | ||
| 142 | 144 | ||
| @@ -181,10 +183,9 @@ struct class { | |||
| 181 | struct list_head children; | 183 | struct list_head children; |
| 182 | struct list_head devices; | 184 | struct list_head devices; |
| 183 | struct list_head interfaces; | 185 | struct list_head interfaces; |
| 186 | struct kset class_dirs; | ||
| 184 | struct semaphore sem; /* locks both the children and interfaces lists */ | 187 | struct semaphore sem; /* locks both the children and interfaces lists */ |
| 185 | 188 | ||
| 186 | struct kobject *virtual_dir; | ||
| 187 | |||
| 188 | struct class_attribute * class_attrs; | 189 | struct class_attribute * class_attrs; |
| 189 | struct class_device_attribute * class_dev_attrs; | 190 | struct class_device_attribute * class_dev_attrs; |
| 190 | struct device_attribute * dev_attrs; | 191 | struct device_attribute * dev_attrs; |
| @@ -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))); |
| 329 | extern void class_device_destroy(struct class *cls, dev_t devt); | 330 | extern 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 | */ | ||
| 331 | struct device_type { | 341 | struct 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,8 +367,12 @@ extern int __must_check device_create_bin_file(struct device *dev, | |||
| 354 | struct bin_attribute *attr); | 367 | struct bin_attribute *attr); |
| 355 | extern void device_remove_bin_file(struct device *dev, | 368 | extern void device_remove_bin_file(struct device *dev, |
| 356 | struct bin_attribute *attr); | 369 | struct bin_attribute *attr); |
| 357 | extern int device_schedule_callback(struct device *dev, | 370 | extern int device_schedule_callback_owner(struct device *dev, |
| 358 | void (*func)(struct device *)); | 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) | ||
| 359 | 376 | ||
| 360 | /* device resource management */ | 377 | /* device resource management */ |
| 361 | typedef void (*dr_release_t)(struct device *dev, void *res); | 378 | typedef void (*dr_release_t)(struct device *dev, void *res); |
| @@ -554,7 +571,11 @@ extern const char *dev_driver_string(struct device *dev); | |||
| 554 | #define dev_dbg(dev, format, arg...) \ | 571 | #define dev_dbg(dev, format, arg...) \ |
| 555 | dev_printk(KERN_DEBUG , dev , format , ## arg) | 572 | dev_printk(KERN_DEBUG , dev , format , ## arg) |
| 556 | #else | 573 | #else |
| 557 | #define dev_dbg(dev, format, arg...) do { (void)(dev); } while (0) | 574 | static inline int __attribute__ ((format (printf, 2, 3))) |
| 575 | dev_dbg(struct device * dev, const char * fmt, ...) | ||
| 576 | { | ||
| 577 | return 0; | ||
| 578 | } | ||
| 558 | #endif | 579 | #endif |
| 559 | 580 | ||
| 560 | #define dev_err(dev, format, arg...) \ | 581 | #define dev_err(dev, format, arg...) \ |
