From patchwork Sat Apr 29 10:49:33 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: 9705751 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 6DB19602BE for ; Sat, 29 Apr 2017 10:51:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60A5E28636 for ; Sat, 29 Apr 2017 10:51:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5586D2868E; Sat, 29 Apr 2017 10:51:46 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM,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 EF2BA28636 for ; Sat, 29 Apr 2017 10:51:45 +0000 (UTC) Received: from localhost ([::1]:40570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d4Pyb-0002C5-7E for patchwork-qemu-devel@patchwork.kernel.org; Sat, 29 Apr 2017 06:51:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d4PxA-0002Ax-Kd for qemu-devel@nongnu.org; Sat, 29 Apr 2017 06:50:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d4Px5-0003iE-M9 for qemu-devel@nongnu.org; Sat, 29 Apr 2017 06:50:16 -0400 Received: from m12-12.163.com ([220.181.12.12]:42590) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d4Px4-0003dH-U6 for qemu-devel@nongnu.org; Sat, 29 Apr 2017 06:50:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=yrim9BPk+zJ1qucqge N9anNFk0xDi3h8DC/NbbQWS0Q=; b=qW4Gsis/UIMm/owuBxBV6pQfVq1N5SmIY8 OP6RwR0aUn0inbjV10hLf23kINAI6A0QCykkkI/A8fmd5jc6+4m5hITLovjVO5R+ XBcTyXQLlDZknvJkzXRw07/Xa8zDJ6GF7Sw8O3+fKXEWvN6xXXIiJo5cS86vZGFb /lEwEJ4lc= Received: from localhost.localdomain (unknown [1.203.183.82]) by smtp8 (Coremail) with SMTP id DMCowAAnzhbNbwRZZlhtBA--.26750S2; Sat, 29 Apr 2017 18:49:49 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Sat, 29 Apr 2017 18:49:33 +0800 Message-Id: <20170429104937.31341-6-zxq_yx_007@163.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170429104937.31341-1-zxq_yx_007@163.com> References: <20170429104937.31341-1-zxq_yx_007@163.com> X-CM-TRANSID: DMCowAAnzhbNbwRZZlhtBA--.26750S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxZw4UCw4ruw15Zr1UZry7ZFb_yoW5WF18pF Z3AF95WrW8GF47JrWfKrykGas5Jwn3Gw48t3W7Gwnakw1xJr9YyF1kA3ya9rWUJrZ7ZF4r tayxtw13W3W7Gw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jSYL9UUUUU= X-Originating-IP: [1.203.183.82] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/1tbiMw7IxlXllK6URgAAsr X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 220.181.12.12 Subject: [Qemu-devel] [PATCH v2 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: edgar.iglesias@xilinx.com, peter.maydell@linaro.org, mark.cave-ayland@ilande.co.uk, pbonzini@redhat.com, atar4qemu@gmail.com, david@gibson.dropbear.id.au 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 474981a6ac..eff259ef96 100644 --- a/hw/timer/m48t59.c +++ b/hw/timer/m48t59.c @@ -644,30 +644,31 @@ void m48t59_realize_common(M48t59State *s, Error **errp) vmstate_register(NULL, -1, &vmstate_m48t59, s); } -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); +} + +static void m48t59_realize(DeviceState *dev, Error **errp) +{ + M48txxSysBusState *d = M48TXX_SYS_BUS(dev); + M48t59State *s = &d->state; + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); - return 0; + sysbus_init_mmio(sbd, &s->iomem); + sysbus_init_mmio(sbd, &d->io); + m48t59_realize_common(s, errp); } static uint32_t m48txx_sysbus_read(Nvram *obj, uint32_t addr) @@ -696,10 +697,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; @@ -725,6 +725,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[]) {