From patchwork Mon Jun 20 16:39:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 9188241 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 6D30C6075F for ; Mon, 20 Jun 2016 17:00:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BA0E276AE for ; Mon, 20 Jun 2016 17:00:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 505D027B2F; Mon, 20 Jun 2016 17:00:52 +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, 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 C86E4276AE for ; Mon, 20 Jun 2016 17:00:51 +0000 (UTC) Received: from localhost ([::1]:45054 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF2Z7-0006js-Iw for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Jun 2016 13:00:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF2FC-00088F-1b for qemu-devel@nongnu.org; Mon, 20 Jun 2016 12:40:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bF2FA-0007B8-SS for qemu-devel@nongnu.org; Mon, 20 Jun 2016 12:40:13 -0400 Received: from ssl.serverraum.org ([2a01:4f8:130:84d6::1:2]:58721) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF2FA-00079f-LU for qemu-devel@nongnu.org; Mon, 20 Jun 2016 12:40:12 -0400 Received: from thanatos.fritz.box (unknown [IPv6:2001:6f8:968:0:56be:f7ff:fe37:9af7]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 26797223CF; Mon, 20 Jun 2016 18:40:06 +0200 (CEST) Authentication-Results: ssl.serverraum.org; dmarc=none header.from=walle.cc DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1466440806; bh=4Dt7BXTYWyqLhNcktBsilFNmP5WJdfxohugC2tLrYDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k20B9SVYANmInHaE6VfM5qWl67RVfoxUbmF75VtMjAaZ5V1gkbQ10aYdSdDQ2b/te 9yDMFS+FQTYjn8MWa2htdqrCsBMQY2maz1LG2tkYiHosLIeK9XNxWA2PAw5IKcQhrU cGROuNX/+PmaRXQQRwPXY4ndUTdHUsMwavFmSBv4= From: Michael Walle To: qemu-devel@nongnu.org Date: Mon, 20 Jun 2016 18:39:04 +0200 Message-Id: <1466440749-17195-2-git-send-email-michael@walle.cc> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1466440749-17195-1-git-send-email-michael@walle.cc> References: <1466440749-17195-1-git-send-email-michael@walle.cc> X-Virus-Scanned: clamav-milter 0.99.2 at web X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:4f8:130:84d6::1:2 Subject: [Qemu-devel] [PULL 1/6] hw/timer: QOM'ify lm32_timer 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: xiaoqiang zhao , Peter Maydell , Michael Walle Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: xiaoqiang zhao * split the old SysBus init function into an instance_init and a Device realize function * use DeviceClass::realize instead of SysBusDeviceClass::init Reviewed-by: Peter Maydell Signed-off-by: xiaoqiang zhao Acked-by: Michael Walle Tested-by: Michael Walle Signed-off-by: Michael Walle --- hw/timer/lm32_timer.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/hw/timer/lm32_timer.c b/hw/timer/lm32_timer.c index 3198355..e45a65b 100644 --- a/hw/timer/lm32_timer.c +++ b/hw/timer/lm32_timer.c @@ -176,21 +176,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, + memory_region_init_io(&s->iomem, obj, &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 = { @@ -213,9 +218,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; @@ -225,6 +229,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, };