summaryrefslogtreecommitdiffhomepage
path: root/device.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-04-05 03:52:39 +0200
committerFelix Fietkau <nbd@openwrt.org>2011-04-05 03:52:39 +0200
commitd3a4844047c7b3c62511a9836a81703b5ee70fc0 (patch)
treecd25491c58cbba0bebd5f0f17ce155d668528544 /device.c
parentb18fb36bd3c7615733c351c99691e1139f386c0c (diff)
add code for cleaning up unused devices mentioned in the config
Diffstat (limited to 'device.c')
-rw-r--r--device.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/device.c b/device.c
index 57b0ac9..34b49d4 100644
--- a/device.c
+++ b/device.c
@@ -197,3 +197,16 @@ void remove_device_user(struct device_user *dep)
dep->dev = NULL;
}
+
+void
+cleanup_devices(void)
+{
+ struct device *dev, *tmp;
+
+ avl_for_each_element_safe(&devices, dev, avl, tmp) {
+ if (!list_empty(&dev->users))
+ continue;
+
+ free_device(dev);
+ }
+}