From patchwork Tue Jan 26 10:55:46 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: 8123421 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 669CA9F818 for ; Tue, 26 Jan 2016 14:26:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C060C20270 for ; Tue, 26 Jan 2016 14:26:54 +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 258012026D for ; Tue, 26 Jan 2016 14:26:53 +0000 (UTC) Received: from localhost ([::1]:44358 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO4a4-0004T3-FM for patchwork-qemu-devel@patchwork.kernel.org; Tue, 26 Jan 2016 09:26:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO1Je-00072p-Vy for qemu-devel@nongnu.org; Tue, 26 Jan 2016 05:57:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aO1Je-0003KY-04 for qemu-devel@nongnu.org; Tue, 26 Jan 2016 05:57:42 -0500 Received: from m12-13.163.com ([220.181.12.13]:39405) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO1Jd-0003KL-E8 for qemu-devel@nongnu.org; Tue, 26 Jan 2016 05:57:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=z+6opJIOHoxklfduEh pma7MJtwSf3HahXp4N3zPIYJs=; b=icc+u1jQJQABIg8Au54qhNVYFzGGFSvVqE Cm9iNyp72i4Ub6+a7PuuN263ew18oO42vzdqmhd5qUCVxJV81mbskFm2wov1Bqmz R76BhFrm78qm8dTmu2assKylXzq2M5Oula8ZdN+w6C06q+gQJw/HenyAr3eLwVL6 0bTq/xkfo= Received: from localhost.localdomain (unknown [101.254.142.162]) by smtp9 (Coremail) with SMTP id DcCowACHxebqUKdWJttrAA--.26091S9; Tue, 26 Jan 2016 18:57:07 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Tue, 26 Jan 2016 18:55:46 +0800 Message-Id: <1453805753-27564-8-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--.26091S9 X-Coremail-Antispam: 1Uf129KBjvJXoW7Cr1rJr4UAr45Zr4UZw1UWrg_yoW8ZF13pa yxuF17Gr48JrsrXr4fArn7GF98tr1kAr1kGryxJws2vF1Iyw18tF4DA3yavF4akFWv9FW3 ArWfXF1rAw45Gr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRE4iUUUUUU= X-Originating-IP: [101.254.142.162] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/xtbB0gP7xlUL9ORcEwAAst 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 07/14] hw/timmer: QOM'ify lm32_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 * split lm32_timer_init into lm32_timer_info.instance_init and lm32_timer_realize * use DeviceClass::realize instead of SysBusDeviceClass::init Signed-off-by: xiaoqiang zhao --- hw/timer/lm32_timer.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/timer/lm32_timer.c b/hw/timer/lm32_timer.c index d2ab1e7..4ee080a 100644 --- a/hw/timer/lm32_timer.c +++ b/hw/timer/lm32_timer.c @@ -175,21 +175,26 @@ static void timer_reset(DeviceState *d) ptimer_stop(s->ptimer); } -static int lm32_timer_init(SysBusDevice *dev) +static void lm32_timer_init(Object *obj) { - LM32TimerState *s = LM32_TIMER(dev); + LM32TimerState *s = LM32_TIMER(obj); + SysBusDevice *dev = SYS_BUS_DEVICE(obj); sysbus_init_irq(dev, &s->irq); s->bh = qemu_bh_new(timer_hit, s); s->ptimer = ptimer_init(s->bh); - ptimer_set_freq(s->ptimer, s->freq_hz); memory_region_init_io(&s->iomem, OBJECT(s), &timer_ops, s, "timer", R_MAX * 4); sysbus_init_mmio(dev, &s->iomem); +} - return 0; +static void lm32_timer_realize(DeviceState *dev, Error **errp) +{ + LM32TimerState *s = LM32_TIMER(dev); + + ptimer_set_freq(s->ptimer, s->freq_hz); } static const VMStateDescription vmstate_lm32_timer = { @@ -212,9 +217,8 @@ static Property lm32_timer_properties[] = { static void lm32_timer_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = lm32_timer_init; + dc->realize = lm32_timer_realize; dc->reset = timer_reset; dc->vmsd = &vmstate_lm32_timer; dc->props = lm32_timer_properties; @@ -224,6 +228,7 @@ static const TypeInfo lm32_timer_info = { .name = TYPE_LM32_TIMER, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(LM32TimerState), + .instance_init = lm32_timer_init, .class_init = lm32_timer_class_init, };