interface: allow an interface to specify device configs even when there are other...
authorFelix Fietkau <nbd@openwrt.org>
Sun, 19 Apr 2015 09:49:51 +0000 (11:49 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 19 Apr 2015 09:49:51 +0000 (11:49 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
device.h
interface.c

index 4b366412b2bc2bfff29e8bf268950fd2379e0d38..753e1fae55bcd16fe79e0fa0418e2de05b710206 100644 (file)
--- a/device.h
+++ b/device.h
@@ -21,6 +21,7 @@
 struct device;
 struct device_user;
 struct device_hotplug_ops;
+struct interface;
 
 typedef int (*device_state_cb)(struct device *, bool up);
 
@@ -165,6 +166,8 @@ struct device {
        bool default_config;
        bool wireless;
 
+       struct interface *config_iface;
+
        /* set interface up or down */
        device_state_cb set_state;
 
index 3281b70f68e078fcf34d06846ca7f1c231a48eba..ea018ad1f94fd596ac40c9bdaacc7c88c3bdc249 100644 (file)
@@ -525,9 +525,11 @@ interface_set_device_config(struct interface *iface, struct device *dev)
        if (!dev || !dev->default_config)
                return;
 
-       if (!iface->device_config && !dev->iface_config)
+       if (!iface->device_config &&
+           (!dev->iface_config || dev->config_iface != iface))
                return;
 
+       dev->config_iface = iface;
        dev->iface_config = iface->device_config;
        device_apply_config(dev, dev->type, iface->config);
 }