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.h55
1 files changed, 52 insertions, 3 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index f44247fe8135..d1a3a27c3988 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -2,6 +2,7 @@
2 * device.h - generic, centralized driver model 2 * device.h - generic, centralized driver model
3 * 3 *
4 * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org> 4 * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org>
5 * Copyright (c) 2004-2007 Greg Kroah-Hartman <gregkh@suse.de>
5 * 6 *
6 * This file is released under the GPLv2 7 * This file is released under the GPLv2
7 * 8 *
@@ -101,7 +102,7 @@ extern int bus_unregister_notifier(struct bus_type *bus,
101#define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be 102#define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be
102 unbound */ 103 unbound */
103 104
104/* driverfs interface for exporting bus attributes */ 105/* sysfs interface for exporting bus attributes */
105 106
106struct bus_attribute { 107struct bus_attribute {
107 struct attribute attr; 108 struct attribute attr;
@@ -126,6 +127,7 @@ struct device_driver {
126 struct klist_node knode_bus; 127 struct klist_node knode_bus;
127 128
128 struct module * owner; 129 struct module * owner;
130 const char * mod_name; /* used for built-in modules */
129 131
130 int (*probe) (struct device * dev); 132 int (*probe) (struct device * dev);
131 int (*remove) (struct device * dev); 133 int (*remove) (struct device * dev);
@@ -145,7 +147,7 @@ extern void put_driver(struct device_driver * drv);
145extern struct device_driver *driver_find(const char *name, struct bus_type *bus); 147extern struct device_driver *driver_find(const char *name, struct bus_type *bus);
146extern int driver_probe_done(void); 148extern int driver_probe_done(void);
147 149
148/* driverfs interface for exporting driver attributes */ 150/* sysfs interface for exporting driver attributes */
149 151
150struct driver_attribute { 152struct driver_attribute {
151 struct attribute attr; 153 struct attribute attr;
@@ -327,6 +329,13 @@ extern struct class_device *class_device_create(struct class *cls,
327 __attribute__((format(printf,5,6))); 329 __attribute__((format(printf,5,6)));
328extern void class_device_destroy(struct class *cls, dev_t devt); 330extern void class_device_destroy(struct class *cls, dev_t devt);
329 331
332struct device_type {
333 struct device_attribute *attrs;
334 int (*uevent)(struct device *dev, char **envp, int num_envp,
335 char *buffer, int buffer_size);
336 void (*release)(struct device *dev);
337};
338
330/* interface for exporting device attributes */ 339/* interface for exporting device attributes */
331struct device_attribute { 340struct device_attribute {
332 struct attribute attr; 341 struct attribute attr;
@@ -346,6 +355,41 @@ extern int __must_check device_create_bin_file(struct device *dev,
346 struct bin_attribute *attr); 355 struct bin_attribute *attr);
347extern void device_remove_bin_file(struct device *dev, 356extern void device_remove_bin_file(struct device *dev,
348 struct bin_attribute *attr); 357 struct bin_attribute *attr);
358
359/* device resource management */
360typedef void (*dr_release_t)(struct device *dev, void *res);
361typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
362
363#ifdef CONFIG_DEBUG_DEVRES
364extern void * __devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
365 const char *name);
366#define devres_alloc(release, size, gfp) \
367 __devres_alloc(release, size, gfp, #release)
368#else
369extern void * devres_alloc(dr_release_t release, size_t size, gfp_t gfp);
370#endif
371extern void devres_free(void *res);
372extern void devres_add(struct device *dev, void *res);
373extern void * devres_find(struct device *dev, dr_release_t release,
374 dr_match_t match, void *match_data);
375extern void * devres_get(struct device *dev, void *new_res,
376 dr_match_t match, void *match_data);
377extern void * devres_remove(struct device *dev, dr_release_t release,
378 dr_match_t match, void *match_data);
379extern int devres_destroy(struct device *dev, dr_release_t release,
380 dr_match_t match, void *match_data);
381
382/* devres group */
383extern void * __must_check devres_open_group(struct device *dev, void *id,
384 gfp_t gfp);
385extern void devres_close_group(struct device *dev, void *id);
386extern void devres_remove_group(struct device *dev, void *id);
387extern int devres_release_group(struct device *dev, void *id);
388
389/* managed kzalloc/kfree for device drivers, no kmalloc, always use kzalloc */
390extern void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp);
391extern void devm_kfree(struct device *dev, void *p);
392
349struct device { 393struct device {
350 struct klist klist_children; 394 struct klist klist_children;
351 struct klist_node knode_parent; /* node in sibling list */ 395 struct klist_node knode_parent; /* node in sibling list */
@@ -355,6 +399,7 @@ struct device {
355 399
356 struct kobject kobj; 400 struct kobject kobj;
357 char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 401 char bus_id[BUS_ID_SIZE]; /* position on parent bus */
402 struct device_type *type;
358 unsigned is_registered:1; 403 unsigned is_registered:1;
359 struct device_attribute uevent_attr; 404 struct device_attribute uevent_attr;
360 struct device_attribute *devt_attr; 405 struct device_attribute *devt_attr;
@@ -388,11 +433,15 @@ struct device {
388 /* arch specific additions */ 433 /* arch specific additions */
389 struct dev_archdata archdata; 434 struct dev_archdata archdata;
390 435
436 spinlock_t devres_lock;
437 struct list_head devres_head;
438
391 /* class_device migration path */ 439 /* class_device migration path */
392 struct list_head node; 440 struct list_head node;
393 struct class *class; /* optional*/ 441 struct class *class;
394 dev_t devt; /* dev_t, creates the sysfs "dev" */ 442 dev_t devt; /* dev_t, creates the sysfs "dev" */
395 struct attribute_group **groups; /* optional groups */ 443 struct attribute_group **groups; /* optional groups */
444 int uevent_suppress;
396 445
397 void (*release)(struct device * dev); 446 void (*release)(struct device * dev);
398}; 447};