X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=device.c;h=56fc3f787713ce5eb0d9e3bf6833b460d1d264cd;hp=5fa0ac12fe449a16fd8461f173524a4faf32eab7;hb=134775b1f41fa19a816768268b9d0f8dad86bd90;hpb=bac6f28ce1d9abc381c2f85c32bcd37c33cd00c8 diff --git a/device.c b/device.c index 5fa0ac1..56fc3f7 100644 --- a/device.c +++ b/device.c @@ -31,15 +31,15 @@ static struct avl_tree devices; static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = { - [DEV_ATTR_TYPE] = { "type", BLOBMSG_TYPE_STRING }, - [DEV_ATTR_IFNAME] = { "ifname", BLOBMSG_TYPE_ARRAY }, - [DEV_ATTR_MTU] = { "mtu", BLOBMSG_TYPE_INT32 }, - [DEV_ATTR_MACADDR] = { "macaddr", BLOBMSG_TYPE_STRING }, - [DEV_ATTR_TXQUEUELEN] = { "txqueuelen", BLOBMSG_TYPE_INT32 }, - [DEV_ATTR_ENABLED] = { "enabled", BLOBMSG_TYPE_BOOL }, + [DEV_ATTR_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING }, + [DEV_ATTR_IFNAME] = { .name = "ifname", .type = BLOBMSG_TYPE_ARRAY }, + [DEV_ATTR_MTU] = { .name = "mtu", .type = BLOBMSG_TYPE_INT32 }, + [DEV_ATTR_MACADDR] = { .name = "macaddr", .type = BLOBMSG_TYPE_STRING }, + [DEV_ATTR_TXQUEUELEN] = { .name = "txqueuelen", .type = BLOBMSG_TYPE_INT32 }, + [DEV_ATTR_ENABLED] = { .name = "enabled", .type = 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, }; @@ -216,7 +216,7 @@ int device_claim(struct device_user *dep) if (ret == 0) device_broadcast_event(dev, DEV_EVENT_UP); else { - D(DEVICE, "claim device %s failed: %d\n", dev->ifname, ret); + D(DEVICE, "claim %s %s failed: %d\n", dev->type->name, dev->ifname, ret); dev->active = 0; dep->claimed = false; } @@ -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) {