diff mbox

[4/4] hw/audio: QOM'ify milkymist-ac97.c

Message ID 1458120244-30976-5-git-send-email-zxq_yx_007@163.com (mailing list archive)
State New, archived
Headers show

Commit Message

zhao xiao qiang March 16, 2016, 9:24 a.m. UTC
Drop the old SysBus init function and use instance_init

Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
---
 hw/audio/milkymist-ac97.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Paolo Bonzini March 16, 2016, 4:30 p.m. UTC | #1
On 16/03/2016 10:24, xiaoqiang zhao wrote:
>      s->voice_out = AUD_open_out(&s->card, s->voice_out,
>              "mm_ac97.out", s, ac97_out_cb, &as);
>  

AUD_open_out should not be done before realize.

Paolo
zhao xiao qiang March 17, 2016, 1:39 a.m. UTC | #2
? 2016?03?17? 00:30, Paolo Bonzini ??:
>
> On 16/03/2016 10:24, xiaoqiang zhao wrote:
>>       s->voice_out = AUD_open_out(&s->card, s->voice_out,
>>               "mm_ac97.out", s, ac97_out_cb, &as);
>>   
> AUD_open_out should not be done before realize.
>
> Paolo
I wil move it to DeviceClasss::realize in the  next version.
Thank you Paolo !
diff mbox

Patch

diff --git a/hw/audio/milkymist-ac97.c b/hw/audio/milkymist-ac97.c
index 6a3b536..ac78e00 100644
--- a/hw/audio/milkymist-ac97.c
+++ b/hw/audio/milkymist-ac97.c
@@ -284,10 +284,10 @@  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);
@@ -306,11 +306,9 @@  static int milkymist_ac97_init(SysBusDevice *dev)
     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,
+    memory_region_init_io(&s->regs_region, obj, &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 +325,7 @@  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->reset = milkymist_ac97_reset;
     dc->vmsd = &vmstate_milkymist_ac97;
 }
@@ -338,6 +334,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,
 };