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/pvpanic.c | |
parent | a3dcca567a1d4a5c79fb9c8fe2d9a21a4a7cebd5 (diff) |
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/pvpanic.c')
-rw-r--r-- | hw/misc/pvpanic.c | 19 |
1 files changed, 12 insertions, 7 deletions
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, }; |