From db895a1e6a97e919f9b86d60c969377357b05066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 25 Nov 2012 02:37:14 +0100 Subject: isa: Use realizefn for ISADevice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- hw/audio/sb16.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'hw/audio/sb16.c') diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c index 6ddc0ac..e697bc1 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, }; -- cgit v1.1