diff options
author | xiaoqiang zhao <zxq_yx_007@163.com> | 2016-05-13 11:47:00 +0800 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2016-06-03 11:13:38 +0200 |
commit | 07b9098dfca4209ea1fca3cb26297164fcb4ae3c (patch) | |
tree | ab3f6113ba57e106207861ed52687ec5212b0305 /hw/audio | |
parent | bda8d9b8b13c0c54aeab268b9023ccc246a3ee67 (diff) | |
download | qemu-07b9098dfca4209ea1fca3cb26297164fcb4ae3c.tar.gz qemu-07b9098dfca4209ea1fca3cb26297164fcb4ae3c.tar.bz2 qemu-07b9098dfca4209ea1fca3cb26297164fcb4ae3c.zip |
hw/audio: QOM'ify milkymist-ac97.c
* Drop the old SysBus init function and use instance_init
* Move AUD_open_in / AUD_open_out function into realize stage
Acked-by: Michael Walle <michael@walle.cc>
Tested-by: Michael Walle <michael@walle.cc>
Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
Message-id: 1463111220-30335-5-git-send-email-zxq_yx_007@163.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/audio')
-rw-r--r-- | hw/audio/milkymist-ac97.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/hw/audio/milkymist-ac97.c b/hw/audio/milkymist-ac97.c index 6a3b53674e..5075c2b148 100644 --- a/hw/audio/milkymist-ac97.c +++ b/hw/audio/milkymist-ac97.c @@ -284,16 +284,26 @@ static int ac97_post_load(void *opaque, int version_id) return 0; } -static int milkymist_ac97_init(SysBusDevice *dev) +static void milkymist_ac97_init(Object *obj) { - MilkymistAC97State *s = MILKYMIST_AC97(dev); + MilkymistAC97State *s = MILKYMIST_AC97(obj); + SysBusDevice *dev = SYS_BUS_DEVICE(obj); - struct audsettings as; sysbus_init_irq(dev, &s->crrequest_irq); sysbus_init_irq(dev, &s->crreply_irq); sysbus_init_irq(dev, &s->dmar_irq); sysbus_init_irq(dev, &s->dmaw_irq); + memory_region_init_io(&s->regs_region, obj, &ac97_mmio_ops, s, + "milkymist-ac97", R_MAX * 4); + sysbus_init_mmio(dev, &s->regs_region); +} + +static void milkymist_ac97_realize(DeviceState *dev, Error **errp) +{ + MilkymistAC97State *s = MILKYMIST_AC97(dev); + struct audsettings as; + AUD_register_card("Milkymist AC'97", &s->card); as.freq = 48000; @@ -305,12 +315,6 @@ static int milkymist_ac97_init(SysBusDevice *dev) "mm_ac97.in", s, ac97_in_cb, &as); s->voice_out = AUD_open_out(&s->card, s->voice_out, "mm_ac97.out", s, ac97_out_cb, &as); - - memory_region_init_io(&s->regs_region, OBJECT(s), &ac97_mmio_ops, s, - "milkymist-ac97", R_MAX * 4); - sysbus_init_mmio(dev, &s->regs_region); - - return 0; } static const VMStateDescription vmstate_milkymist_ac97 = { @@ -327,9 +331,8 @@ static const VMStateDescription vmstate_milkymist_ac97 = { static void milkymist_ac97_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = milkymist_ac97_init; + dc->realize = milkymist_ac97_realize; dc->reset = milkymist_ac97_reset; dc->vmsd = &vmstate_milkymist_ac97; } @@ -338,6 +341,7 @@ static const TypeInfo milkymist_ac97_info = { .name = TYPE_MILKYMIST_AC97, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(MilkymistAC97State), + .instance_init = milkymist_ac97_init, .class_init = milkymist_ac97_class_init, }; |