aboutsummaryrefslogtreecommitdiff
path: root/hw/arm/aspeed_ast2600.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-06-10 07:32:37 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-06-15 22:06:04 +0200
commitdb873cc5d1a4aaa67eea87768d504b2f89d88738 (patch)
tree5979d3c93f4c66784c1447ae27b8153ae4e42fa3 /hw/arm/aspeed_ast2600.c
parent0074fce61fecf40326845fa859119bbdd96df620 (diff)
sysbus: Convert qdev_set_parent_bus() use with Coccinelle, part 2
This is the same transformation as in the previous commit, except sysbus_init_child_obj() and realize are too separated for the commit's Coccinelle script to handle, typically because sysbus_init_child_obj() is in a device's instance_init() method, and the matching realize is in its realize() method. Perhaps a Coccinelle wizard could make it transform that pattern, but I'm just a bungler, and the best I can do is transforming the two separate parts separately: @@ expression errp; expression child; symbol true; @@ - object_property_set_bool(OBJECT(child), true, "realized", errp); + sysbus_realize(SYS_BUS_DEVICE(child), errp); // only correct with a matching sysbus_init_child_obj() transformation! @@ expression errp; expression child; symbol true; @@ - object_property_set_bool(child, true, "realized", errp); + sysbus_realize(SYS_BUS_DEVICE(child), errp); // only correct with a matching sysbus_init_child_obj() transformation! @@ expression child; @@ - qdev_init_nofail(DEVICE(child)); + sysbus_realize(SYS_BUS_DEVICE(child), &error_fatal); // only correct with a matching sysbus_init_child_obj() transformation! @@ expression child; expression dev; @@ dev = DEVICE(child); ... - qdev_init_nofail(dev); + sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal); // only correct with a matching sysbus_init_child_obj() transformation! @@ expression child; identifier dev; @@ DeviceState *dev = DEVICE(child); ... - qdev_init_nofail(dev); + sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal); // only correct with a matching sysbus_init_child_obj() transformation! @@ expression parent, name, size, type; expression child; symbol true; @@ - sysbus_init_child_obj(parent, name, child, size, type); + sysbus_init_child_XXX(parent, name, child, size, type); @@ expression parent, propname, type; expression child; @@ - sysbus_init_child_XXX(parent, propname, child, sizeof(*child), type) + object_initialize_child(parent, propname, child, type) @@ expression parent, propname, type; expression child; @@ - sysbus_init_child_XXX(parent, propname, &child, sizeof(child), type) + object_initialize_child(parent, propname, &child, type) This script is *unsound*: we need to manually verify init and realize conversions are properly paired. This commit has only the pairs where object_initialize_child()'s @child and sysbus_realize()'s @dev argument text match exactly within the same source file. Note that Coccinelle chokes on ARMSSE typedef vs. macro in hw/arm/armsse.c. Worked around by temporarily renaming the macro for the spatch run. Signed-off-by: Markus Armbruster <armbru@redhat.com> Acked-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20200610053247.1583243-49-armbru@redhat.com>
Diffstat (limited to 'hw/arm/aspeed_ast2600.c')
-rw-r--r--hw/arm/aspeed_ast2600.c89
1 files changed, 39 insertions, 50 deletions
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
index 10e92643c1..7c39adb272 100644
--- a/hw/arm/aspeed_ast2600.c
+++ b/hw/arm/aspeed_ast2600.c
@@ -131,7 +131,7 @@ static void aspeed_soc_ast2600_init(Object *obj)
}
snprintf(typename, sizeof(typename), "aspeed.scu-%s", socname);
- sysbus_init_child_obj(obj, "scu", &s->scu, sizeof(s->scu), typename);
+ object_initialize_child(obj, "scu", &s->scu, typename);
qdev_prop_set_uint32(DEVICE(&s->scu), "silicon-rev",
sc->silicon_rev);
object_property_add_alias(obj, "hw-strap1", OBJECT(&s->scu),
@@ -141,36 +141,33 @@ static void aspeed_soc_ast2600_init(Object *obj)
object_property_add_alias(obj, "hw-prot-key", OBJECT(&s->scu),
"hw-prot-key");
- sysbus_init_child_obj(obj, "a7mpcore", &s->a7mpcore,
- sizeof(s->a7mpcore), TYPE_A15MPCORE_PRIV);
+ object_initialize_child(obj, "a7mpcore", &s->a7mpcore,
+ TYPE_A15MPCORE_PRIV);
- sysbus_init_child_obj(obj, "rtc", &s->rtc, sizeof(s->rtc),
- TYPE_ASPEED_RTC);
+ object_initialize_child(obj, "rtc", &s->rtc, TYPE_ASPEED_RTC);
snprintf(typename, sizeof(typename), "aspeed.timer-%s", socname);
- sysbus_init_child_obj(obj, "timerctrl", &s->timerctrl,
- sizeof(s->timerctrl), typename);
+ object_initialize_child(obj, "timerctrl", &s->timerctrl, typename);
snprintf(typename, sizeof(typename), "aspeed.i2c-%s", socname);
- sysbus_init_child_obj(obj, "i2c", &s->i2c, sizeof(s->i2c), typename);
+ object_initialize_child(obj, "i2c", &s->i2c, typename);
snprintf(typename, sizeof(typename), "aspeed.fmc-%s", socname);
- sysbus_init_child_obj(obj, "fmc", &s->fmc, sizeof(s->fmc), typename);
+ object_initialize_child(obj, "fmc", &s->fmc, typename);
object_property_add_alias(obj, "num-cs", OBJECT(&s->fmc), "num-cs");
for (i = 0; i < sc->spis_num; i++) {
snprintf(typename, sizeof(typename), "aspeed.spi%d-%s", i + 1, socname);
- sysbus_init_child_obj(obj, "spi[*]", &s->spi[i],
- sizeof(s->spi[i]), typename);
+ object_initialize_child(obj, "spi[*]", &s->spi[i], typename);
}
for (i = 0; i < sc->ehcis_num; i++) {
- sysbus_init_child_obj(obj, "ehci[*]", &s->ehci[i],
- sizeof(s->ehci[i]), TYPE_PLATFORM_EHCI);
+ object_initialize_child(obj, "ehci[*]", &s->ehci[i],
+ TYPE_PLATFORM_EHCI);
}
snprintf(typename, sizeof(typename), "aspeed.sdmc-%s", socname);
- sysbus_init_child_obj(obj, "sdmc", &s->sdmc, sizeof(s->sdmc), typename);
+ object_initialize_child(obj, "sdmc", &s->sdmc, typename);
object_property_add_alias(obj, "ram-size", OBJECT(&s->sdmc),
"ram-size");
object_property_add_alias(obj, "max-ram-size", OBJECT(&s->sdmc),
@@ -178,30 +175,26 @@ static void aspeed_soc_ast2600_init(Object *obj)
for (i = 0; i < sc->wdts_num; i++) {
snprintf(typename, sizeof(typename), "aspeed.wdt-%s", socname);
- sysbus_init_child_obj(obj, "wdt[*]", &s->wdt[i],
- sizeof(s->wdt[i]), typename);
+ object_initialize_child(obj, "wdt[*]", &s->wdt[i], typename);
}
for (i = 0; i < sc->macs_num; i++) {
- sysbus_init_child_obj(obj, "ftgmac100[*]", &s->ftgmac100[i],
- sizeof(s->ftgmac100[i]), TYPE_FTGMAC100);
+ object_initialize_child(obj, "ftgmac100[*]", &s->ftgmac100[i],
+ TYPE_FTGMAC100);
- sysbus_init_child_obj(obj, "mii[*]", &s->mii[i], sizeof(s->mii[i]),
- TYPE_ASPEED_MII);
+ object_initialize_child(obj, "mii[*]", &s->mii[i], TYPE_ASPEED_MII);
}
- sysbus_init_child_obj(obj, "xdma", &s->xdma, sizeof(s->xdma),
- TYPE_ASPEED_XDMA);
+ object_initialize_child(obj, "xdma", &s->xdma, TYPE_ASPEED_XDMA);
snprintf(typename, sizeof(typename), "aspeed.gpio-%s", socname);
- sysbus_init_child_obj(obj, "gpio", &s->gpio, sizeof(s->gpio), typename);
+ object_initialize_child(obj, "gpio", &s->gpio, typename);
snprintf(typename, sizeof(typename), "aspeed.gpio-%s-1_8v", socname);
- sysbus_init_child_obj(obj, "gpio_1_8v", &s->gpio_1_8v,
- sizeof(s->gpio_1_8v), typename);
+ object_initialize_child(obj, "gpio_1_8v", &s->gpio_1_8v, typename);
- sysbus_init_child_obj(obj, "sd-controller", &s->sdhci,
- sizeof(s->sdhci), TYPE_ASPEED_SDHCI);
+ object_initialize_child(obj, "sd-controller", &s->sdhci,
+ TYPE_ASPEED_SDHCI);
object_property_set_int(OBJECT(&s->sdhci), 2, "num-slots", &error_abort);
@@ -212,8 +205,8 @@ static void aspeed_soc_ast2600_init(Object *obj)
sizeof(s->sdhci.slots[i]), TYPE_SYSBUS_SDHCI);
}
- sysbus_init_child_obj(obj, "emmc-controller", &s->emmc,
- sizeof(s->emmc), TYPE_ASPEED_SDHCI);
+ object_initialize_child(obj, "emmc-controller", &s->emmc,
+ TYPE_ASPEED_SDHCI);
object_property_set_int(OBJECT(&s->emmc), 1, "num-slots", &error_abort);
@@ -282,8 +275,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
ASPEED_SOC_AST2600_MAX_IRQ + GIC_INTERNAL,
"num-irq", &error_abort);
- object_property_set_bool(OBJECT(&s->a7mpcore), true, "realized",
- &error_abort);
+ sysbus_realize(SYS_BUS_DEVICE(&s->a7mpcore), &error_abort);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->a7mpcore), 0, ASPEED_A7MPCORE_ADDR);
for (i = 0; i < sc->num_cpus; i++) {
@@ -311,7 +303,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
sc->memmap[ASPEED_SRAM], &s->sram);
/* SCU */
- object_property_set_bool(OBJECT(&s->scu), true, "realized", &err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->scu), &err);
if (err) {
error_propagate(errp, err);
return;
@@ -319,7 +311,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_SCU]);
/* RTC */
- object_property_set_bool(OBJECT(&s->rtc), true, "realized", &err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->rtc), &err);
if (err) {
error_propagate(errp, err);
return;
@@ -331,7 +323,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
/* Timer */
object_property_set_link(OBJECT(&s->timerctrl),
OBJECT(&s->scu), "scu", &error_abort);
- object_property_set_bool(OBJECT(&s->timerctrl), true, "realized", &err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), &err);
if (err) {
error_propagate(errp, err);
return;
@@ -356,7 +348,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
error_propagate(errp, err);
return;
}
- object_property_set_bool(OBJECT(&s->i2c), true, "realized", &err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->i2c), &err);
if (err) {
error_propagate(errp, err);
return;
@@ -384,7 +376,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
error_propagate(errp, err);
return;
}
- object_property_set_bool(OBJECT(&s->fmc), true, "realized", &err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->fmc), &err);
if (err) {
error_propagate(errp, err);
return;
@@ -404,8 +396,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
return;
}
object_property_set_int(OBJECT(&s->spi[i]), 1, "num-cs", &err);
- object_property_set_bool(OBJECT(&s->spi[i]), true, "realized",
- &local_err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), &local_err);
error_propagate(&err, local_err);
if (err) {
error_propagate(errp, err);
@@ -419,7 +410,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
/* EHCI */
for (i = 0; i < sc->ehcis_num; i++) {
- object_property_set_bool(OBJECT(&s->ehci[i]), true, "realized", &err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->ehci[i]), &err);
if (err) {
error_propagate(errp, err);
return;
@@ -431,7 +422,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
}
/* SDMC - SDRAM Memory Controller */
- object_property_set_bool(OBJECT(&s->sdmc), true, "realized", &err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->sdmc), &err);
if (err) {
error_propagate(errp, err);
return;
@@ -444,7 +435,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
object_property_set_link(OBJECT(&s->wdt[i]),
OBJECT(&s->scu), "scu", &error_abort);
- object_property_set_bool(OBJECT(&s->wdt[i]), true, "realized", &err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), &err);
if (err) {
error_propagate(errp, err);
return;
@@ -457,8 +448,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
for (i = 0; i < sc->macs_num; i++) {
object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "aspeed",
&err);
- object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "realized",
- &local_err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->ftgmac100[i]), &local_err);
error_propagate(&err, local_err);
if (err) {
error_propagate(errp, err);
@@ -471,8 +461,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
object_property_set_link(OBJECT(&s->mii[i]), OBJECT(&s->ftgmac100[i]),
"nic", &error_abort);
- object_property_set_bool(OBJECT(&s->mii[i]), true, "realized",
- &err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->mii[i]), &err);
if (err) {
error_propagate(errp, err);
return;
@@ -483,7 +472,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
}
/* XDMA */
- object_property_set_bool(OBJECT(&s->xdma), true, "realized", &err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->xdma), &err);
if (err) {
error_propagate(errp, err);
return;
@@ -494,7 +483,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
aspeed_soc_get_irq(s, ASPEED_XDMA));
/* GPIO */
- object_property_set_bool(OBJECT(&s->gpio), true, "realized", &err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->gpio), &err);
if (err) {
error_propagate(errp, err);
return;
@@ -503,7 +492,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), 0,
aspeed_soc_get_irq(s, ASPEED_GPIO));
- object_property_set_bool(OBJECT(&s->gpio_1_8v), true, "realized", &err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->gpio_1_8v), &err);
if (err) {
error_propagate(errp, err);
return;
@@ -514,7 +503,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
aspeed_soc_get_irq(s, ASPEED_GPIO_1_8V));
/* SDHCI */
- object_property_set_bool(OBJECT(&s->sdhci), true, "realized", &err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), &err);
if (err) {
error_propagate(errp, err);
return;
@@ -525,7 +514,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
aspeed_soc_get_irq(s, ASPEED_SDHCI));
/* eMMC */
- object_property_set_bool(OBJECT(&s->emmc), true, "realized", &err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->emmc), &err);
if (err) {
error_propagate(errp, err);
return;