diff options
Diffstat (limited to 'hw')
-rw-r--r-- | hw/timer/xilinx_timer.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/hw/timer/xilinx_timer.c b/hw/timer/xilinx_timer.c index 3ff1da9caf..cdb3355174 100644 --- a/hw/timer/xilinx_timer.c +++ b/hw/timer/xilinx_timer.c @@ -204,14 +204,11 @@ static void timer_hit(void *opaque) timer_update_irq(t); } -static int xilinx_timer_init(SysBusDevice *dev) +static void xilinx_timer_realize(DeviceState *dev, Error **errp) { struct timerblock *t = XILINX_TIMER(dev); unsigned int i; - /* All timers share a single irq line. */ - sysbus_init_irq(dev, &t->irq); - /* Init all the ptimers. */ t->timers = g_malloc0(sizeof t->timers[0] * num_timers(t)); for (i = 0; i < num_timers(t); i++) { @@ -226,8 +223,15 @@ static int xilinx_timer_init(SysBusDevice *dev) memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t, "xlnx.xps-timer", R_MAX * 4 * num_timers(t)); - sysbus_init_mmio(dev, &t->mmio); - return 0; + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &t->mmio); +} + +static void xilinx_timer_init(Object *obj) +{ + struct timerblock *t = XILINX_TIMER(obj); + + /* All timers share a single irq line. */ + sysbus_init_irq(SYS_BUS_DEVICE(obj), &t->irq); } static Property xilinx_timer_properties[] = { @@ -240,9 +244,8 @@ static Property xilinx_timer_properties[] = { static void xilinx_timer_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = xilinx_timer_init; + dc->realize = xilinx_timer_realize; dc->props = xilinx_timer_properties; } @@ -250,6 +253,7 @@ static const TypeInfo xilinx_timer_info = { .name = TYPE_XILINX_TIMER, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(struct timerblock), + .instance_init = xilinx_timer_init, .class_init = xilinx_timer_class_init, }; |