From patchwork Sun Oct 23 06:31:31 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: 9391033 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 431A060231 for ; Sun, 23 Oct 2016 06:43:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DD0228C56 for ; Sun, 23 Oct 2016 06:43:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F21DB28D80; Sun, 23 Oct 2016 06:43:44 +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 59D2128C56 for ; Sun, 23 Oct 2016 06:43:44 +0000 (UTC) Received: from localhost ([::1]:39919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byCVT-0005XD-9d for patchwork-qemu-devel@patchwork.kernel.org; Sun, 23 Oct 2016 02:43:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byCKP-0005OL-Tv for qemu-devel@nongnu.org; Sun, 23 Oct 2016 02:32:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byCKM-0003dv-QQ for qemu-devel@nongnu.org; Sun, 23 Oct 2016 02:32:17 -0400 Received: from m12-16.163.com ([220.181.12.16]:53581) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byCKM-0003dQ-7e for qemu-devel@nongnu.org; Sun, 23 Oct 2016 02:32:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=dxHcwWEIkShAGhZEGM irK4MsmNedh/vIBlsnr6Wyuf0=; b=OxP3gOUSK9B/+/GzJlXTP+qcl3rdKVqrJF yymoD1KsdPebjFGrwndYap18b0VDENlnRFWKH2rbBK4gMDzRR1TPmiJ2JzrKtB00 Qxbs9OMgjbIa3nccQLTR8R23RPyGEtCH3mwD07EiyEBuwIXV3a5ZYwECHVs1ZfA/ IIP3fOp7A= Received: from debian.lan (unknown [114.111.167.207]) by smtp12 (Coremail) with SMTP id EMCowABHqthVWQxYKknhBA--.56840S2; Sun, 23 Oct 2016 14:31:50 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Sun, 23 Oct 2016 14:31:31 +0800 Message-Id: <20161023063135.21058-6-zxq_yx_007@163.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161023063135.21058-1-zxq_yx_007@163.com> References: <20161023063135.21058-1-zxq_yx_007@163.com> X-CM-TRANSID: EMCowABHqthVWQxYKknhBA--.56840S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxZw1kKw1fGFyUAFWkuFy8Krg_yoW5Xw4rpF Z7AF95WrW8GF47JrWfKrWDGas5Jwn3Gw48t3WxGwsakw17Gr95JF1kA3ya9FWDJrZ7ZF4r tayxtry3W3WUGw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07b0zuXUUUUU= X-Originating-IP: [114.111.167.207] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/xtbBEBYMxlUL+3rQagAAsp X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.16 Subject: [Qemu-devel] [PATCH 5/9] hw/timer: QOM'ify m48txx_sysbus (pass 1) 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: pbonzini@redhat.com, mark.cave-ayland@ilande.co.uk, atar4qemu@gmail.com, peter.maydell@linaro.org 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 a Device realize function * use DeviceClass::realize instead of SysBusDeviceClass::init Signed-off-by: xiaoqiang zhao --- hw/timer/m48t59.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c index e46ca88..39e425e 100644 --- a/hw/timer/m48t59.c +++ b/hw/timer/m48t59.c @@ -765,30 +765,31 @@ static void m48t59_isa_realize(DeviceState *dev, Error **errp) } } -static int m48t59_init1(SysBusDevice *dev) +static void m48t59_init1(Object *obj) { - M48txxSysBusDeviceClass *u = M48TXX_SYS_BUS_GET_CLASS(dev); - M48txxSysBusState *d = M48TXX_SYS_BUS(dev); - Object *o = OBJECT(dev); + M48txxSysBusDeviceClass *u = M48TXX_SYS_BUS_GET_CLASS(obj); + M48txxSysBusState *d = M48TXX_SYS_BUS(obj); + SysBusDevice *dev = SYS_BUS_DEVICE(obj); M48t59State *s = &d->state; - Error *err = NULL; s->model = u->info.model; s->size = u->info.size; sysbus_init_irq(dev, &s->IRQ); - memory_region_init_io(&s->iomem, o, &nvram_ops, s, "m48t59.nvram", + memory_region_init_io(&s->iomem, obj, &nvram_ops, s, "m48t59.nvram", s->size); - memory_region_init_io(&d->io, o, &m48t59_io_ops, s, "m48t59", 4); - sysbus_init_mmio(dev, &s->iomem); - sysbus_init_mmio(dev, &d->io); - m48t59_realize_common(s, &err); - if (err != NULL) { - error_free(err); - return -1; - } + memory_region_init_io(&d->io, obj, &m48t59_io_ops, s, "m48t59", 4); +} - return 0; +static void m48t59_realize(DeviceState *dev, Error **errp) +{ + M48txxSysBusState *d = M48TXX_SYS_BUS(dev); + M48t59State *s = &d->state; + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); + + sysbus_init_mmio(sbd, &s->iomem); + sysbus_init_mmio(sbd, &d->io); + m48t59_realize_common(s, errp); } static uint32_t m48txx_isa_read(Nvram *obj, uint32_t addr) @@ -862,10 +863,9 @@ static Property m48t59_sysbus_properties[] = { static void m48txx_sysbus_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); NvramClass *nc = NVRAM_CLASS(klass); - k->init = m48t59_init1; + dc->realize = m48t59_realize; dc->reset = m48t59_reset_sysbus; dc->props = m48t59_sysbus_properties; nc->read = m48txx_sysbus_read; @@ -891,6 +891,7 @@ static const TypeInfo m48txx_sysbus_type_info = { .name = TYPE_M48TXX_SYS_BUS, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(M48txxSysBusState), + .instance_init = m48t59_init1, .abstract = true, .class_init = m48txx_sysbus_class_init, .interfaces = (InterfaceInfo[]) {