[bk/patch] driver model update: device_unregister()

From: Patrick Mochel (mochel@osdl.org)
Date: Tue Oct 08 2002 - 19:57:11 EST

Without further ado, here is device_unregister(), and a fixup of the IDE
and USB code that use it. Description below.

Please apply. (bkbits is taking a really long time, so it might take a few
to actually show up).


Please pull from


This will update the following files:

 drivers/base/core.c | 38 +++++++++++++++++++++++++++++++-------
 drivers/base/fs/device.c | 3 +--
 drivers/ide/ide-disk.c | 2 +-
 drivers/usb/core/usb.c | 4 ++--
 include/linux/device.h | 3 ++-
 5 files changed, 37 insertions(+), 13 deletions(-)

through these ChangeSets:

<mochel@osdl.org> (02/10/08 1.601)
   USB: call device_unregister() instead of put_device() when removing devices.

<mochel@osdl.org> (02/10/08 1.600)
   IDE: call device_unregister() instead of put_device() in ide-disk->cleanup().

<mochel@osdl.org> (02/10/08 1.599)
   driver model: check return of get_device() when creating a driverfs file.

<mochel@osdl.org> (02/10/08 1.598)
   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.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

This archive was generated by hypermail 2b29 : Tue Oct 15 2002 - 22:00:29 EST