summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorPatrick Mochel <mochel@osdl.org>2002-10-08 03:23:05 -0700
committerPatrick Mochel <mochel@osdl.org>2002-10-08 03:23:05 -0700
commitc7a01052c40f9e8fdd61bd90e810a358834a8344 (patch)
tree83fcf038748eb585fd738f7ed9ff23ef67172a28 /include/linux
parent0bf36f291063c1bec51a12cbf4b072ec5f0aacd1 (diff)
driver model: and present field to struct device and implement device_unregister().
device_unregister() is intended to be the complement of device_register(), and assumes most of the functionality of the current put_device(). It should be called by the bus driver when a device is physically removed from the system. It should _not_ be called from a driver's remove() method, as that remove() method is called via device_detach() in device_unregister(). dev->present is used to flag the physical presence of the device. It is set when the device is registered, and cleared when unregistered. get_device() checks this flag, and returns a NULL pointer if cleared. This prevents anyone from obtaining a reference to a device that has been unregistered (removed), but not yet been freed (e.g. if someone else is holding a reference to it). put_device() BUG()s if dev->present is set. A device should be unregistered before it is freed. This will catch people doing it in the wrong order.
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/device.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index ef76b15fa930..dea22c61049c 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -289,6 +289,7 @@ struct device {
void *platform_data; /* Platform specific data (e.g. ACPI,
BIOS data relevant to device) */
+ u32 present;
u32 current_state; /* Current operating state. In
ACPI-speak, this is D0-D3, D0
being fully functional, and D3
@@ -327,7 +328,7 @@ dev_set_drvdata (struct device *dev, void *data)
* High level routines for use by the bus drivers
*/
extern int device_register(struct device * dev);
-
+extern void device_unregister(struct device * dev);
/* driverfs interface for exporting device attributes */