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/sb16.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/sb16.c')
-rw-r--r-- | hw/audio/sb16.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c index 6ddc0ac258..e697bc1498 100644 --- a/hw/audio/sb16.c +++ b/hw/audio/sb16.c @@ -1356,12 +1356,19 @@ static const MemoryRegionPortio sb16_ioport_list[] = { }; -static int sb16_initfn (ISADevice *dev) +static void sb16_initfn (Object *obj) { - SB16State *s = SB16 (dev); + SB16State *s = SB16 (obj); s->cmd = -1; - isa_init_irq (dev, &s->pic, s->irq); +} + +static void sb16_realizefn (DeviceState *dev, Error **errp) +{ + ISADevice *isadev = ISA_DEVICE (dev); + SB16State *s = SB16 (dev); + + isa_init_irq (isadev, &s->pic, s->irq); s->mixer_regs[0x80] = magic_of_irq (s->irq); s->mixer_regs[0x81] = (1 << s->dma) | (1 << s->hdma); @@ -1376,14 +1383,13 @@ static int sb16_initfn (ISADevice *dev) dolog ("warning: Could not create auxiliary timer\n"); } - isa_register_portio_list (dev, s->port, sb16_ioport_list, s, "sb16"); + isa_register_portio_list (isadev, s->port, sb16_ioport_list, s, "sb16"); DMA_register_channel (s->hdma, SB_read_DMA, s); DMA_register_channel (s->dma, SB_read_DMA, s); s->can_write = 1; AUD_register_card ("sb16", &s->card); - return 0; } static int SB16_init (ISABus *bus) @@ -1404,8 +1410,8 @@ static Property sb16_properties[] = { static void sb16_class_initfn (ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS (klass); - ISADeviceClass *ic = ISA_DEVICE_CLASS (klass); - ic->init = sb16_initfn; + + dc->realize = sb16_realizefn; dc->desc = "Creative Sound Blaster 16"; dc->vmsd = &vmstate_sb16; dc->props = sb16_properties; @@ -1415,6 +1421,7 @@ static const TypeInfo sb16_info = { .name = TYPE_SB16, .parent = TYPE_ISA_DEVICE, .instance_size = sizeof (SB16State), + .instance_init = sb16_initfn, .class_init = sb16_class_initfn, }; |