diff mbox

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

Message ID 1456110933-5457-10-git-send-email-zxq_yx_007@163.com
State New
Headers show

Commit Message

zhao xiao qiang Feb. 22, 2016, 3:15 a.m. UTC
Move majority of old SysBus init's work the into instance_init.

Note:
musb_init must be called in SysBus's init, otherwise it will
break "make check" with error message as follows:

qom/object.c:1576:object_get_canonical_path_component: assertion failed: (obj->parent != NULL)

Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
---
 hw/timer/tusb6010.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

Comments

Peter Maydell Feb. 22, 2016, 9:18 a.m. UTC | #1
On 22 February 2016 at 03:15, xiaoqiang zhao <zxq_yx_007@163.com> wrote:
> Move majority of old SysBus init's work the into instance_init.
>
> Note:
> musb_init must be called in SysBus's init, otherwise it will
> break "make check" with error message as follows:
>
> qom/object.c:1576:object_get_canonical_path_component: assertion failed: (obj->parent != NULL)
>
> Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
> ---
>  hw/timer/tusb6010.c | 23 ++++++++++++++++-------
>  1 file changed, 16 insertions(+), 7 deletions(-)

Devices should either be instance_init + realize, or
sysbus-init. This patch would make this device be a mix
of both. You should just drop this patch until musb has
been properly QOMified.

thanks
-- PMM
zhao xiao qiang Feb. 22, 2016, 9:20 a.m. UTC | #2
在 2016年02月22日 17:18, Peter Maydell 写道:
> On 22 February 2016 at 03:15, xiaoqiang zhao <zxq_yx_007@163.com> wrote:
>> Move majority of old SysBus init's work the into instance_init.
>>
>> Note:
>> musb_init must be called in SysBus's init, otherwise it will
>> break "make check" with error message as follows:
>>
>> qom/object.c:1576:object_get_canonical_path_component: assertion failed: (obj->parent != NULL)
>>
>> Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
>> ---
>>   hw/timer/tusb6010.c | 23 ++++++++++++++++-------
>>   1 file changed, 16 insertions(+), 7 deletions(-)
> Devices should either be instance_init + realize, or
> sysbus-init. This patch would make this device be a mix
> of both. You should just drop this patch until musb has
> been properly QOMified.
>
> thanks
> -- PMM
Ok.
diff mbox

Patch

diff --git a/hw/timer/tusb6010.c b/hw/timer/tusb6010.c
index 9f6af90..2d6bdd3 100644
--- a/hw/timer/tusb6010.c
+++ b/hw/timer/tusb6010.c
@@ -776,21 +776,29 @@  static void tusb6010_reset(DeviceState *dev)
     musb_reset(s->musb);
 }
 
-static int tusb6010_init(SysBusDevice *sbd)
+static void tusb6010_init(Object *obj)
 {
-    DeviceState *dev = DEVICE(sbd);
-    TUSBState *s = TUSB(dev);
+    DeviceState *dev = DEVICE(obj);
+    TUSBState *s = TUSB(obj);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
 
     s->otg_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, tusb_otg_tick, s);
     s->pwr_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, tusb_power_tick, s);
-    memory_region_init_io(&s->iomem[1], OBJECT(s), &tusb_async_ops, s,
+    memory_region_init_io(&s->iomem[1], obj, &tusb_async_ops, s,
                           "tusb-async", UINT32_MAX);
     sysbus_init_mmio(sbd, &s->iomem[0]);
     sysbus_init_mmio(sbd, &s->iomem[1]);
     sysbus_init_irq(sbd, &s->irq);
     qdev_init_gpio_in(dev, tusb6010_irq, musb_irq_max + 1);
-    s->musb = musb_init(dev, 1);
-    return 0;
+}
+
+static int tusb6010_bus_init(SysBusDevice *sbd)
+{
+   TUSBState *s = TUSB(sbd);
+   DeviceState *dev = DEVICE(sbd);
+
+   s->musb = musb_init(dev, 1);
+   return 0;
 }
 
 static void tusb6010_class_init(ObjectClass *klass, void *data)
@@ -798,7 +806,7 @@  static void tusb6010_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-    k->init = tusb6010_init;
+    k->init = tusb6010_bus_init;
     dc->reset = tusb6010_reset;
 }
 
@@ -806,6 +814,7 @@  static const TypeInfo tusb6010_info = {
     .name          = TYPE_TUSB6010,
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(TUSBState),
+    .instance_init = tusb6010_init,
     .class_init    = tusb6010_class_init,
 };