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/audio/pcspk.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/audio/pcspk.c')
-rw-r--r-- | hw/audio/pcspk.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c index 3a7285f14f..5dde0e75da 100644 --- a/hw/audio/pcspk.c +++ b/hw/audio/pcspk.c @@ -163,16 +163,21 @@ static const MemoryRegionOps pcspk_io_ops = { }, }; -static int pcspk_initfn(ISADevice *dev) +static void pcspk_initfn(Object *obj) { - PCSpkState *s = PC_SPEAKER(dev); + PCSpkState *s = PC_SPEAKER(obj); memory_region_init_io(&s->ioport, &pcspk_io_ops, s, "elcr", 1); - isa_register_ioport(dev, &s->ioport, s->iobase); +} - pcspk_state = s; +static void pcspk_realizefn(DeviceState *dev, Error **errp) +{ + ISADevice *isadev = ISA_DEVICE(dev); + PCSpkState *s = PC_SPEAKER(dev); - return 0; + isa_register_ioport(isadev, &s->ioport, s->iobase); + + pcspk_state = s; } static Property pcspk_properties[] = { @@ -184,9 +189,8 @@ static Property pcspk_properties[] = { static void pcspk_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - ISADeviceClass *ic = ISA_DEVICE_CLASS(klass); - ic->init = pcspk_initfn; + dc->realize = pcspk_realizefn; dc->no_user = 1; dc->props = pcspk_properties; } @@ -195,6 +199,7 @@ static const TypeInfo pcspk_info = { .name = TYPE_PC_SPEAKER, .parent = TYPE_ISA_DEVICE, .instance_size = sizeof(PCSpkState), + .instance_init = pcspk_initfn, .class_init = pcspk_class_initfn, }; |