From patchwork Sat Dec 31 01:18:47 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: 9492577 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 D2ED662AB9 for ; Sat, 31 Dec 2016 01:23:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEBC3223B2 for ; Sat, 31 Dec 2016 01:23:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B001A25F31; Sat, 31 Dec 2016 01:23:59 +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 4FA0A223B2 for ; Sat, 31 Dec 2016 01:23:59 +0000 (UTC) Received: from localhost ([::1]:42131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN8Os-0005LM-8t for patchwork-qemu-devel@patchwork.kernel.org; Fri, 30 Dec 2016 20:23:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54784) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN8K5-0001QK-Mz for qemu-devel@nongnu.org; Fri, 30 Dec 2016 20:19:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cN8K4-0000LU-Ic for qemu-devel@nongnu.org; Fri, 30 Dec 2016 20:19:01 -0500 Received: from m12-14.163.com ([220.181.12.14]:45685) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN8K3-0000Kh-VL for qemu-devel@nongnu.org; Fri, 30 Dec 2016 20:19:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=qXE47sBkegJsV7wYCz Cs/Iisct0w4b3uCcSWG3YmWjY=; b=hK2ATeo7dIjI50NmYBYzW5puYss1EyHG6z UrRiBSILykAGKstWOWb4i+ry1OYL2VGGfnSRTm4VzTGiadZ3CdtITxaYJnfU+so1 VBEHkqQE5SFufHopvxLNoFrEauhwPXzeb2NCHQbLffJ6UrjiLpEF0pa+J7eVXdew 7vjiakjZE= Received: from localhost.localdomain (unknown [223.104.3.243]) by smtp10 (Coremail) with SMTP id DsCowAAn4M94B2dY4BCVFw--.1240S7; Sat, 31 Dec 2016 09:18:57 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Sat, 31 Dec 2016 09:18:47 +0800 Message-Id: <20161231011847.4153-6-zxq_yx_007@163.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161231011847.4153-1-zxq_yx_007@163.com> References: <20161231011847.4153-1-zxq_yx_007@163.com> X-CM-TRANSID: DsCowAAn4M94B2dY4BCVFw--.1240S7 X-Coremail-Antispam: 1Uf129KBjvJXoWxZw4UCw45Cryxtr1UXF1UZFb_yoW5Ww1rpa yfua9Igrs7JFsrZrZ7Zr1qgF1UAw48K340kry0k3s2yw17Gr18tF1kXw15Ar4UtFZ2vryf ArW8WryUCa98tw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j40PhUUUUU= X-Originating-IP: [223.104.3.243] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/1tbiOwFRxlXlW7mgRwAAsY X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 220.181.12.14 Subject: [Qemu-devel] [PATCH 5/5] hw/input: QOM'ify milkymist-softusb.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: michael@walle.cc 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/input/milkymist-softusb.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hw/input/milkymist-softusb.c b/hw/input/milkymist-softusb.c index 40dfca157f..2afbca8a9c 100644 --- a/hw/input/milkymist-softusb.c +++ b/hw/input/milkymist-softusb.c @@ -245,32 +245,37 @@ static void milkymist_softusb_reset(DeviceState *d) s->regs[R_CTRL] = CTRL_RESET; } -static int milkymist_softusb_init(SysBusDevice *dev) +static void milkymist_softusb_init(Object *obj) { + SysBusDevice *dev = SYS_BUS_DEVICE(obj); MilkymistSoftUsbState *s = MILKYMIST_SOFTUSB(dev); sysbus_init_irq(dev, &s->irq); - memory_region_init_io(&s->regs_region, OBJECT(s), &softusb_mmio_ops, s, + memory_region_init_io(&s->regs_region, obj, &softusb_mmio_ops, s, "milkymist-softusb", R_MAX * 4); sysbus_init_mmio(dev, &s->regs_region); +} + +static void milkymist_softusb_realize(DeviceState *dev, Error **errp) +{ + MilkymistSoftUsbState *s = MILKYMIST_SOFTUSB(dev); + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); /* register pmem and dmem */ memory_region_init_ram(&s->pmem, OBJECT(s), "milkymist-softusb.pmem", s->pmem_size, &error_fatal); vmstate_register_ram_global(&s->pmem); s->pmem_ptr = memory_region_get_ram_ptr(&s->pmem); - sysbus_init_mmio(dev, &s->pmem); + sysbus_init_mmio(sbd, &s->pmem); memory_region_init_ram(&s->dmem, OBJECT(s), "milkymist-softusb.dmem", s->dmem_size, &error_fatal); vmstate_register_ram_global(&s->dmem); s->dmem_ptr = memory_region_get_ram_ptr(&s->dmem); - sysbus_init_mmio(dev, &s->dmem); + sysbus_init_mmio(sbd, &s->dmem); hid_init(&s->hid_kbd, HID_KEYBOARD, softusb_kbd_hid_datain); hid_init(&s->hid_mouse, HID_MOUSE, softusb_mouse_hid_datain); - - return 0; } static const VMStateDescription vmstate_milkymist_softusb = { @@ -296,9 +301,8 @@ static Property milkymist_softusb_properties[] = { static void milkymist_softusb_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = milkymist_softusb_init; + dc->realize = milkymist_softusb_realize; dc->reset = milkymist_softusb_reset; dc->vmsd = &vmstate_milkymist_softusb; dc->props = milkymist_softusb_properties; @@ -308,6 +312,7 @@ static const TypeInfo milkymist_softusb_info = { .name = TYPE_MILKYMIST_SOFTUSB, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(MilkymistSoftUsbState), + .instance_init = milkymist_softusb_init, .class_init = milkymist_softusb_class_init, };