diff options
| author | Patrick Mochel <mochel@osdl.org> | 2002-08-12 00:50:03 -0700 |
|---|---|---|
| committer | Patrick Mochel <mochel@osdl.org> | 2002-08-12 00:50:03 -0700 |
| commit | d8b2993cbe5e4a58038e65a2d99b7b396281ba9f (patch) | |
| tree | 1d0d66c3121f1eae68ea42869b97c05c5b324608 /include/linux/device.h | |
| parent | 44013500bd72ac665567899246c749ea6f865f71 (diff) | |
Update device model locking
This updates the device model locking to use device_lock when accessing all
lists (the global list, the bus' lists and the drivers' lists). Before the latter
two would use their own rwlocks.
This also updates get_device() to return a pointer to the struct device if it
can successfully increment the reference count.
Between these two changes, this should prevent anything gaining an invalid
reference to a device that is in the process of being removed:
If a device is being removed, it's reference count is 0, but it hasn't
necessarily hasn't been removed from its bus's list. If the bus list iterator
attempts to access the device, it will take the lock, but will continue on to
the next device because the refcount is 0 (and drop the lock).
Well, theoretically; the bus iterators still need to be changed, but that's
coming next..
Diffstat (limited to 'include/linux/device.h')
| -rw-r--r-- | include/linux/device.h | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index c6f13cf24dba..c33eae266026 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -261,12 +261,7 @@ static inline void unlock_device(struct device * dev) * get_device - atomically increment the reference count for the device. * */ -static inline void get_device(struct device * dev) -{ - BUG_ON(!atomic_read(&dev->refcount)); - atomic_inc(&dev->refcount); -} - +extern struct device * get_device(struct device * dev); extern void put_device(struct device * dev); /* drivers/base/sys.c */ |
