Commit 3747eb84 authored by Patrick Mochel's avatar Patrick Mochel

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
parent e6d19c6a
...@@ -96,9 +96,6 @@ void put_device(struct device * dev) ...@@ -96,9 +96,6 @@ void put_device(struct device * dev)
DBG("DEV: Unregistering device. ID = '%s', name = '%s'\n", DBG("DEV: Unregistering device. ID = '%s', name = '%s'\n",
dev->bus_id,dev->name); dev->bus_id,dev->name);
/* remove the driverfs directory */
device_remove_dir(dev);
/* Notify the platform of the removal, in case they /* Notify the platform of the removal, in case they
* need to do anything... * need to do anything...
*/ */
...@@ -112,6 +109,12 @@ void put_device(struct device * dev) ...@@ -112,6 +109,12 @@ void put_device(struct device * dev)
if (dev->driver && dev->driver->remove) if (dev->driver && dev->driver->remove)
dev->driver->remove(dev,REMOVE_FREE_RESOURCES); 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); put_device(dev->parent);
} }
......
...@@ -92,6 +92,8 @@ struct device { ...@@ -92,6 +92,8 @@ struct device {
being off. */ being off. */
unsigned char *saved_state; /* saved device state */ unsigned char *saved_state; /* saved device state */
void (*release)(struct device * dev);
}; };
static inline struct device * static inline struct device *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment