device: do not check state from within device_init
authorFelix Fietkau <nbd@nbd.name>
Sat, 18 Jul 2020 12:58:15 +0000 (14:58 +0200)
committerFelix Fietkau <nbd@nbd.name>
Sat, 18 Jul 2020 15:40:54 +0000 (17:40 +0200)
At this point the device is usually not fully set up yet and cannot handle
state changes / bringup

Signed-off-by: Felix Fietkau <nbd@nbd.name>
device.c

index 128151a1eb8105116ac04f46cbb7d088c518f9ea..70cb6a7b86b469c95567c03607ad4f44cc38fab7 100644 (file)
--- a/device.c
+++ b/device.c
@@ -509,7 +509,6 @@ int device_init(struct device *dev, struct device_type *type, const char *ifname
                return ret;
 
        system_if_clear_state(dev);
-       device_check_state(dev);
 
        return 0;
 }
@@ -539,6 +538,9 @@ device_create_default(const char *name, bool external)
        dev->default_config = true;
        if (external)
                system_if_apply_settings(dev, &dev->settings, dev->settings.flags);
+
+       device_check_state(dev);
+
        return dev;
 }
 
@@ -794,6 +796,7 @@ device_init_pending(void)
 
                dev->type->config_init(dev);
                dev->config_pending = false;
+               device_check_state(dev);
        }
 }
 
@@ -956,6 +959,8 @@ device_create(const char *name, struct device_type *type,
                dev->config_pending = false;
        }
 
+       device_check_state(dev);
+
        return dev;
 }