From patchwork Sat Dec 31 01:18:08 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: 9492575 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 4CB5162AB9 for ; Sat, 31 Dec 2016 01:23:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38B63223B2 for ; Sat, 31 Dec 2016 01:23:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A1AB25E13; Sat, 31 Dec 2016 01:23:23 +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 C84CC223B2 for ; Sat, 31 Dec 2016 01:23:22 +0000 (UTC) Received: from localhost ([::1]:42127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN8OH-0004q2-DJ for patchwork-qemu-devel@patchwork.kernel.org; Fri, 30 Dec 2016 20:23:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54542) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN8JW-0000xx-1E for qemu-devel@nongnu.org; Fri, 30 Dec 2016 20:18:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cN8JV-0008VP-4F for qemu-devel@nongnu.org; Fri, 30 Dec 2016 20:18:25 -0500 Received: from m12-14.163.com ([220.181.12.14]:44215) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN8JU-0008UF-Ha; Fri, 30 Dec 2016 20:18:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=JZ0m4OPGr0x++rowxv IIzyLxEmBmIDmdB7QqKDJ+hMo=; b=GQHix4m5YlsdndDaxQXamsFvBnu0dmCQyu v01d0CRvaUirlEUcnMoWF80TMfJZTOij93HdTBWl+yDcC5kjXnQUz/T1EEuFStWx fZCj5xmvvaBzUnr3u2hPxspP8fdn8OSxq48awU1rPXlqQEW2ET1YRJspZ4jTz+v+ foqzCi87Y= Received: from localhost.localdomain (unknown [223.104.3.243]) by smtp10 (Coremail) with SMTP id DsCowACnzZpQB2dYbQqVFw--.11118S4; Sat, 31 Dec 2016 09:18:15 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Sat, 31 Dec 2016 09:18:08 +0800 Message-Id: <20161231011808.4037-3-zxq_yx_007@163.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161231011808.4037-1-zxq_yx_007@163.com> References: <20161231011808.4037-1-zxq_yx_007@163.com> X-CM-TRANSID: DsCowACnzZpQB2dYbQqVFw--.11118S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7tw1rJr17uw4fZFy5uFWDtwb_yoW8uw4Dpr WxGFnYyF4DAa1xAF43tFyUGan8Jrn7tF48Jr17Cr4fG397GrnrtF1YkrsIyFW5JrWkAFyr Ca1rKr1UK3WDKr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jQEf5UUUUU= X-Originating-IP: [223.104.3.243] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/1tbiMxdRxlXljrws0gAAsP 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/char: QOM'ify grlib_apbuart.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: i.mitsyanko@gmail.com, pbonzini@redhat.com, qemu-arm@nongnu.org, chouteau@adacore.com 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 Reviewed-by: Peter Maydell --- hw/char/grlib_apbuart.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/hw/char/grlib_apbuart.c b/hw/char/grlib_apbuart.c index db686e6a6f..620b801f34 100644 --- a/hw/char/grlib_apbuart.c +++ b/hw/char/grlib_apbuart.c @@ -239,24 +239,28 @@ static const MemoryRegionOps grlib_apbuart_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -static int grlib_apbuart_init(SysBusDevice *dev) +static void grlib_apbuart_init(Object *obj) { + SysBusDevice *dev = SYS_BUS_DEVICE(obj); UART *uart = GRLIB_APB_UART(dev); - qemu_chr_fe_set_handlers(&uart->chr, - grlib_apbuart_can_receive, - grlib_apbuart_receive, - grlib_apbuart_event, - uart, NULL, true); - sysbus_init_irq(dev, &uart->irq); - memory_region_init_io(&uart->iomem, OBJECT(uart), &grlib_apbuart_ops, uart, + memory_region_init_io(&uart->iomem, obj, &grlib_apbuart_ops, uart, "uart", UART_REG_SIZE); sysbus_init_mmio(dev, &uart->iomem); +} - return 0; +static void grlib_apbuart_realize(DeviceState *dev, Error **errp) +{ + UART *uart = GRLIB_APB_UART(dev); + + qemu_chr_fe_set_handlers(&uart->chr, + grlib_apbuart_can_receive, + grlib_apbuart_receive, + grlib_apbuart_event, + uart, NULL, true); } static void grlib_apbuart_reset(DeviceState *d) @@ -280,9 +284,8 @@ static Property grlib_apbuart_properties[] = { static void grlib_apbuart_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = grlib_apbuart_init; + dc->realize = grlib_apbuart_realize; dc->reset = grlib_apbuart_reset; dc->props = grlib_apbuart_properties; } @@ -291,6 +294,7 @@ static const TypeInfo grlib_apbuart_info = { .name = TYPE_GRLIB_APB_UART, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(UART), + .instance_init = grlib_apbuart_init, .class_init = grlib_apbuart_class_init, };