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/gus.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'hw/audio/gus.c') diff --git a/hw/audio/gus.c b/hw/audio/gus.c index e0aea26..f45ed0b 100644 --- a/hw/audio/gus.c +++ b/hw/audio/gus.c @@ -251,8 +251,9 @@ static const MemoryRegionPortio gus_portio_list2[] = { PORTIO_END_OF_LIST (), }; -static int gus_initfn (ISADevice *dev) +static void gus_realizefn (DeviceState *dev, Error **errp) { + ISADevice *d = ISA_DEVICE(dev); GUSState *s = GUS (dev); struct audsettings as; @@ -274,26 +275,25 @@ static int gus_initfn (ISADevice *dev) if (!s->voice) { AUD_remove_card (&s->card); - return -1; + error_setg(errp, "No voice"); + return; } s->shift = 2; s->samples = AUD_get_buffer_size_out (s->voice) >> s->shift; s->mixbuf = g_malloc0 (s->samples << s->shift); - isa_register_portio_list (dev, s->port, gus_portio_list1, s, "gus"); - isa_register_portio_list (dev, (s->port + 0x100) & 0xf00, + isa_register_portio_list (d, s->port, gus_portio_list1, s, "gus"); + isa_register_portio_list (d, (s->port + 0x100) & 0xf00, gus_portio_list2, s, "gus"); DMA_register_channel (s->emu.gusdma, GUS_read_DMA, s); s->emu.himemaddr = s->himem; s->emu.gusdatapos = s->emu.himemaddr + 1024 * 1024 + 32; s->emu.opaque = s; - isa_init_irq (dev, &s->pic, s->emu.gusirq); + isa_init_irq (d, &s->pic, s->emu.gusirq); AUD_set_active_out (s->voice, 1); - - return 0; } static int GUS_init (ISABus *bus) @@ -313,8 +313,8 @@ static Property gus_properties[] = { static void gus_class_initfn (ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS (klass); - ISADeviceClass *ic = ISA_DEVICE_CLASS (klass); - ic->init = gus_initfn; + + dc->realize = gus_realizefn; dc->desc = "Gravis Ultrasound GF1"; dc->vmsd = &vmstate_gus; dc->props = gus_properties; -- cgit v1.1