diff options
author | Andreas Färber <afaerber@suse.de> | 2012-11-25 02:37:14 +0100 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2013-06-07 12:14:45 +0200 |
commit | db895a1e6a97e919f9b86d60c969377357b05066 (patch) | |
tree | 72f6786abe90f7fa77d2f10416df73cb9d62e35a /hw/misc | |
parent | a3dcca567a1d4a5c79fb9c8fe2d9a21a4a7cebd5 (diff) | |
download | qemu-db895a1e6a97e919f9b86d60c969377357b05066.zip |
isa: Use realizefn for ISADevice
Drop ISADeviceClass::init and the resulting no-op initfn and let
children implement their own realizefn. Adapt error handling.
Split off an instance_init where sensible.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/misc')
-rw-r--r-- | hw/misc/applesmc.c | 10 | ||||
-rw-r--r-- | hw/misc/debugexit.c | 10 | ||||
-rw-r--r-- | hw/misc/pc-testdev.c | 11 | ||||
-rw-r--r-- | hw/misc/pvpanic.c | 19 | ||||
-rw-r--r-- | hw/misc/sga.c | 7 | ||||
-rw-r--r-- | hw/misc/vmport.c | 10 |
6 files changed, 34 insertions, 33 deletions
diff --git a/hw/misc/applesmc.c b/hw/misc/applesmc.c index 78904a816b..46f4fbd005 100644 --- a/hw/misc/applesmc.c +++ b/hw/misc/applesmc.c @@ -201,7 +201,7 @@ static void qdev_applesmc_isa_reset(DeviceState *dev) applesmc_add_key(s, "MSSD", 1, "\0x3"); } -static int applesmc_isa_init(ISADevice *dev) +static void applesmc_isa_realize(DeviceState *dev, Error **errp) { AppleSMCState *s = APPLE_SMC(dev); @@ -220,9 +220,7 @@ static int applesmc_isa_init(ISADevice *dev) } QLIST_INIT(&s->data_def); - qdev_applesmc_isa_reset(&dev->qdev); - - return 0; + qdev_applesmc_isa_reset(dev); } static Property applesmc_isa_properties[] = { @@ -235,8 +233,8 @@ static Property applesmc_isa_properties[] = { static void qdev_applesmc_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - ISADeviceClass *ic = ISA_DEVICE_CLASS(klass); - ic->init = applesmc_isa_init; + + dc->realize = applesmc_isa_realize; dc->reset = qdev_applesmc_isa_reset; dc->props = applesmc_isa_properties; } diff --git a/hw/misc/debugexit.c b/hw/misc/debugexit.c index 59bed5bff5..ee254e46d2 100644 --- a/hw/misc/debugexit.c +++ b/hw/misc/debugexit.c @@ -35,15 +35,15 @@ static const MemoryRegionOps debug_exit_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; -static int debug_exit_initfn(ISADevice *dev) +static void debug_exit_realizefn(DeviceState *d, Error **errp) { - ISADebugExitState *isa = ISA_DEBUG_EXIT_DEVICE(dev); + ISADevice *dev = ISA_DEVICE(d); + ISADebugExitState *isa = ISA_DEBUG_EXIT_DEVICE(d); memory_region_init_io(&isa->io, &debug_exit_ops, isa, TYPE_ISA_DEBUG_EXIT_DEVICE, isa->iosize); memory_region_add_subregion(isa_address_space_io(dev), isa->iobase, &isa->io); - return 0; } static Property debug_exit_properties[] = { @@ -55,8 +55,8 @@ static Property debug_exit_properties[] = { static void debug_exit_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - ISADeviceClass *ic = ISA_DEVICE_CLASS(klass); - ic->init = debug_exit_initfn; + + dc->realize = debug_exit_realizefn; dc->props = debug_exit_properties; } diff --git a/hw/misc/pc-testdev.c b/hw/misc/pc-testdev.c index 32df175c10..e6707d69d4 100644 --- a/hw/misc/pc-testdev.c +++ b/hw/misc/pc-testdev.c @@ -142,9 +142,10 @@ static const MemoryRegionOps test_iomem_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; -static int init_test_device(ISADevice *isa) +static void testdev_realizefn(DeviceState *d, Error **errp) { - PCTestdev *dev = TESTDEV(isa); + ISADevice *isa = ISA_DEVICE(d); + PCTestdev *dev = TESTDEV(d); MemoryRegion *mem = isa_address_space(isa); MemoryRegion *io = isa_address_space_io(isa); @@ -161,15 +162,13 @@ static int init_test_device(ISADevice *isa) memory_region_add_subregion(io, 0xe4, &dev->flush); memory_region_add_subregion(io, 0x2000, &dev->irq); memory_region_add_subregion(mem, 0xff000000, &dev->iomem); - - return 0; } static void testdev_class_init(ObjectClass *klass, void *data) { - ISADeviceClass *k = ISA_DEVICE_CLASS(klass); + DeviceClass *dc = DEVICE_CLASS(klass); - k->init = init_test_device; + dc->realize = testdev_realizefn; } static const TypeInfo testdev_info = { diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index 910e44f9d2..060099b553 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -86,14 +86,21 @@ static const MemoryRegionOps pvpanic_ops = { }, }; -static int pvpanic_isa_initfn(ISADevice *dev) +static void pvpanic_isa_initfn(Object *obj) { + PVPanicState *s = ISA_PVPANIC_DEVICE(obj); + + memory_region_init_io(&s->io, &pvpanic_ops, s, "pvpanic", 1); +} + +static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp) +{ + ISADevice *d = ISA_DEVICE(dev); PVPanicState *s = ISA_PVPANIC_DEVICE(dev); static bool port_configured; FWCfgState *fw_cfg; - memory_region_init_io(&s->io, &pvpanic_ops, s, "pvpanic", 1); - isa_register_ioport(dev, &s->io, s->ioport); + isa_register_ioport(d, &s->io, s->ioport); if (!port_configured) { fw_cfg = fw_cfg_find(); @@ -104,8 +111,6 @@ static int pvpanic_isa_initfn(ISADevice *dev) port_configured = true; } } - - return 0; } int pvpanic_init(ISABus *bus) @@ -122,9 +127,8 @@ static Property pvpanic_isa_properties[] = { static void pvpanic_isa_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - ISADeviceClass *ic = ISA_DEVICE_CLASS(klass); - ic->init = pvpanic_isa_initfn; + dc->realize = pvpanic_isa_realizefn; dc->no_user = 1; dc->props = pvpanic_isa_properties; } @@ -133,6 +137,7 @@ static TypeInfo pvpanic_isa_info = { .name = TYPE_ISA_PVPANIC_DEVICE, .parent = TYPE_ISA_DEVICE, .instance_size = sizeof(PVPanicState), + .instance_init = pvpanic_isa_initfn, .class_init = pvpanic_isa_class_init, }; diff --git a/hw/misc/sga.c b/hw/misc/sga.c index c842190999..08803e7ddc 100644 --- a/hw/misc/sga.c +++ b/hw/misc/sga.c @@ -38,17 +38,16 @@ typedef struct ISASGAState { ISADevice parent_obj; } ISASGAState; -static int sga_initfn(ISADevice *dev) +static void sga_realizefn(DeviceState *dev, Error **errp) { rom_add_vga(SGABIOS_FILENAME); - return 0; } static void sga_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - ISADeviceClass *ic = ISA_DEVICE_CLASS(klass); - ic->init = sga_initfn; + + dc->realize = sga_realizefn; dc->desc = "Serial Graphics Adapter"; } diff --git a/hw/misc/vmport.c b/hw/misc/vmport.c index c14612905b..57b71f5248 100644 --- a/hw/misc/vmport.c +++ b/hw/misc/vmport.c @@ -137,25 +137,25 @@ static const MemoryRegionOps vmport_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; -static int vmport_initfn(ISADevice *dev) +static void vmport_realizefn(DeviceState *dev, Error **errp) { + ISADevice *isadev = ISA_DEVICE(dev); VMPortState *s = VMPORT(dev); memory_region_init_io(&s->io, &vmport_ops, s, "vmport", 1); - isa_register_ioport(dev, &s->io, 0x5658); + isa_register_ioport(isadev, &s->io, 0x5658); port_state = s; /* Register some generic port commands */ vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, NULL); vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL); - return 0; } static void vmport_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - ISADeviceClass *ic = ISA_DEVICE_CLASS(klass); - ic->init = vmport_initfn; + + dc->realize = vmport_realizefn; dc->no_user = 1; } |