diff options
| author | Patrick Mochel <mochel@osdl.org> | 2002-11-19 08:42:26 -0600 |
|---|---|---|
| committer | Patrick Mochel <mochel@osdl.org> | 2002-11-19 08:42:26 -0600 |
| commit | b12cf4fff95fc6bab2b350160cba008c1467d19e (patch) | |
| tree | 9a713b3f9674448fe9d496b7a58aad463c28197a /include/linux/device.h | |
| parent | ca01359a93da05d7ab2b17b207ea117748f8c87f (diff) | |
driver model: exploit kobject contstructs.
This makes the driver model core (for devices) exploit the kobject
infrastructure more and make the resulting code quite a bit simpler.
For one, device_register() mimmicks kobject_register() in that it now only
calls device_initialize() and device_add() back to back. Similarly,
device_unregister() calls device_del() and put_device() consecutively.
device_del() no longer removes and frees the device, it only removes them.
It also removes the devices from the global and sibling lists. This was
previously done by device_put(), but moved here to be symmetrical with
device_add().
The device's parent is now only incremented in device_add() and decremented
in device_del(), fixing a bug in which the parent's refcount was incremented
twice.
Because of these simplifications, the core can easily be converted to use
the kobject reference counting infrastructure. get_device() now simply
forwards the call to kobject_get() and ditto for put_device().
device_release() is implemented to handle the freeing of devices once their
reference count reaches 0.
Since we're using the kobject refcounting model, we no longer need the
checking or setting of the device state field, so it has been removed.
The only users of it were the power routines. In those, it is implicit that
we have a valid device, since we've already taken device_sem, and we're
walking the list (all modifications are protected by device_sem).
struct device::lock, and the helpers to lock/unlock have been removed. No
one has ever used them, and no one is likely to use them.
Diffstat (limited to 'include/linux/device.h')
| -rw-r--r-- | include/linux/device.h | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index b434f2725c23..16ed478db4f1 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -279,12 +279,6 @@ struct device { char name[DEVICE_NAME_SIZE]; /* descriptive ascii string */ char bus_id[BUS_ID_SIZE]; /* position on parent bus */ - spinlock_t lock; /* lock for the device to ensure two - different layers don't access it at - the same time. */ - atomic_t refcount; /* refcount to make sure the device - * persists for the right amount of time */ - struct bus_type * bus; /* type of bus device is on */ struct device_driver *driver; /* which driver has allocated this device */ @@ -296,7 +290,6 @@ struct device { void *platform_data; /* Platform specific data (e.g. ACPI, BIOS data relevant to device) */ - enum device_state state; u32 power_state; /* Current operating state. In ACPI-speak, this is D0-D3, D0 being fully functional, and D3 @@ -369,24 +362,6 @@ extern int (*platform_notify)(struct device * dev); extern int (*platform_notify_remove)(struct device * dev); -static inline int device_present(struct device * dev) -{ - return (dev && (dev->state == DEVICE_INITIALIZED || dev->state == DEVICE_REGISTERED)); -} - -/* device and bus locking helpers. - * - * FIXME: Is there anything else we need to do? - */ -static inline void lock_device(struct device * dev) -{ - spin_lock(&dev->lock); -} - -static inline void unlock_device(struct device * dev) -{ - spin_unlock(&dev->lock); -} /** * get_device - atomically increment the reference count for the device. |
