summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-02-17 10:27:31 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-02-17 10:27:31 +0100
commit2546c5a514e57c0efaeb1664006b2af14d3c0590 (patch)
tree17cef9339fdc6fb12ecf72ef27c51d96022ffed2 /drivers
parentc6a87e145cea8af8c7545a0406aa8f8dd9146c92 (diff)
parent491cc29b0a2cf7c675e94e00eed2d58934a76011 (diff)
downloadbarebox-2546c5a514e57c0efaeb1664006b2af14d3c0590.tar.gz
barebox-2546c5a514e57c0efaeb1664006b2af14d3c0590.tar.xz
Merge branch 'pu/device-cleanup' into next
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/driver.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 0132e7dcf8..3777f82d64 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -137,16 +137,26 @@ EXPORT_SYMBOL(register_device);
int unregister_device(struct device_d *old_dev)
{
- debug("unregister_device: %s\n", dev_name(old_dev));
+ struct cdev *cdev, *ct;
+ struct device_d *child, *dt;
- if (!list_empty(&old_dev->children)) {
- errno = -EBUSY;
- return errno;
- }
+ dev_dbg(old_dev, "unregister\n");
if (old_dev->driver)
old_dev->bus->remove(old_dev);
+ list_for_each_entry_safe(child, dt, &old_dev->children, sibling) {
+ dev_dbg(old_dev, "unregister child %s\n", dev_name(child));
+ unregister_device(child);
+ }
+
+ list_for_each_entry_safe(cdev, ct, &old_dev->cdevs, devices_list) {
+ if (cdev->flags & DEVFS_IS_PARTITION) {
+ dev_dbg(old_dev, "unregister part %s\n", cdev->name);
+ devfs_del_partition(cdev->name);
+ }
+ }
+
list_del(&old_dev->list);
list_del(&old_dev->active);