if (ret < 0)
return ret;
+ system_if_clear_state(dev);
device_check_state(dev);
return 0;
static void
__device_free_unused(struct device *dev)
{
- if (!list_empty(&dev->users) || dev->current_config)
+ if (!list_empty(&dev->users) || dev->current_config || config_init)
return;
device_free(dev);
struct device *odev = NULL, *dev;
enum dev_change_type change;
- D(DEVICE, "Create new device '%s' (%s)\n", name, type->name);
config = config_memdup(config);
if (!config)
return NULL;
device_delete(odev);
break;
}
- }
+ } else
+ D(DEVICE, "Create new device '%s' (%s)\n", name, type->name);
dev = type->create(config);
if (!dev)
return dev;
}
+
+void
+device_dump_status(struct blob_buf *b, struct device *dev)
+{
+ void *c, *s;
+
+ if (!dev) {
+ avl_for_each_element(&devices, dev, avl) {
+ if (!dev->present)
+ continue;
+ c = blobmsg_open_table(b, dev->ifname);
+ device_dump_status(b, dev);
+ blobmsg_close_table(b, c);
+ }
+
+ return;
+ }
+
+ if (!dev->present)
+ return;
+
+ blobmsg_add_string(b, "type", dev->type->name);
+ blobmsg_add_u8(b, "up", !!dev->active);
+ if (dev->type->dump_info)
+ dev->type->dump_info(dev, b);
+
+ s = blobmsg_open_table(b, "statistics");
+ if (dev->type->dump_stats)
+ dev->type->dump_stats(dev, b);
+ else
+ system_if_dump_stats(dev, b);
+ blobmsg_close_table(b, s);
+}