Hi Cédric, On 5/6/19 4:20 PM, Cédric Le Goater wrote: > Signed-off-by: Cédric Le Goater <c...@kaod.org> > --- > hw/arm/aspeed_soc.c | 50 ++++++++++++++++++--------------------------- > 1 file changed, 20 insertions(+), 30 deletions(-) > > diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c > index bd83618ceba9..4b705afd096a 100644 > --- a/hw/arm/aspeed_soc.c > +++ b/hw/arm/aspeed_soc.c > @@ -172,12 +172,11 @@ static void aspeed_soc_init(Object *obj) > AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); > int i; > > - object_initialize(&s->cpu, sizeof(s->cpu), sc->info->cpu_type); > - object_property_add_child(obj, "cpu", OBJECT(&s->cpu), NULL); > + object_initialize_child(obj, "cpu", OBJECT(&s->cpu), sizeof(s->cpu), > + sc->info->cpu_type, &error_abort, NULL); > > - object_initialize(&s->scu, sizeof(s->scu), TYPE_ASPEED_SCU); > - object_property_add_child(obj, "scu", OBJECT(&s->scu), NULL); > - qdev_set_parent_bus(DEVICE(&s->scu), sysbus_get_default()); > + sysbus_init_child_obj(obj, "scu", OBJECT(&s->scu), sizeof(s->scu), > + TYPE_ASPEED_SCU);
A similar patch (although better described IMO) was posted here: https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg05931.html However you improved it by using sysbus_init_child_obj(). If you don't mind I'll respin addressing Markus comment and using your improvement. > qdev_prop_set_uint32(DEVICE(&s->scu), "silicon-rev", > sc->info->silicon_rev); > object_property_add_alias(obj, "hw-strap1", OBJECT(&s->scu), > @@ -187,36 +186,29 @@ static void aspeed_soc_init(Object *obj) > object_property_add_alias(obj, "hw-prot-key", OBJECT(&s->scu), > "hw-prot-key", &error_abort); > > - object_initialize(&s->vic, sizeof(s->vic), TYPE_ASPEED_VIC); > - object_property_add_child(obj, "vic", OBJECT(&s->vic), NULL); > - qdev_set_parent_bus(DEVICE(&s->vic), sysbus_get_default()); > + sysbus_init_child_obj(obj, "vic", OBJECT(&s->vic), sizeof(s->vic), > + TYPE_ASPEED_VIC); > > - object_initialize(&s->timerctrl, sizeof(s->timerctrl), > TYPE_ASPEED_TIMER); > - object_property_add_child(obj, "timerctrl", OBJECT(&s->timerctrl), NULL); > + sysbus_init_child_obj(obj, "timerctrl", OBJECT(&s->timerctrl), > + sizeof(s->timerctrl), TYPE_ASPEED_TIMER); > object_property_add_const_link(OBJECT(&s->timerctrl), "scu", > OBJECT(&s->scu), &error_abort); > - qdev_set_parent_bus(DEVICE(&s->timerctrl), sysbus_get_default()); > > - object_initialize(&s->i2c, sizeof(s->i2c), TYPE_ASPEED_I2C); > - object_property_add_child(obj, "i2c", OBJECT(&s->i2c), NULL); > - qdev_set_parent_bus(DEVICE(&s->i2c), sysbus_get_default()); > + sysbus_init_child_obj(obj, "i2c", OBJECT(&s->i2c), sizeof(s->i2c), > + TYPE_ASPEED_I2C); > > - object_initialize(&s->fmc, sizeof(s->fmc), sc->info->fmc_typename); > - object_property_add_child(obj, "fmc", OBJECT(&s->fmc), NULL); > - qdev_set_parent_bus(DEVICE(&s->fmc), sysbus_get_default()); > + sysbus_init_child_obj(obj, "fmc", OBJECT(&s->fmc), sizeof(s->fmc), > + sc->info->fmc_typename); > object_property_add_alias(obj, "num-cs", OBJECT(&s->fmc), "num-cs", > &error_abort); > > for (i = 0; i < sc->info->spis_num; i++) { > - object_initialize(&s->spi[i], sizeof(s->spi[i]), > - sc->info->spi_typename[i]); > - object_property_add_child(obj, "spi[*]", OBJECT(&s->spi[i]), NULL); > - qdev_set_parent_bus(DEVICE(&s->spi[i]), sysbus_get_default()); > + sysbus_init_child_obj(obj, "spi[*]", OBJECT(&s->spi[i]), > + sizeof(s->spi[i]), sc->info->spi_typename[i]); > } > > - object_initialize(&s->sdmc, sizeof(s->sdmc), TYPE_ASPEED_SDMC); > - object_property_add_child(obj, "sdmc", OBJECT(&s->sdmc), NULL); > - qdev_set_parent_bus(DEVICE(&s->sdmc), sysbus_get_default()); > + sysbus_init_child_obj(obj, "sdmc", OBJECT(&s->sdmc), sizeof(s->sdmc), > + TYPE_ASPEED_SDMC); > qdev_prop_set_uint32(DEVICE(&s->sdmc), "silicon-rev", > sc->info->silicon_rev); > object_property_add_alias(obj, "ram-size", OBJECT(&s->sdmc), > @@ -225,16 +217,14 @@ static void aspeed_soc_init(Object *obj) > "max-ram-size", &error_abort); > > for (i = 0; i < sc->info->wdts_num; i++) { > - object_initialize(&s->wdt[i], sizeof(s->wdt[i]), TYPE_ASPEED_WDT); > - object_property_add_child(obj, "wdt[*]", OBJECT(&s->wdt[i]), NULL); > - qdev_set_parent_bus(DEVICE(&s->wdt[i]), sysbus_get_default()); > + sysbus_init_child_obj(obj, "wdt[*]", OBJECT(&s->wdt[i]), > + sizeof(s->wdt[i]), TYPE_ASPEED_WDT); > qdev_prop_set_uint32(DEVICE(&s->wdt[i]), "silicon-rev", > sc->info->silicon_rev); > } > > - object_initialize(&s->ftgmac100, sizeof(s->ftgmac100), TYPE_FTGMAC100); > - object_property_add_child(obj, "ftgmac100", OBJECT(&s->ftgmac100), NULL); > - qdev_set_parent_bus(DEVICE(&s->ftgmac100), sysbus_get_default()); > + sysbus_init_child_obj(obj, "ftgmac100", OBJECT(&s->ftgmac100), > + sizeof(s->ftgmac100), TYPE_FTGMAC100); > } > > static void aspeed_soc_realize(DeviceState *dev, Error **errp) >