aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/device.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/device.h')
-rw-r--r--include/linux/device.h32
1 files changed, 29 insertions, 3 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index 4d8372d135df..987f5912720a 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -90,6 +90,9 @@ int __must_check bus_for_each_drv(struct bus_type *bus,
90 struct device_driver *start, void *data, 90 struct device_driver *start, void *data,
91 int (*fn)(struct device_driver *, void *)); 91 int (*fn)(struct device_driver *, void *));
92 92
93void bus_sort_breadthfirst(struct bus_type *bus,
94 int (*compare)(const struct device *a,
95 const struct device *b));
93/* 96/*
94 * Bus notifiers: Get notified of addition/removal of devices 97 * Bus notifiers: Get notified of addition/removal of devices
95 * and binding/unbinding of drivers to devices. 98 * and binding/unbinding of drivers to devices.
@@ -199,6 +202,11 @@ struct class {
199 struct class_private *p; 202 struct class_private *p;
200}; 203};
201 204
205struct class_dev_iter {
206 struct klist_iter ki;
207 const struct device_type *type;
208};
209
202extern struct kobject *sysfs_dev_block_kobj; 210extern struct kobject *sysfs_dev_block_kobj;
203extern struct kobject *sysfs_dev_char_kobj; 211extern struct kobject *sysfs_dev_char_kobj;
204extern int __must_check __class_register(struct class *class, 212extern int __must_check __class_register(struct class *class,
@@ -213,6 +221,13 @@ extern void class_unregister(struct class *class);
213 __class_register(class, &__key); \ 221 __class_register(class, &__key); \
214}) 222})
215 223
224extern void class_dev_iter_init(struct class_dev_iter *iter,
225 struct class *class,
226 struct device *start,
227 const struct device_type *type);
228extern struct device *class_dev_iter_next(struct class_dev_iter *iter);
229extern void class_dev_iter_exit(struct class_dev_iter *iter);
230
216extern int class_for_each_device(struct class *class, struct device *start, 231extern int class_for_each_device(struct class *class, struct device *start,
217 void *data, 232 void *data,
218 int (*fn)(struct device *dev, void *data)); 233 int (*fn)(struct device *dev, void *data));
@@ -396,7 +411,7 @@ struct device {
396 spinlock_t devres_lock; 411 spinlock_t devres_lock;
397 struct list_head devres_head; 412 struct list_head devres_head;
398 413
399 struct list_head node; 414 struct klist_node knode_class;
400 struct class *class; 415 struct class *class;
401 dev_t devt; /* dev_t, creates the sysfs "dev" */ 416 dev_t devt; /* dev_t, creates the sysfs "dev" */
402 struct attribute_group **groups; /* optional groups */ 417 struct attribute_group **groups; /* optional groups */
@@ -490,7 +505,6 @@ extern struct device *device_create(struct class *cls, struct device *parent,
490 dev_t devt, void *drvdata, 505 dev_t devt, void *drvdata,
491 const char *fmt, ...) 506 const char *fmt, ...)
492 __attribute__((format(printf, 5, 6))); 507 __attribute__((format(printf, 5, 6)));
493#define device_create_drvdata device_create
494extern void device_destroy(struct class *cls, dev_t devt); 508extern void device_destroy(struct class *cls, dev_t devt);
495 509
496/* 510/*
@@ -539,7 +553,11 @@ extern const char *dev_driver_string(const struct device *dev);
539#define dev_info(dev, format, arg...) \ 553#define dev_info(dev, format, arg...) \
540 dev_printk(KERN_INFO , dev , format , ## arg) 554 dev_printk(KERN_INFO , dev , format , ## arg)
541 555
542#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)
543#define dev_dbg(dev, format, arg...) \ 561#define dev_dbg(dev, format, arg...) \
544 dev_printk(KERN_DEBUG , dev , format , ## arg) 562 dev_printk(KERN_DEBUG , dev , format , ## arg)
545#else 563#else
@@ -555,6 +573,14 @@ extern const char *dev_driver_string(const struct device *dev);
555 ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) 573 ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; })
556#endif 574#endif
557 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
558/* Create alias, so I can be autoloaded. */ 584/* Create alias, so I can be autoloaded. */
559#define MODULE_ALIAS_CHARDEV(major,minor) \ 585#define MODULE_ALIAS_CHARDEV(major,minor) \
560 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) 586 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))