diff mbox

[v4,3/9] hw/timer: QOM'ify lm32_timer

Message ID 1456110933-5457-4-git-send-email-zxq_yx_007@163.com (mailing list archive)
State New, archived
Headers show

Commit Message

zhao xiao qiang Feb. 22, 2016, 3:15 a.m. UTC
* 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>
---
 hw/timer/lm32_timer.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

Comments

Michael Walle March 17, 2016, 2:59 p.m. UTC | #1
[I had some problems with my mailserver and the v5 version didn't make 
it through. I know there is a v5 version of this patch series and I've 
tested with the v5 version]


Am 2016-02-22 04:15, schrieb xiaoqiang zhao:
> * 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>

Signed-off-by: Michael Walle <michael@walle.cc>

-michael
Peter Maydell March 17, 2016, 3 p.m. UTC | #2
On 17 March 2016 at 14:59,  <michael@walle.cc> wrote:
> [I had some problems with my mailserver and the v5 version didn't make it
> through. I know there is a v5 version of this patch series and I've tested
> with the v5 version]
>
>
> Am 2016-02-22 04:15, schrieb xiaoqiang zhao:
>>
>> * 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>
>
>
> Signed-off-by: Michael Walle <michael@walle.cc>

Signed-off-by: doesn't make much sense in this situation -- did
you want Acked-by, Reviewed-by, Tested-by, or some combination
of those ?

thanks
-- PMM
Michael Walle March 17, 2016, 3:02 p.m. UTC | #3
Am 2016-03-17 16:00, schrieb Peter Maydell:
> On 17 March 2016 at 14:59,  <michael@walle.cc> wrote:
>> [I had some problems with my mailserver and the v5 version didn't make 
>> it
>> through. I know there is a v5 version of this patch series and I've 
>> tested
>> with the v5 version]
>> 
>> 
>> Am 2016-02-22 04:15, schrieb xiaoqiang zhao:
>>> 
>>> * 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>
>> 
>> 
>> Signed-off-by: Michael Walle <michael@walle.cc>
> 
> Signed-off-by: doesn't make much sense in this situation -- did
> you want Acked-by, Reviewed-by, Tested-by, or some combination
> of those ?

ahh sorry, need more sleep :(

Acked-by: Michael Walle <michael@walle.cc>
Tested-by: Michael Walle <michael@walle.cc>

-michael
diff mbox

Patch

diff --git a/hw/timer/lm32_timer.c b/hw/timer/lm32_timer.c
index 3198355..e45a65b 100644
--- a/hw/timer/lm32_timer.c
+++ b/hw/timer/lm32_timer.c
@@ -176,21 +176,26 @@  static void timer_reset(DeviceState *d)
     ptimer_stop(s->ptimer);
 }
 
-static int lm32_timer_init(SysBusDevice *dev)
+static void lm32_timer_init(Object *obj)
 {
-    LM32TimerState *s = LM32_TIMER(dev);
+    LM32TimerState *s = LM32_TIMER(obj);
+    SysBusDevice *dev = SYS_BUS_DEVICE(obj);
 
     sysbus_init_irq(dev, &s->irq);
 
     s->bh = qemu_bh_new(timer_hit, s);
     s->ptimer = ptimer_init(s->bh);
-    ptimer_set_freq(s->ptimer, s->freq_hz);
 
-    memory_region_init_io(&s->iomem, OBJECT(s), &timer_ops, s,
+    memory_region_init_io(&s->iomem, obj, &timer_ops, s,
                           "timer", R_MAX * 4);
     sysbus_init_mmio(dev, &s->iomem);
+}
 
-    return 0;
+static void lm32_timer_realize(DeviceState *dev, Error **errp)
+{
+    LM32TimerState *s = LM32_TIMER(dev);
+
+    ptimer_set_freq(s->ptimer, s->freq_hz);
 }
 
 static const VMStateDescription vmstate_lm32_timer = {
@@ -213,9 +218,8 @@  static Property lm32_timer_properties[] = {
 static void lm32_timer_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-    k->init = lm32_timer_init;
+    dc->realize = lm32_timer_realize;
     dc->reset = timer_reset;
     dc->vmsd = &vmstate_lm32_timer;
     dc->props = lm32_timer_properties;
@@ -225,6 +229,7 @@  static const TypeInfo lm32_timer_info = {
     .name          = TYPE_LM32_TIMER,
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(LM32TimerState),
+    .instance_init = lm32_timer_init,
     .class_init    = lm32_timer_class_init,
 };