aboutsummaryrefslogtreecommitdiff
path: root/hw/arm/aspeed_soc.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-07-07 18:05:32 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-07-10 15:01:06 +0200
commit118bfd76c9c604588cb3f97811710576f58e5a76 (patch)
tree0b3c83772d214c827e2aa87581e2b9126052d612 /hw/arm/aspeed_soc.c
parente3fe3988d7851cac30abffae06d2f555ff7bee62 (diff)
downloadqemu-118bfd76c9c604588cb3f97811710576f58e5a76.zip
qemu-118bfd76c9c604588cb3f97811710576f58e5a76.tar.gz
qemu-118bfd76c9c604588cb3f97811710576f58e5a76.tar.bz2
qdev: Use returned bool to check for qdev_realize() etc. failure
Convert foo(..., &err); if (err) { ... } to if (!foo(..., &err)) { ... } for qdev_realize(), qdev_realize_and_unref(), qbus_realize() and their wrappers isa_realize_and_unref(), pci_realize_and_unref(), sysbus_realize(), sysbus_realize_and_unref(), usb_realize_and_unref(). Coccinelle script: @@ identifier fun = { isa_realize_and_unref, pci_realize_and_unref, qbus_realize, qdev_realize, qdev_realize_and_unref, sysbus_realize, sysbus_realize_and_unref, usb_realize_and_unref }; expression list args, args2; typedef Error; Error *err; @@ - fun(args, &err, args2); - if (err) + if (!fun(args, &err, args2)) { ... } Chokes on hw/arm/musicpal.c's lcd_refresh() with the unhelpful error message "no position information". Nothing to convert there; skipped. Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by ARMSSE being used both as typedef and function-like macro there. Converted manually. A few line breaks tidied up manually. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Greg Kurz <groug@kaod.org> Message-Id: <20200707160613.848843-5-armbru@redhat.com>
Diffstat (limited to 'hw/arm/aspeed_soc.c')
-rw-r--r--hw/arm/aspeed_soc.c45
1 files changed, 15 insertions, 30 deletions
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
index 311458a..fa56f96 100644
--- a/hw/arm/aspeed_soc.c
+++ b/hw/arm/aspeed_soc.c
@@ -230,8 +230,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
/* CPU */
for (i = 0; i < sc->num_cpus; i++) {
- qdev_realize(DEVICE(&s->cpu[i]), NULL, &err);
- if (err) {
+ if (!qdev_realize(DEVICE(&s->cpu[i]), NULL, &err)) {
error_propagate(errp, err);
return;
}
@@ -248,16 +247,14 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
sc->memmap[ASPEED_SRAM], &s->sram);
/* SCU */
- sysbus_realize(SYS_BUS_DEVICE(&s->scu), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), &err)) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_SCU]);
/* VIC */
- sysbus_realize(SYS_BUS_DEVICE(&s->vic), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->vic), &err)) {
error_propagate(errp, err);
return;
}
@@ -268,8 +265,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ));
/* RTC */
- sysbus_realize(SYS_BUS_DEVICE(&s->rtc), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->rtc), &err)) {
error_propagate(errp, err);
return;
}
@@ -280,8 +276,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
/* Timer */
object_property_set_link(OBJECT(&s->timerctrl),
OBJECT(&s->scu), "scu", &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), &err)) {
error_propagate(errp, err);
return;
}
@@ -302,8 +297,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
/* I2C */
object_property_set_link(OBJECT(&s->i2c), OBJECT(s->dram_mr), "dram",
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->i2c), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c), &err)) {
error_propagate(errp, err);
return;
}
@@ -320,8 +314,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
error_propagate(errp, err);
return;
}
- sysbus_realize(SYS_BUS_DEVICE(&s->fmc), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->fmc), &err)) {
error_propagate(errp, err);
return;
}
@@ -335,8 +328,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
for (i = 0; i < sc->spis_num; i++) {
object_property_set_int(OBJECT(&s->spi[i]), 1, "num-cs",
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), &err)) {
error_propagate(errp, err);
return;
}
@@ -348,8 +340,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
/* EHCI */
for (i = 0; i < sc->ehcis_num; i++) {
- sysbus_realize(SYS_BUS_DEVICE(&s->ehci[i]), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->ehci[i]), &err)) {
error_propagate(errp, err);
return;
}
@@ -360,8 +351,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
}
/* SDMC - SDRAM Memory Controller */
- sysbus_realize(SYS_BUS_DEVICE(&s->sdmc), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdmc), &err)) {
error_propagate(errp, err);
return;
}
@@ -373,8 +363,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
object_property_set_link(OBJECT(&s->wdt[i]),
OBJECT(&s->scu), "scu", &error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), &err)) {
error_propagate(errp, err);
return;
}
@@ -386,8 +375,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
for (i = 0; i < sc->macs_num; i++) {
object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "aspeed",
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->ftgmac100[i]), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->ftgmac100[i]), &err)) {
error_propagate(errp, err);
return;
}
@@ -398,8 +386,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
}
/* XDMA */
- sysbus_realize(SYS_BUS_DEVICE(&s->xdma), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->xdma), &err)) {
error_propagate(errp, err);
return;
}
@@ -409,8 +396,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
aspeed_soc_get_irq(s, ASPEED_XDMA));
/* GPIO */
- sysbus_realize(SYS_BUS_DEVICE(&s->gpio), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), &err)) {
error_propagate(errp, err);
return;
}
@@ -419,8 +405,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
aspeed_soc_get_irq(s, ASPEED_GPIO));
/* SDHCI */
- sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), &err)) {
error_propagate(errp, err);
return;
}