Skip to content

Commit

Permalink
hw/timer: QOM'ify slavio_timer
Browse files Browse the repository at this point in the history
rename slavio_timer_init1 to slavio_timer_init and assign
it to slavio_timer_info.instance_init, then we drop the
SysBusDeviceClass::init

Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
  • Loading branch information
hitmoon authored and mcayland committed Jun 2, 2017
1 parent c04e34a commit 4410b94
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions hw/timer/slavio_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,10 @@ static void slavio_timer_reset(DeviceState *d)
s->cputimer_mode = 0;
}

static int slavio_timer_init1(SysBusDevice *dev)
static void slavio_timer_init(Object *obj)
{
SLAVIO_TIMERState *s = SLAVIO_TIMER(dev);
SLAVIO_TIMERState *s = SLAVIO_TIMER(obj);
SysBusDevice *dev = SYS_BUS_DEVICE(obj);
QEMUBH *bh;
unsigned int i;
TimerContext *tc;
Expand All @@ -394,14 +395,12 @@ static int slavio_timer_init1(SysBusDevice *dev)

size = i == 0 ? SYS_TIMER_SIZE : CPU_TIMER_SIZE;
snprintf(timer_name, sizeof(timer_name), "timer-%i", i);
memory_region_init_io(&tc->iomem, OBJECT(s), &slavio_timer_mem_ops, tc,
memory_region_init_io(&tc->iomem, obj, &slavio_timer_mem_ops, tc,
timer_name, size);
sysbus_init_mmio(dev, &tc->iomem);

sysbus_init_irq(dev, &s->cputimer[i].irq);
}

return 0;
}

static Property slavio_timer_properties[] = {
Expand All @@ -412,9 +411,7 @@ static Property slavio_timer_properties[] = {
static void slavio_timer_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);

k->init = slavio_timer_init1;
dc->reset = slavio_timer_reset;
dc->vmsd = &vmstate_slavio_timer;
dc->props = slavio_timer_properties;
Expand All @@ -424,6 +421,7 @@ static const TypeInfo slavio_timer_info = {
.name = TYPE_SLAVIO_TIMER,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(SLAVIO_TIMERState),
.instance_init = slavio_timer_init,
.class_init = slavio_timer_class_init,
};

Expand Down

0 comments on commit 4410b94

Please sign in to comment.