From patchwork Fri Jan 6 01:10:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: zhao xiao qiang X-Patchwork-Id: 9499813 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 ABCCD60413 for ; Fri, 6 Jan 2017 01:11:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A03472841C for ; Fri, 6 Jan 2017 01:11:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 951912848A; Fri, 6 Jan 2017 01:11:04 +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 2186F2841C for ; Fri, 6 Jan 2017 01:11:03 +0000 (UTC) Received: from localhost ([::1]:49522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPJ3d-0003G9-H8 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Jan 2017 20:11:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPJ3L-0003G4-4n for qemu-devel@nongnu.org; Thu, 05 Jan 2017 20:10:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cPJ3H-00080z-NH for qemu-devel@nongnu.org; Thu, 05 Jan 2017 20:10:42 -0500 Received: from m12-14.163.com ([220.181.12.14]:34902) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPJ3G-0007sk-PM for qemu-devel@nongnu.org; Thu, 05 Jan 2017 20:10:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=JH6MQiEgLSO0bA8bn0 TqHKYyHX1KQ493ylvmx3TW8Xc=; b=OoaN6O3QxhtmTQCVFTLPg17xTIBqI/1L0Q xLZdgcOtWB7fCGmpKU9cmMRAMiSRzB3NzgaCXp8/VGdqyRs9EcdtyrbJ5idCbo/W 8wUXzcGC+UagSTle2zYsc7CGHq+hDFESVstrt9vgmMdYAF0s+fealuo2OZOwvMxy v8DGupVEQ= Received: from localhost.localdomain (unknown [223.104.3.255]) by smtp10 (Coremail) with SMTP id DsCowADn97eA7m5YTlg1GQ--.3457S2; Fri, 06 Jan 2017 09:10:31 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Fri, 6 Jan 2017 09:10:23 +0800 Message-Id: <20170106011023.24057-1-zxq_yx_007@163.com> X-Mailer: git-send-email 2.11.0 X-CM-TRANSID: DsCowADn97eA7m5YTlg1GQ--.3457S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxWryxXr4kur4kGr4rZF48Xrb_yoW5AFykpF WfCF90kr4rJFsrGFWftr4kuFy5A34kGw4Iyr12ywn3K3W7Cr15AF1kGa93trWUCFZ7uF15 GFWrX3WxGw48J3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jjnQUUUUUU= X-Originating-IP: [223.104.3.255] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/xtbB0gdXxlUMCSca-QAAsU X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 220.181.12.14 Subject: [Qemu-devel] [PATCH v2] hw/display: QOM'ify g364fb.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: peter.maydell@linaro.org, hpoussin@reactos.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Drop the old Sysbus init and use instance_init and DeviceClass::realize instead Signed-off-by: xiaoqiang zhao Tested-by: Hervé Poussineau --- hw/display/g364fb.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c index 70ef2c7453..7e2b3abe79 100644 --- a/hw/display/g364fb.c +++ b/hw/display/g364fb.c @@ -482,19 +482,6 @@ static const GraphicHwOps g364fb_ops = { .gfx_update = g364fb_update_display, }; -static void g364fb_init(DeviceState *dev, G364State *s) -{ - s->vram = g_malloc0(s->vram_size); - - s->con = graphic_console_init(dev, 0, &g364fb_ops, s); - - memory_region_init_io(&s->mem_ctrl, NULL, &g364fb_ctrl_ops, s, "ctrl", 0x180000); - memory_region_init_ram_ptr(&s->mem_vram, NULL, "vram", - s->vram_size, s->vram); - vmstate_register_ram(&s->mem_vram, dev); - memory_region_set_log(&s->mem_vram, true, DIRTY_MEMORY_VGA); -} - #define TYPE_G364 "sysbus-g364" #define G364(obj) OBJECT_CHECK(G364SysBusState, (obj), TYPE_G364) @@ -504,18 +491,33 @@ typedef struct { G364State g364; } G364SysBusState; -static int g364fb_sysbus_init(SysBusDevice *sbd) +static void g364fb_init(Object *obj) { + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); DeviceState *dev = DEVICE(sbd); G364SysBusState *sbs = G364(dev); G364State *s = &sbs->g364; - g364fb_init(dev, s); sysbus_init_irq(sbd, &s->irq); + + memory_region_init_io(&s->mem_ctrl, NULL, &g364fb_ctrl_ops, + s, "ctrl", 0x180000); sysbus_init_mmio(sbd, &s->mem_ctrl); - sysbus_init_mmio(sbd, &s->mem_vram); +} - return 0; +static void g364fb_realize(DeviceState *dev, Error **errp) +{ + G364SysBusState *sbs = G364(dev); + G364State *s = &sbs->g364; + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); + + s->vram = g_malloc0(s->vram_size); + s->con = graphic_console_init(dev, 0, &g364fb_ops, s); + memory_region_init_ram_ptr(&s->mem_vram, NULL, "vram", + s->vram_size, s->vram); + vmstate_register_ram(&s->mem_vram, dev); + memory_region_set_log(&s->mem_vram, true, DIRTY_MEMORY_VGA); + sysbus_init_mmio(sbd, &s->mem_vram); } static void g364fb_sysbus_reset(DeviceState *d) @@ -534,9 +536,8 @@ static Property g364fb_sysbus_properties[] = { static void g364fb_sysbus_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = g364fb_sysbus_init; + dc->realize = g364fb_realize; set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); dc->desc = "G364 framebuffer"; dc->reset = g364fb_sysbus_reset; @@ -548,6 +549,7 @@ static const TypeInfo g364fb_sysbus_info = { .name = TYPE_G364, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(G364SysBusState), + .instance_init = g364fb_init, .class_init = g364fb_sysbus_class_init, };