From patchwork Tue Jan 26 10:55:40 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: 8123391 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9BD6CBEEE5 for ; Tue, 26 Jan 2016 14:25:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E960520259 for ; Tue, 26 Jan 2016 14:25:37 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 3CDEB20222 for ; Tue, 26 Jan 2016 14:25:37 +0000 (UTC) Received: from localhost ([::1]:44346 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO4Yq-0002Ph-I7 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 26 Jan 2016 09:25:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO1Ja-00071U-JQ for qemu-devel@nongnu.org; Tue, 26 Jan 2016 05:57:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aO1JX-0003IE-K4 for qemu-devel@nongnu.org; Tue, 26 Jan 2016 05:57:38 -0500 Received: from m12-13.163.com ([220.181.12.13]:38819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO1JX-0003Gm-1m for qemu-devel@nongnu.org; Tue, 26 Jan 2016 05:57:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=85/RalHUtyLtwPGOlA Ti7GKjQrdjbnzF3XNOqet5BSw=; b=R4iNltTvJX+AceVtWPXNmPujg8h11Gt1BN 2e9I9QGO+m8w7t78TBZkQZDhogWQvO0ALv0Iu/m2RRV4A0ABHlhNI2RdNXUinETA Rb4WsjkwyVfq0DIdtv/lXpWM8RC9Eakpma7ip/PwRwuNPHdQrBK4HQugacA6zrsh FIot5kZ3g= Received: from localhost.localdomain (unknown [101.254.142.162]) by smtp9 (Coremail) with SMTP id DcCowACHxebqUKdWJttrAA--.26091S3; Tue, 26 Jan 2016 18:57:03 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Tue, 26 Jan 2016 18:55:40 +0800 Message-Id: <1453805753-27564-2-git-send-email-zxq_yx_007@163.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1453805753-27564-1-git-send-email-zxq_yx_007@163.com> References: <1453805753-27564-1-git-send-email-zxq_yx_007@163.com> X-CM-TRANSID: DcCowACHxebqUKdWJttrAA--.26091S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxAF48tF13Gr4UWw1kXF1UWrg_yoW5Zw1UpF Z7WF13ArW0gFs7Jrs3JFn7W3Z5Awn7Cw18GF17GrnakFZ2kry3tF1DA3y3CFWUGrWxZF9x t3yrJFyakF4UGw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRCzuAUUUUU= X-Originating-IP: [101.254.142.162] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/1tbiEB-7xlWBTbRg9QAAsK X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.13 X-Mailman-Approved-At: Tue, 26 Jan 2016 09:22:12 -0500 Cc: xiaoqiang zhao , peter.maydell@linaro.org, afaerber@suse.de Subject: [Qemu-devel] [PATCH 01/14] hw/timmer: QOM'ify arm_timer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP * assign icp_pit_init to icp_pit_info.instance_init * split sp804_init into sp804_info.instance_init (sp804_init) and sp804_realize * use DeviceClass::realize instead of SysBusDeviceClass::init Signed-off-by: xiaoqiang zhao --- hw/timer/arm_timer.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/hw/timer/arm_timer.c b/hw/timer/arm_timer.c index d53f39a..cce1abc 100644 --- a/hw/timer/arm_timer.c +++ b/hw/timer/arm_timer.c @@ -276,21 +276,26 @@ static const VMStateDescription vmstate_sp804 = { } }; -static int sp804_init(SysBusDevice *sbd) +static void sp804_init(Object *obj) { - DeviceState *dev = DEVICE(sbd); - SP804State *s = SP804(dev); + SP804State *s = SP804(obj); + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); sysbus_init_irq(sbd, &s->irq); + memory_region_init_io(&s->iomem, OBJECT(s), &sp804_ops, s, + "sp804", 0x1000); + sysbus_init_mmio(sbd, &s->iomem); +} + +static void sp804_realize(DeviceState *dev, Error **errp) +{ + SP804State *s = SP804(dev); + s->timer[0] = arm_timer_init(s->freq0); s->timer[1] = arm_timer_init(s->freq1); s->timer[0]->irq = qemu_allocate_irq(sp804_set_irq, s, 0); s->timer[1]->irq = qemu_allocate_irq(sp804_set_irq, s, 1); - memory_region_init_io(&s->iomem, OBJECT(s), &sp804_ops, s, - "sp804", 0x1000); - sysbus_init_mmio(sbd, &s->iomem); vmstate_register(dev, -1, &vmstate_sp804, s); - return 0; } /* Integrator/CP timer module. */ @@ -343,9 +348,10 @@ static const MemoryRegionOps icp_pit_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -static int icp_pit_init(SysBusDevice *dev) +static void icp_pit_init(Object *obj) { - icp_pit_state *s = INTEGRATOR_PIT(dev); + icp_pit_state *s = INTEGRATOR_PIT(obj); + SysBusDevice *dev = SYS_BUS_DEVICE(obj); /* Timer 0 runs at the system clock speed (40MHz). */ s->timer[0] = arm_timer_init(40000000); @@ -362,20 +368,18 @@ static int icp_pit_init(SysBusDevice *dev) sysbus_init_mmio(dev, &s->iomem); /* This device has no state to save/restore. The component timers will save themselves. */ - return 0; } static void icp_pit_class_init(ObjectClass *klass, void *data) { - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); - - sdc->init = icp_pit_init; + /* do nothing */ } static const TypeInfo icp_pit_info = { .name = TYPE_INTEGRATOR_PIT, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(icp_pit_state), + .instance_init = icp_pit_init, .class_init = icp_pit_class_init, }; @@ -387,17 +391,17 @@ static Property sp804_properties[] = { static void sp804_class_init(ObjectClass *klass, void *data) { - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); - DeviceClass *k = DEVICE_CLASS(klass); + DeviceClass *dc = DEVICE_CLASS(klass); - sdc->init = sp804_init; - k->props = sp804_properties; + dc->realize = sp804_realize; + dc->props = sp804_properties; } static const TypeInfo sp804_info = { .name = TYPE_SP804, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(SP804State), + .instance_init = sp804_init, .class_init = sp804_class_init, };