diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-10-28 11:26:12 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-28 11:26:12 -0400 |
commit | 7a9787e1eba95a166265e6a260cf30af04ef0a99 (patch) | |
tree | e730a4565e0318140d2fbd2f0415d18a339d7336 /include/linux/device.h | |
parent | 41b9eb264c8407655db57b60b4457fe1b2ec9977 (diff) | |
parent | 0173a3265b228da319ceb9c1ec6a5682fd1b2d92 (diff) |
Merge commit 'v2.6.28-rc2' into x86/pci-ioapic-boot-irq-quirks
Diffstat (limited to 'include/linux/device.h')
-rw-r--r-- | include/linux/device.h | 95 |
1 files changed, 68 insertions, 27 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index f71a78d123ae..1a3686d15f98 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 | ||
@@ -93,6 +90,9 @@ int __must_check bus_for_each_drv(struct bus_type *bus, | |||
93 | struct device_driver *start, void *data, | 90 | struct device_driver *start, void *data, |
94 | int (*fn)(struct device_driver *, void *)); | 91 | int (*fn)(struct device_driver *, void *)); |
95 | 92 | ||
93 | void bus_sort_breadthfirst(struct bus_type *bus, | ||
94 | int (*compare)(const struct device *a, | ||
95 | const struct device *b)); | ||
96 | /* | 96 | /* |
97 | * Bus notifiers: Get notified of addition/removal of devices | 97 | * Bus notifiers: Get notified of addition/removal of devices |
98 | * and binding/unbinding of drivers to devices. | 98 | * and binding/unbinding of drivers to devices. |
@@ -186,13 +186,9 @@ struct class { | |||
186 | const char *name; | 186 | const char *name; |
187 | struct module *owner; | 187 | struct module *owner; |
188 | 188 | ||
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; | 189 | struct class_attribute *class_attrs; |
195 | struct device_attribute *dev_attrs; | 190 | struct device_attribute *dev_attrs; |
191 | struct kobject *dev_kobj; | ||
196 | 192 | ||
197 | int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); | 193 | int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); |
198 | 194 | ||
@@ -203,13 +199,40 @@ struct class { | |||
203 | int (*resume)(struct device *dev); | 199 | int (*resume)(struct device *dev); |
204 | 200 | ||
205 | struct pm_ops *pm; | 201 | struct pm_ops *pm; |
202 | struct class_private *p; | ||
203 | }; | ||
204 | |||
205 | struct class_dev_iter { | ||
206 | struct klist_iter ki; | ||
207 | const struct device_type *type; | ||
206 | }; | 208 | }; |
207 | 209 | ||
208 | extern int __must_check class_register(struct class *class); | 210 | extern struct kobject *sysfs_dev_block_kobj; |
211 | extern struct kobject *sysfs_dev_char_kobj; | ||
212 | extern int __must_check __class_register(struct class *class, | ||
213 | struct lock_class_key *key); | ||
209 | extern void class_unregister(struct class *class); | 214 | extern void class_unregister(struct class *class); |
210 | extern int class_for_each_device(struct class *class, void *data, | 215 | |
216 | /* This is a #define to keep the compiler from merging different | ||
217 | * instances of the __key variable */ | ||
218 | #define class_register(class) \ | ||
219 | ({ \ | ||
220 | static struct lock_class_key __key; \ | ||
221 | __class_register(class, &__key); \ | ||
222 | }) | ||
223 | |||
224 | extern void class_dev_iter_init(struct class_dev_iter *iter, | ||
225 | struct class *class, | ||
226 | struct device *start, | ||
227 | const struct device_type *type); | ||
228 | extern struct device *class_dev_iter_next(struct class_dev_iter *iter); | ||
229 | extern void class_dev_iter_exit(struct class_dev_iter *iter); | ||
230 | |||
231 | extern int class_for_each_device(struct class *class, struct device *start, | ||
232 | void *data, | ||
211 | int (*fn)(struct device *dev, void *data)); | 233 | int (*fn)(struct device *dev, void *data)); |
212 | extern struct device *class_find_device(struct class *class, void *data, | 234 | extern struct device *class_find_device(struct class *class, |
235 | struct device *start, void *data, | ||
213 | int (*match)(struct device *, void *)); | 236 | int (*match)(struct device *, void *)); |
214 | 237 | ||
215 | struct class_attribute { | 238 | struct class_attribute { |
@@ -237,9 +260,19 @@ struct class_interface { | |||
237 | extern int __must_check class_interface_register(struct class_interface *); | 260 | extern int __must_check class_interface_register(struct class_interface *); |
238 | extern void class_interface_unregister(struct class_interface *); | 261 | extern void class_interface_unregister(struct class_interface *); |
239 | 262 | ||
240 | extern struct class *class_create(struct module *owner, const char *name); | 263 | extern struct class * __must_check __class_create(struct module *owner, |
264 | const char *name, | ||
265 | struct lock_class_key *key); | ||
241 | extern void class_destroy(struct class *cls); | 266 | extern void class_destroy(struct class *cls); |
242 | 267 | ||
268 | /* This is a #define to keep the compiler from merging different | ||
269 | * instances of the __key variable */ | ||
270 | #define class_create(owner, name) \ | ||
271 | ({ \ | ||
272 | static struct lock_class_key __key; \ | ||
273 | __class_create(owner, name, &__key); \ | ||
274 | }) | ||
275 | |||
243 | /* | 276 | /* |
244 | * The type of device, "struct device" is embedded in. A class | 277 | * The type of device, "struct device" is embedded in. A class |
245 | * or bus can contain devices of different types | 278 | * or bus can contain devices of different types |
@@ -340,6 +373,7 @@ struct device { | |||
340 | 373 | ||
341 | struct kobject kobj; | 374 | struct kobject kobj; |
342 | char bus_id[BUS_ID_SIZE]; /* position on parent bus */ | 375 | char bus_id[BUS_ID_SIZE]; /* position on parent bus */ |
376 | const char *init_name; /* initial name of the device */ | ||
343 | struct device_type *type; | 377 | struct device_type *type; |
344 | unsigned uevent_suppress:1; | 378 | unsigned uevent_suppress:1; |
345 | 379 | ||
@@ -377,7 +411,7 @@ struct device { | |||
377 | spinlock_t devres_lock; | 411 | spinlock_t devres_lock; |
378 | struct list_head devres_head; | 412 | struct list_head devres_head; |
379 | 413 | ||
380 | struct list_head node; | 414 | struct klist_node knode_class; |
381 | struct class *class; | 415 | struct class *class; |
382 | dev_t devt; /* dev_t, creates the sysfs "dev" */ | 416 | dev_t devt; /* dev_t, creates the sysfs "dev" */ |
383 | struct attribute_group **groups; /* optional groups */ | 417 | struct attribute_group **groups; /* optional groups */ |
@@ -388,7 +422,7 @@ struct device { | |||
388 | /* Get the wakeup routines, which depend on struct device */ | 422 | /* Get the wakeup routines, which depend on struct device */ |
389 | #include <linux/pm_wakeup.h> | 423 | #include <linux/pm_wakeup.h> |
390 | 424 | ||
391 | static inline const char *dev_name(struct device *dev) | 425 | static inline const char *dev_name(const struct device *dev) |
392 | { | 426 | { |
393 | /* will be changed into kobject_name(&dev->kobj) in the near future */ | 427 | /* will be changed into kobject_name(&dev->kobj) in the near future */ |
394 | return dev->bus_id; | 428 | return dev->bus_id; |
@@ -416,7 +450,7 @@ static inline void set_dev_node(struct device *dev, int node) | |||
416 | } | 450 | } |
417 | #endif | 451 | #endif |
418 | 452 | ||
419 | static inline void *dev_get_drvdata(struct device *dev) | 453 | static inline void *dev_get_drvdata(const struct device *dev) |
420 | { | 454 | { |
421 | return dev->driver_data; | 455 | return dev->driver_data; |
422 | } | 456 | } |
@@ -468,13 +502,8 @@ extern struct device *device_create_vargs(struct class *cls, | |||
468 | const char *fmt, | 502 | const char *fmt, |
469 | va_list vargs); | 503 | va_list vargs); |
470 | extern struct device *device_create(struct class *cls, struct device *parent, | 504 | extern struct device *device_create(struct class *cls, struct device *parent, |
471 | dev_t devt, const char *fmt, ...) | 505 | dev_t devt, void *drvdata, |
472 | __attribute__((format(printf, 4, 5))); | 506 | 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))); | 507 | __attribute__((format(printf, 5, 6))); |
479 | extern void device_destroy(struct class *cls, dev_t devt); | 508 | extern void device_destroy(struct class *cls, dev_t devt); |
480 | 509 | ||
@@ -504,7 +533,7 @@ extern void device_shutdown(void); | |||
504 | extern void sysdev_shutdown(void); | 533 | extern void sysdev_shutdown(void); |
505 | 534 | ||
506 | /* debugging and troubleshooting/diagnostic helpers. */ | 535 | /* debugging and troubleshooting/diagnostic helpers. */ |
507 | extern const char *dev_driver_string(struct device *dev); | 536 | extern const char *dev_driver_string(const struct device *dev); |
508 | #define dev_printk(level, dev, format, arg...) \ | 537 | #define dev_printk(level, dev, format, arg...) \ |
509 | printk(level "%s %s: " format , dev_driver_string(dev) , \ | 538 | printk(level "%s %s: " format , dev_driver_string(dev) , \ |
510 | dev_name(dev) , ## arg) | 539 | dev_name(dev) , ## arg) |
@@ -524,7 +553,11 @@ extern const char *dev_driver_string(struct device *dev); | |||
524 | #define dev_info(dev, format, arg...) \ | 553 | #define dev_info(dev, format, arg...) \ |
525 | dev_printk(KERN_INFO , dev , format , ## arg) | 554 | dev_printk(KERN_INFO , dev , format , ## arg) |
526 | 555 | ||
527 | #ifdef DEBUG | 556 | #if defined(CONFIG_DYNAMIC_PRINTK_DEBUG) |
557 | #define dev_dbg(dev, format, ...) do { \ | ||
558 | dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \ | ||
559 | } while (0) | ||
560 | #elif defined(DEBUG) | ||
528 | #define dev_dbg(dev, format, arg...) \ | 561 | #define dev_dbg(dev, format, arg...) \ |
529 | dev_printk(KERN_DEBUG , dev , format , ## arg) | 562 | dev_printk(KERN_DEBUG , dev , format , ## arg) |
530 | #else | 563 | #else |
@@ -540,6 +573,14 @@ extern const char *dev_driver_string(struct device *dev); | |||
540 | ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) | 573 | ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) |
541 | #endif | 574 | #endif |
542 | 575 | ||
576 | /* | ||
577 | * dev_WARN() acts like dev_printk(), but with the key difference | ||
578 | * of using a WARN/WARN_ON to get the message out, including the | ||
579 | * file/line information and a backtrace. | ||
580 | */ | ||
581 | #define dev_WARN(dev, format, arg...) \ | ||
582 | WARN(1, "Device: %s\n" format, dev_driver_string(dev), ## arg); | ||
583 | |||
543 | /* Create alias, so I can be autoloaded. */ | 584 | /* Create alias, so I can be autoloaded. */ |
544 | #define MODULE_ALIAS_CHARDEV(major,minor) \ | 585 | #define MODULE_ALIAS_CHARDEV(major,minor) \ |
545 | MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) | 586 | MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) |