Spawn device events when adding dependency in device_replace so the dependency 
installer gets
the actual device status

Signed-off-by: Hans Dedecker <dedec...@gmail.com>
---
 device.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/device.c b/device.c
index 1636611..66eb6d4 100644
--- a/device.c
+++ b/device.c
@@ -534,19 +534,11 @@ static int device_refcount(struct device *dev)
        return count;
 }
 
-void device_add_user(struct device_user *dep, struct device *dev)
+static void
+__device_add_user(struct device_user *dep, struct device *dev)
 {
        struct safe_list *head;
 
-       if (dep->dev == dev)
-               return;
-
-       if (dep->dev)
-               device_remove_user(dep);
-
-       if (!dev)
-               return;
-
        dep->dev = dev;
 
        if (dep->alias)
@@ -567,6 +559,20 @@ void device_add_user(struct device_user *dep, struct 
device *dev)
        }
 }
 
+void device_add_user(struct device_user *dep, struct device *dev)
+{
+       if (dep->dev == dev)
+               return;
+
+       if (dep->dev)
+               device_remove_user(dep);
+
+       if (!dev)
+               return;
+
+       __device_add_user(dep, dev);
+}
+
 void
 device_free(struct device *dev)
 {
@@ -710,8 +716,7 @@ device_replace(struct device *dev, struct device *odev)
        list_for_each_entry_safe(dep, tmp, &odev->users.list, list.list) {
                device_release(dep);
                safe_list_del(&dep->list);
-               safe_list_add(&dep->list, &dev->users);
-               dep->dev = dev;
+               __device_add_user(dep, dev);
        }
        __devlock--;
 
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to