add some code for parsing static ipaddr/ip6addr/netmask
[project/netifd.git] / device.c
index 57b0ac9..ef70685 100644 (file)
--- a/device.c
+++ b/device.c
@@ -3,19 +3,12 @@
 #include <stdio.h>
 #include <assert.h>
 
-#include <libubox/uapi.h>
-
 #include "netifd.h"
 #include "system.h"
 
 static struct avl_tree devices;
 
-static int avl_strcmp(const void *k1, const void *k2, void *ptr)
-{
-       return strcmp(k1, k2);
-}
-
-static void API_CTOR dev_init(void)
+static void __init dev_init(void)
 {
        avl_init(&devices, avl_strcmp, false, NULL);
 }
@@ -197,3 +190,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);
+       }
+}