summaryrefslogtreecommitdiff
path: root/hw/audio/cs4231a.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/cs4231a.c
parenta3dcca567a1d4a5c79fb9c8fe2d9a21a4a7cebd5 (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/cs4231a.c')
-rw-r--r--hw/audio/cs4231a.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c
index d3ce739745..605dad4988 100644
--- a/hw/audio/cs4231a.c
+++ b/hw/audio/cs4231a.c
@@ -644,19 +644,25 @@ static const MemoryRegionOps cs_ioport_ops = {
}
};
-static int cs4231a_initfn (ISADevice *dev)
+static void cs4231a_initfn (Object *obj)
{
+ CSState *s = CS4231A (obj);
+
+ memory_region_init_io (&s->ioports, &cs_ioport_ops, s, "cs4231a", 4);
+}
+
+static void cs4231a_realizefn (DeviceState *dev, Error **errp)
+{
+ ISADevice *d = ISA_DEVICE (dev);
CSState *s = CS4231A (dev);
- isa_init_irq (dev, &s->pic, s->irq);
+ isa_init_irq (d, &s->pic, s->irq);
- memory_region_init_io (&s->ioports, &cs_ioport_ops, s, "cs4231a", 4);
- isa_register_ioport (dev, &s->ioports, s->port);
+ isa_register_ioport (d, &s->ioports, s->port);
DMA_register_channel (s->dma, cs_dma_read, s);
AUD_register_card ("cs4231a", &s->card);
- return 0;
}
static int cs4231a_init (ISABus *bus)
@@ -675,8 +681,8 @@ static Property cs4231a_properties[] = {
static void cs4231a_class_initfn (ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS (klass);
- ISADeviceClass *ic = ISA_DEVICE_CLASS (klass);
- ic->init = cs4231a_initfn;
+
+ dc->realize = cs4231a_realizefn;
dc->reset = cs4231a_reset;
dc->desc = "Crystal Semiconductor CS4231A";
dc->vmsd = &vmstate_cs4231a;
@@ -687,6 +693,7 @@ static const TypeInfo cs4231a_info = {
.name = TYPE_CS4231A,
.parent = TYPE_ISA_DEVICE,
.instance_size = sizeof (CSState),
+ .instance_init = cs4231a_initfn,
.class_init = cs4231a_class_initfn,
};