diff options
| author | Patrick Mochel <mochel@osdl.org> | 2002-10-15 21:11:26 -0700 |
|---|---|---|
| committer | Patrick Mochel <mochel@osdl.org> | 2002-10-15 21:11:26 -0700 |
| commit | 2884fae053fb6a58f4f7c5985d574532b7ddd3d2 (patch) | |
| tree | 65bdf834df8e8a43b850abda642f0f2d2a16141c /include | |
| parent | 4278bccc2d9707c9c4ee1769b464bffe4dfd820a (diff) | |
driver model: make driver refcounting similar to devices'.
In the spirit of devices and buses, change driver refcounting model to
match the way that devices and buses are done.
struct device_driver gets a ->present field, which is set on registration
and cleared in driver_unregister(). get_device() checks the state of this
flag and returns NULL if cleared.
Note that the horribly wrong remove_driver() is deprecated and simply BUG()s
when called. Please convert callers to use driver_unregister(). Updates to
callers will be coming soon.
Note also that this still doesn't fix the race in which a driver module can
be removed while the refcount on a driver > 1. Near future work should help
to remedy it, but no solutions are guaranteed..
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/device.h | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 03c7d995e96c..4b6b0cbe77ed 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -110,6 +110,7 @@ struct device_driver { rwlock_t lock; atomic_t refcount; + u32 present; struct list_head bus_list; struct list_head class_list; @@ -127,16 +128,10 @@ struct device_driver { }; - extern int driver_register(struct device_driver * drv); +extern void driver_unregister(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 struct device_driver * get_driver(struct device_driver * drv); extern void put_driver(struct device_driver * drv); extern void remove_driver(struct device_driver * drv); |
