From patchwork Thu Mar 17 09:06:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhao xiao qiang X-Patchwork-Id: 8608431 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DA6C8C0553 for ; Thu, 17 Mar 2016 09:08:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3093E20279 for ; Thu, 17 Mar 2016 09:08:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7E6762026F for ; Thu, 17 Mar 2016 09:08:12 +0000 (UTC) Received: from localhost ([::1]:33542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agTud-0003aJ-Ax for patchwork-qemu-devel@patchwork.kernel.org; Thu, 17 Mar 2016 05:08:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agTuR-0003ZL-3n for qemu-devel@nongnu.org; Thu, 17 Mar 2016 05:08:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agTuL-0004aR-DW for qemu-devel@nongnu.org; Thu, 17 Mar 2016 05:07:59 -0400 Received: from m12-17.163.com ([220.181.12.17]:49330) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agTuL-0004Zv-29 for qemu-devel@nongnu.org; Thu, 17 Mar 2016 05:07:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=pwcjYPf7ZabzrkXIZG qMqMu1HTmoirYWe1860f88Fx0=; b=MyynPk0eMp0/6gN5I+aR6xsbwJpmSzeJO0 TAavsRXQlqH6pIcbm22/HMXKD5kMxymgwgoqedOrWGzetxwIZjfUO2J4blNjSH9O 5IAaFTAWgs0i3X7WMcPZOaUoAhR8lrGhilyw9fQ1xbYVyA0We90C48QF77mODGVp KBfwGUqQo= Received: from localhost.localdomain (unknown [118.187.28.42]) by smtp13 (Coremail) with SMTP id EcCowADn0SzUc+pWwyspAw--.30326S6; Thu, 17 Mar 2016 17:07:48 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Thu, 17 Mar 2016 17:06:16 +0800 Message-Id: <1458205576-21646-5-git-send-email-zxq_yx_007@163.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1458205576-21646-1-git-send-email-zxq_yx_007@163.com> References: <1458205576-21646-1-git-send-email-zxq_yx_007@163.com> X-CM-TRANSID: EcCowADn0SzUc+pWwyspAw--.30326S6 X-Coremail-Antispam: 1Uf129KBjvJXoWxXFy3Gr13XF18ur13ZF1fJFb_yoW5GryrpF Z3ZFn8CrW8Ar4DXrZ3Jw1qvF15Aw1kKas2kr48twn3tw12kry3Ja1kuw1IyFWjgFZYv3Wf t3yvyrW7tw4Ygw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jJBMtUUUUU= X-Originating-IP: [118.187.28.42] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/1tbiFgQvxlWBProeawAAse X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.17 Cc: pbonzini@redhat.com, michael@walle.cc, kraxel@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [RESEND PATCH v2 4/4] hw/audio: QOM'ify milkymist-ac97.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP * Drop the old SysBus init function and use instance_init * Move AUD_open_in / AUD_open_out function into realize stage Signed-off-by: xiaoqiang zhao Acked-by: Michael Walle Tested-by: Michael Walle --- hw/audio/milkymist-ac97.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/hw/audio/milkymist-ac97.c b/hw/audio/milkymist-ac97.c index 6a3b536..5075c2b 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, };