fix clearing device state, trigger it on device_init()
authorFelix Fietkau <nbd@openwrt.org>
Sun, 9 Oct 2011 20:42:34 +0000 (22:42 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 9 Oct 2011 20:42:34 +0000 (22:42 +0200)
device.c
system-dummy.c
system-linux.c
system.h

index 5b27ce0..6929177 100644 (file)
--- a/device.c
+++ b/device.c
@@ -206,6 +206,7 @@ int device_init(struct device *dev, const struct device_type *type, const char *
        if (ret < 0)
                return ret;
 
        if (ret < 0)
                return ret;
 
+       system_if_clear_state(dev);
        device_check_state(dev);
 
        return 0;
        device_check_state(dev);
 
        return 0;
index 9a646dc..00a9b2a 100644 (file)
@@ -64,6 +64,11 @@ int system_if_down(struct device *dev)
        return 0;
 }
 
        return 0;
 }
 
+void system_if_clear_state(struct device *dev)
+{
+       return 0;
+}
+
 int system_if_check(struct device *dev)
 {
        dev->ifindex = 0;
 int system_if_check(struct device *dev)
 {
        dev->ifindex = 0;
index b823099..9f1aa9e 100644 (file)
@@ -202,7 +202,7 @@ static int system_if_flags(const char *ifname, unsigned add, unsigned rem)
 /*
  * Clear bridge (membership) state and bring down device
  */
 /*
  * Clear bridge (membership) state and bring down device
  */
-static void system_if_clear_state(struct device *dev)
+void system_if_clear_state(struct device *dev)
 {
        char buf[256];
        char *bridge;
 {
        char buf[256];
        char *bridge;
@@ -236,7 +236,6 @@ int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg)
 {
        unsigned long args[4] = {};
 
 {
        unsigned long args[4] = {};
 
-       system_if_clear_state(bridge);
        if (ioctl(sock_ioctl, SIOCBRADDBR, bridge->ifname) < 0)
                return -1;
 
        if (ioctl(sock_ioctl, SIOCBRADDBR, bridge->ifname) < 0)
                return -1;
 
@@ -291,7 +290,6 @@ static int system_vlan(struct device *dev, int id)
 
 int system_vlan_add(struct device *dev, int id)
 {
 
 int system_vlan_add(struct device *dev, int id)
 {
-       system_if_clear_state(dev);
        return system_vlan(dev, id);
 }
 
        return system_vlan(dev, id);
 }
 
@@ -313,7 +311,6 @@ int system_if_down(struct device *dev)
 
 int system_if_check(struct device *dev)
 {
 
 int system_if_check(struct device *dev)
 {
-       system_if_clear_state(dev);
        device_set_present(dev, (system_if_resolve(dev) >= 0));
        return 0;
 }
        device_set_present(dev, (system_if_resolve(dev) >= 0));
        return 0;
 }
index a2bcf04..7600417 100644 (file)
--- a/system.h
+++ b/system.h
@@ -32,6 +32,7 @@ int system_bridge_delif(struct device *bridge, struct device *dev);
 int system_vlan_add(struct device *dev, int id);
 int system_vlan_del(struct device *dev);
 
 int system_vlan_add(struct device *dev, int id);
 int system_vlan_del(struct device *dev);
 
+void system_if_clear_state(struct device *dev);
 int system_if_up(struct device *dev);
 int system_if_down(struct device *dev);
 int system_if_check(struct device *dev);
 int system_if_up(struct device *dev);
 int system_if_down(struct device *dev);
 int system_if_check(struct device *dev);