From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: patches@linaro.org, Paolo Bonzini <pbonzini@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH 2/2] hw/arm/bcm2835_peripherals: Use sysbus_init_child()
Date: Fri, 16 Feb 2018 13:45:16 +0000 [thread overview]
Message-ID: <20180216134516.6269-3-peter.maydell@linaro.org> (raw)
In-Reply-To: <20180216134516.6269-1-peter.maydell@linaro.org>
Use the new sysbus_init_child() function rather than
opencoding the init-and-parent operations.
This commit was created with coccinelle:
spatch --in-place -sp_file sysbus-init-child.spatch --keep-comments hw/arm/bcm2835_peripherals.c
and the following spatch file:
@@
expression CHILD, CHILDTYPE, POBJ, CHILDNAME, ERREXPR;
@@
- object_initialize(&CHILD, sizeof(CHILD), CHILDTYPE);
- object_property_add_child(POBJ, CHILDNAME, OBJECT(&CHILD), ERREXPR);
- qdev_set_parent_bus(DEVICE(&CHILD), sysbus_get_default());
+ sysbus_init_child(POBJ, CHILDNAME, &CHILD, sizeof(CHILD), CHILDTYPE);
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/arm/bcm2835_peripherals.c | 36 ++++++++++++------------------------
1 file changed, 12 insertions(+), 24 deletions(-)
diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
index 13b63970d7..7968d611ef 100644
--- a/hw/arm/bcm2835_peripherals.c
+++ b/hw/arm/bcm2835_peripherals.c
@@ -41,9 +41,7 @@ static void bcm2835_peripherals_init(Object *obj)
MBOX_CHAN_COUNT << MBOX_AS_CHAN_SHIFT);
/* Interrupt Controller */
- object_initialize(&s->ic, sizeof(s->ic), TYPE_BCM2835_IC);
- object_property_add_child(obj, "ic", OBJECT(&s->ic), NULL);
- qdev_set_parent_bus(DEVICE(&s->ic), sysbus_get_default());
+ sysbus_init_child(obj, "ic", &s->ic, sizeof(s->ic), TYPE_BCM2835_IC);
/* UART0 */
s->uart0 = SYS_BUS_DEVICE(object_new("pl011"));
@@ -51,14 +49,11 @@ static void bcm2835_peripherals_init(Object *obj)
qdev_set_parent_bus(DEVICE(s->uart0), sysbus_get_default());
/* AUX / UART1 */
- object_initialize(&s->aux, sizeof(s->aux), TYPE_BCM2835_AUX);
- object_property_add_child(obj, "aux", OBJECT(&s->aux), NULL);
- qdev_set_parent_bus(DEVICE(&s->aux), sysbus_get_default());
+ sysbus_init_child(obj, "aux", &s->aux, sizeof(s->aux), TYPE_BCM2835_AUX);
/* Mailboxes */
- object_initialize(&s->mboxes, sizeof(s->mboxes), TYPE_BCM2835_MBOX);
- object_property_add_child(obj, "mbox", OBJECT(&s->mboxes), NULL);
- qdev_set_parent_bus(DEVICE(&s->mboxes), sysbus_get_default());
+ sysbus_init_child(obj, "mbox", &s->mboxes, sizeof(s->mboxes),
+ TYPE_BCM2835_MBOX);
object_property_add_const_link(OBJECT(&s->mboxes), "mbox-mr",
OBJECT(&s->mbox_mr), &error_abort);
@@ -86,32 +81,25 @@ static void bcm2835_peripherals_init(Object *obj)
OBJECT(&s->gpu_bus_mr), &error_abort);
/* Random Number Generator */
- object_initialize(&s->rng, sizeof(s->rng), TYPE_BCM2835_RNG);
- object_property_add_child(obj, "rng", OBJECT(&s->rng), NULL);
- qdev_set_parent_bus(DEVICE(&s->rng), sysbus_get_default());
+ sysbus_init_child(obj, "rng", &s->rng, sizeof(s->rng), TYPE_BCM2835_RNG);
/* Extended Mass Media Controller */
- object_initialize(&s->sdhci, sizeof(s->sdhci), TYPE_SYSBUS_SDHCI);
- object_property_add_child(obj, "sdhci", OBJECT(&s->sdhci), NULL);
- qdev_set_parent_bus(DEVICE(&s->sdhci), sysbus_get_default());
+ sysbus_init_child(obj, "sdhci", &s->sdhci, sizeof(s->sdhci),
+ TYPE_SYSBUS_SDHCI);
/* SDHOST */
- object_initialize(&s->sdhost, sizeof(s->sdhost), TYPE_BCM2835_SDHOST);
- object_property_add_child(obj, "sdhost", OBJECT(&s->sdhost), NULL);
- qdev_set_parent_bus(DEVICE(&s->sdhost), sysbus_get_default());
+ sysbus_init_child(obj, "sdhost", &s->sdhost, sizeof(s->sdhost),
+ TYPE_BCM2835_SDHOST);
/* DMA Channels */
- object_initialize(&s->dma, sizeof(s->dma), TYPE_BCM2835_DMA);
- object_property_add_child(obj, "dma", OBJECT(&s->dma), NULL);
- qdev_set_parent_bus(DEVICE(&s->dma), sysbus_get_default());
+ sysbus_init_child(obj, "dma", &s->dma, sizeof(s->dma), TYPE_BCM2835_DMA);
object_property_add_const_link(OBJECT(&s->dma), "dma-mr",
OBJECT(&s->gpu_bus_mr), &error_abort);
/* GPIO */
- object_initialize(&s->gpio, sizeof(s->gpio), TYPE_BCM2835_GPIO);
- object_property_add_child(obj, "gpio", OBJECT(&s->gpio), NULL);
- qdev_set_parent_bus(DEVICE(&s->gpio), sysbus_get_default());
+ sysbus_init_child(obj, "gpio", &s->gpio, sizeof(s->gpio),
+ TYPE_BCM2835_GPIO);
object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhci",
OBJECT(&s->sdhci.sdbus), &error_abort);
--
2.16.1
prev parent reply other threads:[~2018-02-16 13:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-16 13:45 [Qemu-devel] [PATCH 0/2] Reduce QOM boilerplate with sysbus_init_child() helper Peter Maydell
2018-02-16 13:45 ` [Qemu-devel] [PATCH 1/2] hw/sysbus.h: New sysbus_init_child() helper function Peter Maydell
2018-02-16 16:28 ` Igor Mammedov
2018-02-16 17:40 ` Philippe Mathieu-Daudé
2018-02-20 12:13 ` Paolo Bonzini
2018-02-20 13:23 ` Igor Mammedov
2018-03-24 15:35 ` Philippe Mathieu-Daudé
2018-03-26 12:41 ` Igor Mammedov
2018-02-16 13:45 ` Peter Maydell [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180216134516.6269-3-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=patches@linaro.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).