diff options
Diffstat (limited to 'include/linux/device.h')
-rw-r--r-- | include/linux/device.h | 67 |
1 files changed, 45 insertions, 22 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 6a2d04c011bc..d24a47f80f9c 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/kobject.h> | 16 | #include <linux/kobject.h> |
17 | #include <linux/klist.h> | 17 | #include <linux/klist.h> |
18 | #include <linux/list.h> | 18 | #include <linux/list.h> |
19 | #include <linux/lockdep.h> | ||
19 | #include <linux/compiler.h> | 20 | #include <linux/compiler.h> |
20 | #include <linux/types.h> | 21 | #include <linux/types.h> |
21 | #include <linux/module.h> | 22 | #include <linux/module.h> |
@@ -24,17 +25,13 @@ | |||
24 | #include <asm/atomic.h> | 25 | #include <asm/atomic.h> |
25 | #include <asm/device.h> | 26 | #include <asm/device.h> |
26 | 27 | ||
27 | #define DEVICE_NAME_SIZE 50 | 28 | #define BUS_ID_SIZE 20 |
28 | /* DEVICE_NAME_HALF is really less than half to accommodate slop */ | ||
29 | #define DEVICE_NAME_HALF __stringify(20) | ||
30 | #define DEVICE_ID_SIZE 32 | ||
31 | #define BUS_ID_SIZE KOBJ_NAME_LEN | ||
32 | |||
33 | 29 | ||
34 | struct device; | 30 | struct device; |
35 | struct device_driver; | 31 | struct device_driver; |
36 | struct driver_private; | 32 | struct driver_private; |
37 | struct class; | 33 | struct class; |
34 | struct class_private; | ||
38 | struct bus_type; | 35 | struct bus_type; |
39 | struct bus_type_private; | 36 | struct bus_type_private; |
40 | 37 | ||
@@ -68,6 +65,8 @@ struct bus_type { | |||
68 | int (*resume_early)(struct device *dev); | 65 | int (*resume_early)(struct device *dev); |
69 | int (*resume)(struct device *dev); | 66 | int (*resume)(struct device *dev); |
70 | 67 | ||
68 | struct pm_ext_ops *pm; | ||
69 | |||
71 | struct bus_type_private *p; | 70 | struct bus_type_private *p; |
72 | }; | 71 | }; |
73 | 72 | ||
@@ -131,6 +130,8 @@ struct device_driver { | |||
131 | int (*resume) (struct device *dev); | 130 | int (*resume) (struct device *dev); |
132 | struct attribute_group **groups; | 131 | struct attribute_group **groups; |
133 | 132 | ||
133 | struct pm_ops *pm; | ||
134 | |||
134 | struct driver_private *p; | 135 | struct driver_private *p; |
135 | }; | 136 | }; |
136 | 137 | ||
@@ -182,13 +183,9 @@ struct class { | |||
182 | const char *name; | 183 | const char *name; |
183 | struct module *owner; | 184 | struct module *owner; |
184 | 185 | ||
185 | struct kset subsys; | ||
186 | struct list_head devices; | ||
187 | struct list_head interfaces; | ||
188 | struct kset class_dirs; | ||
189 | struct semaphore sem; /* locks children, devices, interfaces */ | ||
190 | struct class_attribute *class_attrs; | 186 | struct class_attribute *class_attrs; |
191 | struct device_attribute *dev_attrs; | 187 | struct device_attribute *dev_attrs; |
188 | struct kobject *dev_kobj; | ||
192 | 189 | ||
193 | int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); | 190 | int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); |
194 | 191 | ||
@@ -197,13 +194,30 @@ struct class { | |||
197 | 194 | ||
198 | int (*suspend)(struct device *dev, pm_message_t state); | 195 | int (*suspend)(struct device *dev, pm_message_t state); |
199 | int (*resume)(struct device *dev); | 196 | int (*resume)(struct device *dev); |
197 | |||
198 | struct pm_ops *pm; | ||
199 | struct class_private *p; | ||
200 | }; | 200 | }; |
201 | 201 | ||
202 | extern int __must_check class_register(struct class *class); | 202 | extern struct kobject *sysfs_dev_block_kobj; |
203 | extern struct kobject *sysfs_dev_char_kobj; | ||
204 | extern int __must_check __class_register(struct class *class, | ||
205 | struct lock_class_key *key); | ||
203 | extern void class_unregister(struct class *class); | 206 | extern void class_unregister(struct class *class); |
204 | extern int class_for_each_device(struct class *class, void *data, | 207 | |
208 | /* This is a #define to keep the compiler from merging different | ||
209 | * instances of the __key variable */ | ||
210 | #define class_register(class) \ | ||
211 | ({ \ | ||
212 | static struct lock_class_key __key; \ | ||
213 | __class_register(class, &__key); \ | ||
214 | }) | ||
215 | |||
216 | extern int class_for_each_device(struct class *class, struct device *start, | ||
217 | void *data, | ||
205 | int (*fn)(struct device *dev, void *data)); | 218 | int (*fn)(struct device *dev, void *data)); |
206 | extern struct device *class_find_device(struct class *class, void *data, | 219 | extern struct device *class_find_device(struct class *class, |
220 | struct device *start, void *data, | ||
207 | int (*match)(struct device *, void *)); | 221 | int (*match)(struct device *, void *)); |
208 | 222 | ||
209 | struct class_attribute { | 223 | struct class_attribute { |
@@ -231,9 +245,19 @@ struct class_interface { | |||
231 | extern int __must_check class_interface_register(struct class_interface *); | 245 | extern int __must_check class_interface_register(struct class_interface *); |
232 | extern void class_interface_unregister(struct class_interface *); | 246 | extern void class_interface_unregister(struct class_interface *); |
233 | 247 | ||
234 | extern struct class *class_create(struct module *owner, const char *name); | 248 | extern struct class * __must_check __class_create(struct module *owner, |
249 | const char *name, | ||
250 | struct lock_class_key *key); | ||
235 | extern void class_destroy(struct class *cls); | 251 | extern void class_destroy(struct class *cls); |
236 | 252 | ||
253 | /* This is a #define to keep the compiler from merging different | ||
254 | * instances of the __key variable */ | ||
255 | #define class_create(owner, name) \ | ||
256 | ({ \ | ||
257 | static struct lock_class_key __key; \ | ||
258 | __class_create(owner, name, &__key); \ | ||
259 | }) | ||
260 | |||
237 | /* | 261 | /* |
238 | * The type of device, "struct device" is embedded in. A class | 262 | * The type of device, "struct device" is embedded in. A class |
239 | * or bus can contain devices of different types | 263 | * or bus can contain devices of different types |
@@ -248,8 +272,11 @@ struct device_type { | |||
248 | struct attribute_group **groups; | 272 | struct attribute_group **groups; |
249 | int (*uevent)(struct device *dev, struct kobj_uevent_env *env); | 273 | int (*uevent)(struct device *dev, struct kobj_uevent_env *env); |
250 | void (*release)(struct device *dev); | 274 | void (*release)(struct device *dev); |
275 | |||
251 | int (*suspend)(struct device *dev, pm_message_t state); | 276 | int (*suspend)(struct device *dev, pm_message_t state); |
252 | int (*resume)(struct device *dev); | 277 | int (*resume)(struct device *dev); |
278 | |||
279 | struct pm_ops *pm; | ||
253 | }; | 280 | }; |
254 | 281 | ||
255 | /* interface for exporting device attributes */ | 282 | /* interface for exporting device attributes */ |
@@ -459,14 +486,10 @@ extern struct device *device_create_vargs(struct class *cls, | |||
459 | const char *fmt, | 486 | const char *fmt, |
460 | va_list vargs); | 487 | va_list vargs); |
461 | extern struct device *device_create(struct class *cls, struct device *parent, | 488 | extern struct device *device_create(struct class *cls, struct device *parent, |
462 | dev_t devt, const char *fmt, ...) | 489 | dev_t devt, void *drvdata, |
463 | __attribute__((format(printf, 4, 5))); | 490 | const char *fmt, ...) |
464 | extern struct device *device_create_drvdata(struct class *cls, | ||
465 | struct device *parent, | ||
466 | dev_t devt, | ||
467 | void *drvdata, | ||
468 | const char *fmt, ...) | ||
469 | __attribute__((format(printf, 5, 6))); | 491 | __attribute__((format(printf, 5, 6))); |
492 | #define device_create_drvdata device_create | ||
470 | extern void device_destroy(struct class *cls, dev_t devt); | 493 | extern void device_destroy(struct class *cls, dev_t devt); |
471 | 494 | ||
472 | /* | 495 | /* |