aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/device.h
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2007-02-10 01:26:32 -0500
committerDmitry Torokhov <dtor@insightbb.com>2007-02-10 01:26:32 -0500
commitb22364c8eec89e6b0c081a237f3b6348df87796f (patch)
tree233a923281fb640106465d076997ff511efb6edf /include/linux/device.h
parent2c8dc071517ec2843869024dc82be2e246f41064 (diff)
parent66efc5a7e3061c3597ac43a8bb1026488d57e66b (diff)
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'include/linux/device.h')
-rw-r--r--include/linux/device.h52
1 files changed, 51 insertions, 1 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index 49ab53ce92dc..26e4692f2d1a 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -126,6 +126,7 @@ struct device_driver {
126 struct klist_node knode_bus; 126 struct klist_node knode_bus;
127 127
128 struct module * owner; 128 struct module * owner;
129 const char * mod_name; /* used for built-in modules */
129 130
130 int (*probe) (struct device * dev); 131 int (*probe) (struct device * dev);
131 int (*remove) (struct device * dev); 132 int (*remove) (struct device * dev);
@@ -327,6 +328,13 @@ extern struct class_device *class_device_create(struct class *cls,
327 __attribute__((format(printf,5,6))); 328 __attribute__((format(printf,5,6)));
328extern void class_device_destroy(struct class *cls, dev_t devt); 329extern void class_device_destroy(struct class *cls, dev_t devt);
329 330
331struct device_type {
332 struct device_attribute *attrs;
333 int (*uevent)(struct device *dev, char **envp, int num_envp,
334 char *buffer, int buffer_size);
335 void (*release)(struct device *dev);
336};
337
330/* interface for exporting device attributes */ 338/* interface for exporting device attributes */
331struct device_attribute { 339struct device_attribute {
332 struct attribute attr; 340 struct attribute attr;
@@ -346,6 +354,41 @@ extern int __must_check device_create_bin_file(struct device *dev,
346 struct bin_attribute *attr); 354 struct bin_attribute *attr);
347extern void device_remove_bin_file(struct device *dev, 355extern void device_remove_bin_file(struct device *dev,
348 struct bin_attribute *attr); 356 struct bin_attribute *attr);
357
358/* device resource management */
359typedef void (*dr_release_t)(struct device *dev, void *res);
360typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
361
362#ifdef CONFIG_DEBUG_DEVRES
363extern void * __devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
364 const char *name);
365#define devres_alloc(release, size, gfp) \
366 __devres_alloc(release, size, gfp, #release)
367#else
368extern void * devres_alloc(dr_release_t release, size_t size, gfp_t gfp);
369#endif
370extern void devres_free(void *res);
371extern void devres_add(struct device *dev, void *res);
372extern void * devres_find(struct device *dev, dr_release_t release,
373 dr_match_t match, void *match_data);
374extern void * devres_get(struct device *dev, void *new_res,
375 dr_match_t match, void *match_data);
376extern void * devres_remove(struct device *dev, dr_release_t release,
377 dr_match_t match, void *match_data);
378extern int devres_destroy(struct device *dev, dr_release_t release,
379 dr_match_t match, void *match_data);
380
381/* devres group */
382extern void * __must_check devres_open_group(struct device *dev, void *id,
383 gfp_t gfp);
384extern void devres_close_group(struct device *dev, void *id);
385extern void devres_remove_group(struct device *dev, void *id);
386extern int devres_release_group(struct device *dev, void *id);
387
388/* managed kzalloc/kfree for device drivers, no kmalloc, always use kzalloc */
389extern void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp);
390extern void devm_kfree(struct device *dev, void *p);
391
349struct device { 392struct device {
350 struct klist klist_children; 393 struct klist klist_children;
351 struct klist_node knode_parent; /* node in sibling list */ 394 struct klist_node knode_parent; /* node in sibling list */
@@ -355,6 +398,7 @@ struct device {
355 398
356 struct kobject kobj; 399 struct kobject kobj;
357 char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 400 char bus_id[BUS_ID_SIZE]; /* position on parent bus */
401 struct device_type *type;
358 unsigned is_registered:1; 402 unsigned is_registered:1;
359 struct device_attribute uevent_attr; 403 struct device_attribute uevent_attr;
360 struct device_attribute *devt_attr; 404 struct device_attribute *devt_attr;
@@ -388,11 +432,15 @@ struct device {
388 /* arch specific additions */ 432 /* arch specific additions */
389 struct dev_archdata archdata; 433 struct dev_archdata archdata;
390 434
435 spinlock_t devres_lock;
436 struct list_head devres_head;
437
391 /* class_device migration path */ 438 /* class_device migration path */
392 struct list_head node; 439 struct list_head node;
393 struct class *class; /* optional*/ 440 struct class *class;
394 dev_t devt; /* dev_t, creates the sysfs "dev" */ 441 dev_t devt; /* dev_t, creates the sysfs "dev" */
395 struct attribute_group **groups; /* optional groups */ 442 struct attribute_group **groups; /* optional groups */
443 int uevent_suppress;
396 444
397 void (*release)(struct device * dev); 445 void (*release)(struct device * dev);
398}; 446};
@@ -433,6 +481,8 @@ static inline int device_is_registered(struct device *dev)
433 return dev->is_registered; 481 return dev->is_registered;
434} 482}
435 483
484void driver_init(void);
485
436/* 486/*
437 * High level routines for use by the bus drivers 487 * High level routines for use by the bus drivers
438 */ 488 */