From patchwork Sun Feb 5 13:37: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: 9556077 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 A2576602B1 for ; Sun, 5 Feb 2017 13:43:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 949B5204BE for ; Sun, 5 Feb 2017 13:43:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8989B26E39; Sun, 5 Feb 2017 13:43:22 +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 2B180204BE for ; Sun, 5 Feb 2017 13:43:22 +0000 (UTC) Received: from localhost ([::1]:43304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1caN69-00043l-7l for patchwork-qemu-devel@patchwork.kernel.org; Sun, 05 Feb 2017 08:43:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1caN1B-0000As-3c for qemu-devel@nongnu.org; Sun, 05 Feb 2017 08:38:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1caN17-0003Hl-VO for qemu-devel@nongnu.org; Sun, 05 Feb 2017 08:38:13 -0500 Received: from m12-14.163.com ([220.181.12.14]:60837) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1caN17-0003En-BI for qemu-devel@nongnu.org; Sun, 05 Feb 2017 08:38:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=0LIuUqaLw7GAp8Zb/F nJyFCrYZG5tkaNSU9xSup/3kk=; b=RM/XplcZkWk73/1zyL7PSXBZuaoWkYgOrI 0SbKgXd/AqCBTu/O+ImxubMmS7Dikw4zH3Ef8aEECzdHrGfIaA1MDfcNVyblr/9y +gKaF28IH7qedfGzlFKiozQv4NLBIPfr9rtpobR6opfN5x0ZX+LIPN74dXsziKCP buxDydvx0= Received: from localhost.localdomain (unknown [117.136.0.125]) by smtp10 (Coremail) with SMTP id DsCowACnVrepKpdYyVK9Ig--.30409S3; Sun, 05 Feb 2017 21:37:46 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Sun, 5 Feb 2017 21:37:23 +0800 Message-Id: <20170205133727.23424-6-zxq_yx_007@163.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170205133727.23424-1-zxq_yx_007@163.com> References: <20170205133727.23424-1-zxq_yx_007@163.com> X-CM-TRANSID: DsCowACnVrepKpdYyVK9Ig--.30409S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxZw1kKw1fGFyUAFWkuFy8Krg_yoW5Wr1UpF Z7AF95WrW8GF47JrWfKrWDGas5Jwn3Gw48t3WxGwsakw17Gr95JF1kA3ya9FWUGrZ7ZF4r tayxtry3W3W7Gw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jlZXOUUUUU= X-Originating-IP: [117.136.0.125] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/1tbiFgp1xlWBUnmo5wAAsf X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 220.181.12.14 Subject: [Qemu-devel] [RESEND 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 Reviewed-by: Philippe Mathieu-Daudé --- 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 e46ca88391..39e425e950 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[]) {