[OpenWrt-Devel] [PATCH 4/4] netifd: Spawn device events when registering dependency in device_replace
Hans Dedecker
dedeckeh at gmail.com
Tue Aug 4 10:22:45 EDT 2015
Spawn device events when adding dependency in device_replace so the dependency installer gets
the actual device status
Signed-off-by: Hans Dedecker <dedeckeh at 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 at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list