diff options
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, }; |