From 3747eb8489228468dad737eb593289988ac36b62 Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Thu, 23 May 2002 21:20:21 -0700 Subject: Device Model: do better cleanup on device removal - make sure driverfs directory is removed after driver is detached and platform is notified (since they might have added files to it) - Add release callback to struct device that is to be set by whoever allocated the device (e.g. the bus). This is the last thing called from put_device, so the owner of it can free the memory for the structure --- drivers/base/core.c | 9 ++++++--- include/linux/device.h | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 93b8a0bb046a..391e0abefaa0 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -96,9 +96,6 @@ void put_device(struct device * dev) DBG("DEV: Unregistering device. ID = '%s', name = '%s'\n", dev->bus_id,dev->name); - /* remove the driverfs directory */ - device_remove_dir(dev); - /* Notify the platform of the removal, in case they * need to do anything... */ @@ -112,6 +109,12 @@ void put_device(struct device * dev) if (dev->driver && dev->driver->remove) dev->driver->remove(dev,REMOVE_FREE_RESOURCES); + /* remove the driverfs directory */ + device_remove_dir(dev); + + if (dev->release) + dev->release(dev); + put_device(dev->parent); } diff --git a/include/linux/device.h b/include/linux/device.h index 96d9cb108139..ccfd221d5dcd 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -92,6 +92,8 @@ struct device { being off. */ unsigned char *saved_state; /* saved device state */ + + void (*release)(struct device * dev); }; static inline struct device * -- cgit v1.2.3