From: Michael Walle <michael@walle.cc>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
xiaoqiang zhao <zxq_yx_007@163.com>,
Michael Walle <michael@walle.cc>
Subject: [Qemu-devel] [PULL 2/6] hw/timer: QOM'ify milkymist_sysctl
Date: Mon, 20 Jun 2016 18:39:05 +0200 [thread overview]
Message-ID: <1466440749-17195-3-git-send-email-michael@walle.cc> (raw)
In-Reply-To: <1466440749-17195-1-git-send-email-michael@walle.cc>
From: xiaoqiang zhao <zxq_yx_007@163.com>
* split the old SysBus init function into an instance_init
and a Device realize function
* use DeviceClass::realize instead of SysBusDeviceClass::init
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
Acked-by: Michael Walle <michael@walle.cc>
Tested-by: Michael Walle <michael@walle.cc>
Signed-off-by: Michael Walle <michael@walle.cc>
---
hw/timer/milkymist-sysctl.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/hw/timer/milkymist-sysctl.c b/hw/timer/milkymist-sysctl.c
index 5f29480..30a4bc4 100644
--- a/hw/timer/milkymist-sysctl.c
+++ b/hw/timer/milkymist-sysctl.c
@@ -270,9 +270,10 @@ static void milkymist_sysctl_reset(DeviceState *d)
s->regs[R_GPIO_IN] = s->strappings;
}
-static int milkymist_sysctl_init(SysBusDevice *dev)
+static void milkymist_sysctl_init(Object *obj)
{
- MilkymistSysctlState *s = MILKYMIST_SYSCTL(dev);
+ MilkymistSysctlState *s = MILKYMIST_SYSCTL(obj);
+ SysBusDevice *dev = SYS_BUS_DEVICE(obj);
sysbus_init_irq(dev, &s->gpio_irq);
sysbus_init_irq(dev, &s->timer0_irq);
@@ -282,14 +283,18 @@ static int milkymist_sysctl_init(SysBusDevice *dev)
s->bh1 = qemu_bh_new(timer1_hit, s);
s->ptimer0 = ptimer_init(s->bh0);
s->ptimer1 = ptimer_init(s->bh1);
- ptimer_set_freq(s->ptimer0, s->freq_hz);
- ptimer_set_freq(s->ptimer1, s->freq_hz);
- memory_region_init_io(&s->regs_region, OBJECT(s), &sysctl_mmio_ops, s,
+ memory_region_init_io(&s->regs_region, obj, &sysctl_mmio_ops, s,
"milkymist-sysctl", R_MAX * 4);
sysbus_init_mmio(dev, &s->regs_region);
+}
- return 0;
+static void milkymist_sysctl_realize(DeviceState *dev, Error **errp)
+{
+ MilkymistSysctlState *s = MILKYMIST_SYSCTL(dev);
+
+ ptimer_set_freq(s->ptimer0, s->freq_hz);
+ ptimer_set_freq(s->ptimer1, s->freq_hz);
}
static const VMStateDescription vmstate_milkymist_sysctl = {
@@ -319,9 +324,8 @@ static Property milkymist_sysctl_properties[] = {
static void milkymist_sysctl_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = milkymist_sysctl_init;
+ dc->realize = milkymist_sysctl_realize;
dc->reset = milkymist_sysctl_reset;
dc->vmsd = &vmstate_milkymist_sysctl;
dc->props = milkymist_sysctl_properties;
@@ -331,6 +335,7 @@ static const TypeInfo milkymist_sysctl_info = {
.name = TYPE_MILKYMIST_SYSCTL,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(MilkymistSysctlState),
+ .instance_init = milkymist_sysctl_init,
.class_init = milkymist_sysctl_class_init,
};
--
2.1.4
next prev parent reply other threads:[~2016-06-20 16:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-20 16:39 [Qemu-devel] [PULL 0/6] lm32/milkymist: some qomifying and a small doc fix Michael Walle
2016-06-20 16:39 ` [Qemu-devel] [PULL 1/6] hw/timer: QOM'ify lm32_timer Michael Walle
2016-06-20 16:39 ` Michael Walle [this message]
2016-06-20 16:39 ` [Qemu-devel] [PULL 3/6] hw/display: QOM'ify milkymist-tmu2.c Michael Walle
2016-06-20 16:39 ` [Qemu-devel] [PULL 4/6] hw/display: QOM'ify milkymist-vgafb.c Michael Walle
2016-06-20 16:39 ` [Qemu-devel] [PULL 5/6] hw/intc: QOM'ify lm32_pic.c Michael Walle
2016-06-20 16:39 ` [Qemu-devel] [PULL 6/6] milkymist: update specification URLs Michael Walle
2016-06-20 17:55 ` [Qemu-devel] [PULL 0/6] lm32/milkymist: some qomifying and a small doc fix Peter Maydell
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=1466440749-17195-3-git-send-email-michael@walle.cc \
--to=michael@walle.cc \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=zxq_yx_007@163.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).