aboutsummaryrefslogtreecommitdiff
path: root/hw/audio/gus.c
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2012-11-25 02:37:14 +0100
committerAndreas Färber <afaerber@suse.de>2013-06-07 12:14:45 +0200
commitdb895a1e6a97e919f9b86d60c969377357b05066 (patch)
tree72f6786abe90f7fa77d2f10416df73cb9d62e35a /hw/audio/gus.c
parenta3dcca567a1d4a5c79fb9c8fe2d9a21a4a7cebd5 (diff)
downloadqemu-db895a1e6a97e919f9b86d60c969377357b05066.zip
qemu-db895a1e6a97e919f9b86d60c969377357b05066.tar.gz
qemu-db895a1e6a97e919f9b86d60c969377357b05066.tar.bz2
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/gus.c')
-rw-r--r--hw/audio/gus.c18
1 files changed, 9 insertions, 9 deletions
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;