summaryrefslogtreecommitdiffstats
path: root/hw/arm/bcm2835_peripherals.c
diff options
context:
space:
mode:
authorMarkus Armbruster2020-07-07 18:05:32 +0200
committerMarkus Armbruster2020-07-10 15:01:06 +0200
commit118bfd76c9c604588cb3f97811710576f58e5a76 (patch)
tree0b3c83772d214c827e2aa87581e2b9126052d612 /hw/arm/bcm2835_peripherals.c
parenterror: Document Error API usage rules (diff)
downloadqemu-118bfd76c9c604588cb3f97811710576f58e5a76.tar.gz
qemu-118bfd76c9c604588cb3f97811710576f58e5a76.tar.xz
qemu-118bfd76c9c604588cb3f97811710576f58e5a76.zip
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/bcm2835_peripherals.c')
-rw-r--r--hw/arm/bcm2835_peripherals.c45
1 files changed, 15 insertions, 30 deletions
diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
index 7ffdf62067..2df81168e4 100644
--- a/hw/arm/bcm2835_peripherals.c
+++ b/hw/arm/bcm2835_peripherals.c
@@ -161,8 +161,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
}
/* Interrupt Controller */
- sysbus_realize(SYS_BUS_DEVICE(&s->ic), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->ic), &err)) {
error_propagate(errp, err);
return;
}
@@ -172,8 +171,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
sysbus_pass_irq(SYS_BUS_DEVICE(s), SYS_BUS_DEVICE(&s->ic));
/* Sys Timer */
- sysbus_realize(SYS_BUS_DEVICE(&s->systmr), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->systmr), &err)) {
error_propagate(errp, err);
return;
}
@@ -185,8 +183,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
/* UART0 */
qdev_prop_set_chr(DEVICE(&s->uart0), "chardev", serial_hd(0));
- sysbus_realize(SYS_BUS_DEVICE(&s->uart0), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->uart0), &err)) {
error_propagate(errp, err);
return;
}
@@ -200,8 +197,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
/* AUX / UART1 */
qdev_prop_set_chr(DEVICE(&s->aux), "chardev", serial_hd(1));
- sysbus_realize(SYS_BUS_DEVICE(&s->aux), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->aux), &err)) {
error_propagate(errp, err);
return;
}
@@ -213,8 +209,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
INTERRUPT_AUX));
/* Mailboxes */
- sysbus_realize(SYS_BUS_DEVICE(&s->mboxes), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->mboxes), &err)) {
error_propagate(errp, err);
return;
}
@@ -239,8 +234,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
return;
}
- sysbus_realize(SYS_BUS_DEVICE(&s->fb), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->fb), &err)) {
error_propagate(errp, err);
return;
}
@@ -251,8 +245,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
qdev_get_gpio_in(DEVICE(&s->mboxes), MBOX_CHAN_FB));
/* Property channel */
- sysbus_realize(SYS_BUS_DEVICE(&s->property), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->property), &err)) {
error_propagate(errp, err);
return;
}
@@ -264,8 +257,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
qdev_get_gpio_in(DEVICE(&s->mboxes), MBOX_CHAN_PROPERTY));
/* Random Number Generator */
- sysbus_realize(SYS_BUS_DEVICE(&s->rng), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->rng), &err)) {
error_propagate(errp, err);
return;
}
@@ -289,8 +281,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
&error_abort);
object_property_set_bool(OBJECT(&s->sdhci), true, "pending-insert-quirk",
&error_abort);
- sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), &err)) {
error_propagate(errp, err);
return;
}
@@ -302,8 +293,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
INTERRUPT_ARASANSDIO));
/* SDHOST */
- sysbus_realize(SYS_BUS_DEVICE(&s->sdhost), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhost), &err)) {
error_propagate(errp, err);
return;
}
@@ -315,8 +305,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
INTERRUPT_SDIO));
/* DMA Channels */
- sysbus_realize(SYS_BUS_DEVICE(&s->dma), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->dma), &err)) {
error_propagate(errp, err);
return;
}
@@ -334,8 +323,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
}
/* THERMAL */
- sysbus_realize(SYS_BUS_DEVICE(&s->thermal), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->thermal), &err)) {
error_propagate(errp, err);
return;
}
@@ -343,8 +331,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->thermal), 0));
/* 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;
}
@@ -355,8 +342,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->gpio), "sd-bus");
/* Mphi */
- sysbus_realize(SYS_BUS_DEVICE(&s->mphi), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->mphi), &err)) {
error_propagate(errp, err);
return;
}
@@ -368,8 +354,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
INTERRUPT_HOSTPORT));
/* DWC2 */
- sysbus_realize(SYS_BUS_DEVICE(&s->dwc2), &err);
- if (err) {
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->dwc2), &err)) {
error_propagate(errp, err);
return;
}