From patchwork Sat Dec 31 01:17:20 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: 9492581 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0E69762ABC for ; Sat, 31 Dec 2016 01:26:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCF33223B2 for ; Sat, 31 Dec 2016 01:26:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEAB125F31; Sat, 31 Dec 2016 01:26:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 43ACD223B2 for ; Sat, 31 Dec 2016 01:26:43 +0000 (UTC) Received: from localhost ([::1]:42146 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN8RW-0007hH-3s for patchwork-qemu-devel@patchwork.kernel.org; Fri, 30 Dec 2016 20:26:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN8Is-0000ZV-MK for qemu-devel@nongnu.org; Fri, 30 Dec 2016 20:17:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cN8Ip-0008HK-TE for qemu-devel@nongnu.org; Fri, 30 Dec 2016 20:17:46 -0500 Received: from m12-14.163.com ([220.181.12.14]:42333) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN8Ip-0008GE-A5 for qemu-devel@nongnu.org; Fri, 30 Dec 2016 20:17:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=sAelXdnS2Q2/qIztay 9m9jBzfr9t3qkLZUeaMs7RhR8=; b=fkT6/G+oGIBTqr+d6W4ljCRgPiapC0Yyxu Q5NbII2kve5r3j7t3lWb9sVCxIxZxJGDdibLoMYReJQmU0Ms+rRtkk3rI/skDh4D 2E3XkHMuoRrVi+Cu3tmSA7WT7nAj43ZowShL1vyI9J3MchQGn/RdROJHHQV/j19I JzM7Y5wCs= Received: from localhost.localdomain (unknown [223.104.3.243]) by smtp10 (Coremail) with SMTP id DsCowABXrbYnB2dYGQKVFw--.9854S4; Sat, 31 Dec 2016 09:17:36 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Sat, 31 Dec 2016 09:17:20 +0800 Message-Id: <20161231011720.3965-3-zxq_yx_007@163.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161231011720.3965-1-zxq_yx_007@163.com> References: <20161231011720.3965-1-zxq_yx_007@163.com> X-CM-TRANSID: DsCowABXrbYnB2dYGQKVFw--.9854S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7tw45WrykXw4Utw15Wr13CFg_yoW8Kr18pr Z7uFn8JryUJrs7C3saqr1DXF1DGwn7u3W8tFnrJ3WxKa95K3s8XFn5A3yay347KrZ7ZF15 W34rJrW7Ja18Gw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jF38nUUUUU= X-Originating-IP: [223.104.3.243] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/1tbiOxBRxlXlW7mc4QAAsT X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 220.181.12.14 Subject: [Qemu-devel] [PATCH 2/2] hw/audio: QOM'ify pl041.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP split the old SysBus init function into an instance_init and Device realize function Signed-off-by: xiaoqiang zhao --- hw/audio/pl041.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/hw/audio/pl041.c b/hw/audio/pl041.c index 6e9c104011..c8cc503236 100644 --- a/hw/audio/pl041.c +++ b/hw/audio/pl041.c @@ -521,12 +521,23 @@ static const MemoryRegionOps pl041_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -static int pl041_init(SysBusDevice *dev) +static void pl041_init(Object *obj) { + SysBusDevice *dev = SYS_BUS_DEVICE(obj); PL041State *s = PL041(dev); DBG_L1("pl041_init 0x%08x\n", (uint32_t)s); + /* Connect the device to the sysbus */ + memory_region_init_io(&s->iomem, obj, &pl041_ops, s, "pl041", 0x1000); + sysbus_init_mmio(dev, &s->iomem); + sysbus_init_irq(dev, &s->irq); +} + +static void pl041_realize(DeviceState *dev, Error **errp) +{ + PL041State *s = PL041(dev); + /* Check the device properties */ switch (s->fifo_depth) { case 8: @@ -545,18 +556,10 @@ static int pl041_init(SysBusDevice *dev) qemu_log_mask(LOG_UNIMP, "pl041: unsupported non-compact fifo depth [%i]\n", s->fifo_depth); - return -1; } - /* Connect the device to the sysbus */ - memory_region_init_io(&s->iomem, OBJECT(s), &pl041_ops, s, "pl041", 0x1000); - sysbus_init_mmio(dev, &s->iomem); - sysbus_init_irq(dev, &s->irq); - /* Init the codec */ lm4549_init(&s->codec, &pl041_request_data, (void *)s); - - return 0; } static const VMStateDescription vmstate_pl041_regfile = { @@ -627,9 +630,8 @@ static Property pl041_device_properties[] = { static void pl041_device_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = pl041_init; + dc->realize = pl041_realize; set_bit(DEVICE_CATEGORY_SOUND, dc->categories); dc->reset = pl041_device_reset; dc->vmsd = &vmstate_pl041; @@ -640,6 +642,7 @@ static const TypeInfo pl041_device_info = { .name = TYPE_PL041, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(PL041State), + .instance_init = pl041_init, .class_init = pl041_device_class_init, };