From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH qom-next for-1.6 2/6] pl080: QOM'ify pl080 and pl081
Date: Fri, 26 Jul 2013 17:00:59 +0200 [thread overview]
Message-ID: <1374850864-7331-3-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1374850864-7331-1-git-send-email-afaerber@suse.de>
Let pl081 inherit from pl080 and replace triple SysBus initfn with two
instance_inits.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/dma/pl080.c | 51 ++++++++++++++++++++-------------------------------
1 file changed, 20 insertions(+), 31 deletions(-)
diff --git a/hw/dma/pl080.c b/hw/dma/pl080.c
index 189a922..35b9015 100644
--- a/hw/dma/pl080.c
+++ b/hw/dma/pl080.c
@@ -35,8 +35,12 @@ typedef struct {
uint32_t conf;
} pl080_channel;
+#define TYPE_PL080 "pl080"
+#define PL080(obj) OBJECT_CHECK(PL080State, (obj), TYPE_PL080)
+
typedef struct PL080State {
- SysBusDevice busdev;
+ SysBusDevice parent_obj;
+
MemoryRegion iomem;
uint8_t tc_int;
uint8_t tc_mask;
@@ -355,59 +359,44 @@ static const MemoryRegionOps pl080_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-static int pl08x_init(SysBusDevice *dev, int nchannels)
+static void pl080_init(Object *obj)
{
- PL080State *s = FROM_SYSBUS(PL080State, dev);
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
+ PL080State *s = PL080(obj);
memory_region_init_io(&s->iomem, OBJECT(s), &pl080_ops, s, "pl080", 0x1000);
- sysbus_init_mmio(dev, &s->iomem);
- sysbus_init_irq(dev, &s->irq);
- s->nchannels = nchannels;
- return 0;
+ sysbus_init_mmio(sbd, &s->iomem);
+ sysbus_init_irq(sbd, &s->irq);
+ s->nchannels = 8;
}
-static int pl080_init(SysBusDevice *dev)
+static void pl081_init(Object *obj)
{
- return pl08x_init(dev, 8);
-}
+ PL080State *s = PL080(obj);
-static int pl081_init(SysBusDevice *dev)
-{
- return pl08x_init(dev, 2);
+ s->nchannels = 2;
}
-static void pl080_class_init(ObjectClass *klass, void *data)
+static void pl080_class_init(ObjectClass *oc, void *data)
{
- DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
+ DeviceClass *dc = DEVICE_CLASS(oc);
- k->init = pl080_init;
dc->no_user = 1;
dc->vmsd = &vmstate_pl080;
}
static const TypeInfo pl080_info = {
- .name = "pl080",
+ .name = TYPE_PL080,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(PL080State),
+ .instance_init = pl080_init,
.class_init = pl080_class_init,
};
-static void pl081_class_init(ObjectClass *klass, void *data)
-{
- DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
-
- k->init = pl081_init;
- dc->no_user = 1;
- dc->vmsd = &vmstate_pl080;
-}
-
static const TypeInfo pl081_info = {
.name = "pl081",
- .parent = TYPE_SYS_BUS_DEVICE,
- .instance_size = sizeof(PL080State),
- .class_init = pl081_class_init,
+ .parent = TYPE_PL080,
+ .instance_init = pl081_init,
};
/* The PL080 and PL081 are the same except for the number of channels
--
1.8.1.4
next prev parent reply other threads:[~2013-07-26 15:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-26 15:00 [Qemu-devel] [PATCH qom-next for-1.6 0/6] dma: QOM cast cleanups Andreas Färber
2013-07-26 15:00 ` [Qemu-devel] [PATCH qom-next for-1.6 1/6] pl080: Rename pl080_state to PL080State Andreas Färber
2013-07-26 15:00 ` Andreas Färber [this message]
2013-07-26 15:01 ` [Qemu-devel] [PATCH qom-next for-1.6 3/6] puv3_dma: QOM cast cleanup Andreas Färber
2013-07-26 15:01 ` [Qemu-devel] [PATCH qom-next for-1.6 4/6] pxa2xx_dma: " Andreas Färber
2013-07-26 15:01 ` [Qemu-devel] [PATCH qom-next for-1.6 5/6] sparc32_dma: " Andreas Färber
2013-07-26 15:01 ` [Qemu-devel] [PATCH qom-next for-1.6 6/6] sun4m_iommu: " Andreas Färber
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=1374850864-7331-3-git-send-email-afaerber@suse.de \
--to=afaerber@suse.de \
--cc=qemu-devel@nongnu.org \
/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).