diff options
Diffstat (limited to 'include/linux/device.h')
-rw-r--r-- | include/linux/device.h | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index f71a78d123ae..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 | ||
@@ -186,13 +183,9 @@ struct class { | |||
186 | const char *name; | 183 | const char *name; |
187 | struct module *owner; | 184 | struct module *owner; |
188 | 185 | ||
189 | struct kset subsys; | ||
190 | struct list_head devices; | ||
191 | struct list_head interfaces; | ||
192 | struct kset class_dirs; | ||
193 | struct semaphore sem; /* locks children, devices, interfaces */ | ||
194 | struct class_attribute *class_attrs; | 186 | struct class_attribute *class_attrs; |
195 | struct device_attribute *dev_attrs; | 187 | struct device_attribute *dev_attrs; |
188 | struct kobject *dev_kobj; | ||
196 | 189 | ||
197 | int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); | 190 | int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); |
198 | 191 | ||
@@ -203,13 +196,28 @@ struct class { | |||
203 | int (*resume)(struct device *dev); | 196 | int (*resume)(struct device *dev); |
204 | 197 | ||
205 | struct pm_ops *pm; | 198 | struct pm_ops *pm; |
199 | struct class_private *p; | ||
206 | }; | 200 | }; |
207 | 201 | ||
208 | 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); | ||
209 | extern void class_unregister(struct class *class); | 206 | extern void class_unregister(struct class *class); |
210 | 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, | ||
211 | int (*fn)(struct device *dev, void *data)); | 218 | int (*fn)(struct device *dev, void *data)); |
212 | 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, | ||
213 | int (*match)(struct device *, void *)); | 221 | int (*match)(struct device *, void *)); |
214 | 222 | ||
215 | struct class_attribute { | 223 | struct class_attribute { |
@@ -237,9 +245,19 @@ struct class_interface { | |||
237 | extern int __must_check class_interface_register(struct class_interface *); | 245 | extern int __must_check class_interface_register(struct class_interface *); |
238 | extern void class_interface_unregister(struct class_interface *); | 246 | extern void class_interface_unregister(struct class_interface *); |
239 | 247 | ||
240 | 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); | ||
241 | extern void class_destroy(struct class *cls); | 251 | extern void class_destroy(struct class *cls); |
242 | 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 | |||
243 | /* | 261 | /* |
244 | * The type of device, "struct device" is embedded in. A class | 262 | * The type of device, "struct device" is embedded in. A class |
245 | * or bus can contain devices of different types | 263 | * or bus can contain devices of different types |
@@ -468,14 +486,10 @@ extern struct device *device_create_vargs(struct class *cls, | |||
468 | const char *fmt, | 486 | const char *fmt, |
469 | va_list vargs); | 487 | va_list vargs); |
470 | extern struct device *device_create(struct class *cls, struct device *parent, | 488 | extern struct device *device_create(struct class *cls, struct device *parent, |
471 | dev_t devt, const char *fmt, ...) | 489 | dev_t devt, void *drvdata, |
472 | __attribute__((format(printf, 4, 5))); | 490 | const char *fmt, ...) |
473 | extern struct device *device_create_drvdata(struct class *cls, | ||
474 | struct device *parent, | ||
475 | dev_t devt, | ||
476 | void *drvdata, | ||
477 | const char *fmt, ...) | ||
478 | __attribute__((format(printf, 5, 6))); | 491 | __attribute__((format(printf, 5, 6))); |
492 | #define device_create_drvdata device_create | ||
479 | extern void device_destroy(struct class *cls, dev_t devt); | 493 | extern void device_destroy(struct class *cls, dev_t devt); |
480 | 494 | ||
481 | /* | 495 | /* |