From patchwork Mon Jun 20 16:39:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 9188247 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 0FE136075F for ; Mon, 20 Jun 2016 17:03:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F13AF276AE for ; Mon, 20 Jun 2016 17:03:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E564A27B2F; Mon, 20 Jun 2016 17:03:50 +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 DA021276AE for ; Mon, 20 Jun 2016 17:03:49 +0000 (UTC) Received: from localhost ([::1]:45068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF2c1-00020H-4e for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Jun 2016 13:03:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF2FE-0008BD-Ur for qemu-devel@nongnu.org; Mon, 20 Jun 2016 12:40:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bF2FB-0007BM-Lh for qemu-devel@nongnu.org; Mon, 20 Jun 2016 12:40:16 -0400 Received: from ssl.serverraum.org ([213.133.101.245]:50728) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF2FB-0007B5-9u for qemu-devel@nongnu.org; Mon, 20 Jun 2016 12:40:13 -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 704A322454; Mon, 20 Jun 2016 18:40:08 +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=1466440808; bh=EUBnvU7RMqh319ZLuf8Q54G7OxQEHLaZs3EQR/uRrHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gt4JOeHw+AB8S9rfmVrFx6kyHeDmGoNEZ2UCyJasANGb3+P2xmhaRcpIlFg6OVqEp x6YkDUgysXlUA5Tu2nsxU3dBB2VuhOWUnB3EDWUkwR/wDvWF/uJX3vrrQG7CiRy83c fp7Q3sq0/Lz271mo7TrTy3pAnYypB9f6OxVxKCNI= From: Michael Walle To: qemu-devel@nongnu.org Date: Mon, 20 Jun 2016 18:39:05 +0200 Message-Id: <1466440749-17195-3-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: 213.133.101.245 Subject: [Qemu-devel] [PULL 2/6] hw/timer: QOM'ify milkymist_sysctl 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/milkymist-sysctl.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hw/timer/milkymist-sysctl.c b/hw/timer/milkymist-sysctl.c index 5f29480..30a4bc4 100644 --- a/hw/timer/milkymist-sysctl.c +++ b/hw/timer/milkymist-sysctl.c @@ -270,9 +270,10 @@ static void milkymist_sysctl_reset(DeviceState *d) s->regs[R_GPIO_IN] = s->strappings; } -static int milkymist_sysctl_init(SysBusDevice *dev) +static void milkymist_sysctl_init(Object *obj) { - MilkymistSysctlState *s = MILKYMIST_SYSCTL(dev); + MilkymistSysctlState *s = MILKYMIST_SYSCTL(obj); + SysBusDevice *dev = SYS_BUS_DEVICE(obj); sysbus_init_irq(dev, &s->gpio_irq); sysbus_init_irq(dev, &s->timer0_irq); @@ -282,14 +283,18 @@ static int milkymist_sysctl_init(SysBusDevice *dev) s->bh1 = qemu_bh_new(timer1_hit, s); s->ptimer0 = ptimer_init(s->bh0); s->ptimer1 = ptimer_init(s->bh1); - ptimer_set_freq(s->ptimer0, s->freq_hz); - ptimer_set_freq(s->ptimer1, s->freq_hz); - memory_region_init_io(&s->regs_region, OBJECT(s), &sysctl_mmio_ops, s, + memory_region_init_io(&s->regs_region, obj, &sysctl_mmio_ops, s, "milkymist-sysctl", R_MAX * 4); sysbus_init_mmio(dev, &s->regs_region); +} - return 0; +static void milkymist_sysctl_realize(DeviceState *dev, Error **errp) +{ + MilkymistSysctlState *s = MILKYMIST_SYSCTL(dev); + + ptimer_set_freq(s->ptimer0, s->freq_hz); + ptimer_set_freq(s->ptimer1, s->freq_hz); } static const VMStateDescription vmstate_milkymist_sysctl = { @@ -319,9 +324,8 @@ static Property milkymist_sysctl_properties[] = { static void milkymist_sysctl_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = milkymist_sysctl_init; + dc->realize = milkymist_sysctl_realize; dc->reset = milkymist_sysctl_reset; dc->vmsd = &vmstate_milkymist_sysctl; dc->props = milkymist_sysctl_properties; @@ -331,6 +335,7 @@ static const TypeInfo milkymist_sysctl_info = { .name = TYPE_MILKYMIST_SYSCTL, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(MilkymistSysctlState), + .instance_init = milkymist_sysctl_init, .class_init = milkymist_sysctl_class_init, };