static void __init dev_init(void)
{
- avl_init(&devices, avl_strcmp, false, NULL);
+ avl_init(&devices, avl_strcmp, true, NULL);
}
static void device_broadcast_event(struct device *dev, enum device_event ev)
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;
+
odev = device_get(name, false);
if (odev) {
change = device_check_config(odev, config);
switch (change) {
case DEV_CONFIG_APPLIED:
free(odev->config);
- odev->config = config_memdup(config);
+ odev->config = config;
if (odev->present) {
device_set_present(odev, false);
device_set_present(odev, true);
}
/* fall through */
case DEV_CONFIG_NO_CHANGE:
+ free(config);
return odev;
case DEV_CONFIG_RECREATE:
break;
}
dev = type->create(config);
- dev->config = config_memdup(config);
+ dev->config = config;
if (odev)
device_replace(dev, odev);