device_add_user: return immediately if the new device is the same as the old device
[project/netifd.git] / device.c
index 1c0736f67ce05260d5c1d3800f6bd52dec4140fd..53971c8dffc9a86d5516cd4cb7dbfe94cbf5e881 100644 (file)
--- a/device.c
+++ b/device.c
@@ -39,7 +39,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = {
        [DEV_ATTR_ENABLED] = { "enabled", BLOBMSG_TYPE_BOOL },
 };
 
-const struct config_param_list device_attr_list = {
+const struct uci_blob_param_list device_attr_list = {
        .n_params = __DEV_ATTR_MAX,
        .params = dev_attrs,
 };
@@ -408,6 +408,9 @@ 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);
 
@@ -499,9 +502,9 @@ static enum dev_change_type
 device_reload_config(struct device *dev, struct blob_attr *attr)
 {
        struct blob_attr *tb[__DEV_ATTR_MAX];
-       const struct config_param_list *cfg = dev->type->config_params;
+       const struct uci_blob_param_list *cfg = dev->type->config_params;
 
-       if (config_check_equal(dev->config, attr, cfg))
+       if (uci_blob_check_equal(dev->config, attr, cfg))
                return DEV_CONFIG_NO_CHANGE;
 
        if (cfg == &device_attr_list) {
@@ -584,7 +587,7 @@ device_create(const char *name, const struct device_type *type,
        struct device *odev = NULL, *dev;
        enum dev_change_type change;
 
-       config = config_memdup(config);
+       config = blob_memdup(config);
        if (!config)
                return NULL;