diff options
author | xiaoqiang zhao <zxq_yx_007@163.com> | 2017-05-25 21:34:44 +0800 |
---|---|---|
committer | Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | 2017-06-02 05:54:43 +0100 |
commit | b229a5765bc0973102ca9908ecc95bff4918f0c1 (patch) | |
tree | b8ecc94c08773502da619eff05890b4c3f43528f /hw/misc/eccmemctl.c | |
parent | 43771d5d92312504305c19abe29ec5bfabd55f01 (diff) | |
download | qemu-b229a5765bc0973102ca9908ecc95bff4918f0c1.zip qemu-b229a5765bc0973102ca9908ecc95bff4918f0c1.tar.gz qemu-b229a5765bc0973102ca9908ecc95bff4918f0c1.tar.bz2 |
hw/misc: QOM'ify eccmemctl.c
* Split the old SysBus init into an instance_init and a
DeviceClass::realize function
* Drop the old SysBus init function and use instance_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>
Diffstat (limited to 'hw/misc/eccmemctl.c')
-rw-r--r-- | hw/misc/eccmemctl.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/hw/misc/eccmemctl.c b/hw/misc/eccmemctl.c index a0071f3..bb7cc52 100644 --- a/hw/misc/eccmemctl.c +++ b/hw/misc/eccmemctl.c @@ -295,22 +295,29 @@ static void ecc_reset(DeviceState *d) s->regs[ECC_ECR1] = 0; } -static int ecc_init1(SysBusDevice *dev) +static void ecc_init(Object *obj) { - ECCState *s = ECC_MEMCTL(dev); + ECCState *s = ECC_MEMCTL(obj); + SysBusDevice *dev = SYS_BUS_DEVICE(obj); sysbus_init_irq(dev, &s->irq); - s->regs[0] = s->version; - memory_region_init_io(&s->iomem, OBJECT(dev), &ecc_mem_ops, s, "ecc", ECC_SIZE); + + memory_region_init_io(&s->iomem, obj, &ecc_mem_ops, s, "ecc", ECC_SIZE); sysbus_init_mmio(dev, &s->iomem); +} + +static void ecc_realize(DeviceState *dev, Error **errp) +{ + ECCState *s = ECC_MEMCTL(dev); + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); + + s->regs[0] = s->version; if (s->version == ECC_MCC) { // SS-600MP only memory_region_init_io(&s->iomem_diag, OBJECT(dev), &ecc_diag_mem_ops, s, "ecc.diag", ECC_DIAG_SIZE); - sysbus_init_mmio(dev, &s->iomem_diag); + sysbus_init_mmio(sbd, &s->iomem_diag); } - - return 0; } static Property ecc_properties[] = { @@ -321,9 +328,8 @@ static Property ecc_properties[] = { static void ecc_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = ecc_init1; + dc->realize = ecc_realize; dc->reset = ecc_reset; dc->vmsd = &vmstate_ecc; dc->props = ecc_properties; @@ -333,6 +339,7 @@ static const TypeInfo ecc_info = { .name = TYPE_ECC_MEMCTL, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(ECCState), + .instance_init = ecc_init, .class_init = ecc_class_init, }; |