diff options
| author | Patrick Mochel <mochel@geena.pdx.osdl.net> | 2002-05-28 03:59:17 -0700 |
|---|---|---|
| committer | Patrick Mochel <mochel@hera.kernel.org> | 2002-05-28 03:59:17 -0700 |
| commit | f371ab1c59dab04bfe7d239c3d5e85550bf31365 (patch) | |
| tree | 7b7c43fdd3608a5b2c02ea077f16816a1e2279bf /include/linux | |
| parent | 1f5bbbe447abdfbce71d4a6c7f4e66ff3626a987 (diff) | |
Beef up centralized driver mgmt:
- add name, bus, lock, refcount, bus_list, devices, and dir fields to struct
- add release callback to be called when refcount hits 0
- add helpers for registration and refcounting
- create directory for driver in bus's directory
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/device.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 078c65e02370..2ad1e9ff4f75 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -84,17 +84,48 @@ extern void put_bus(struct bus_type * bus); struct device_driver { + char * name; + struct bus_type * bus; + + rwlock_t lock; + atomic_t refcount; + + list_t bus_list; + list_t devices; + + struct driver_dir_entry dir; + int (*probe) (struct device * dev); int (*remove) (struct device * dev, u32 flags); int (*suspend) (struct device * dev, u32 state, u32 level); int (*resume) (struct device * dev, u32 level); + + void (*release) (struct device_driver * drv); }; + + +extern int driver_register(struct device_driver * drv); + +static inline struct device_driver * get_driver(struct device_driver * drv) +{ + BUG_ON(!atomic_read(&drv->refcount)); + atomic_inc(&drv->refcount); + return drv; +} + +extern void put_driver(struct device_driver * drv); + +extern int driver_for_each_dev(struct device_driver * drv, void * data, + int (*callback)(struct device * dev, void * data)); + + struct device { struct list_head g_list; /* node in depth-first order list */ struct list_head node; /* node in sibling list */ struct list_head bus_list; /* node in bus's list */ + struct list_head driver_list; struct list_head children; struct device * parent; |
