From patchwork Tue Jan 26 10:55:48 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: 8123341 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 68932BEEE5 for ; Tue, 26 Jan 2016 14:22:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BACB420256 for ; Tue, 26 Jan 2016 14:22:30 +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 189812025A for ; Tue, 26 Jan 2016 14:22:30 +0000 (UTC) Received: from localhost ([::1]:44309 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO4Vp-0004mC-Dr for patchwork-qemu-devel@patchwork.kernel.org; Tue, 26 Jan 2016 09:22:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO1Ja-00071X-KC 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-0003Hz-D9 for qemu-devel@nongnu.org; Tue, 26 Jan 2016 05:57:38 -0500 Received: from m12-13.163.com ([220.181.12.13]:38896) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO1JW-0003Gw-IZ 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=i81tdsRCP0No5Ez/eU wyS1zpJtu0QwvOH8/b2W0CqMk=; b=MKGz+mf+/8Ay4G49lVtyB5GjyVkgAFJ8b2 To/SaX9oeKfhjog1fZBqk5yIwgUTbrkL6YDbQmolB3gXL33GJYBmYpWMs+wnNMCr uT7txqgWNxNQJC/2qmRwuwcxhzo63z13Qiag/TadGVusKzYsNydUeD1uZAqDqAj5 6qiygXinY= Received: from localhost.localdomain (unknown [101.254.142.162]) by smtp9 (Coremail) with SMTP id DcCowACHxebqUKdWJttrAA--.26091S11; Tue, 26 Jan 2016 18:57:08 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Tue, 26 Jan 2016 18:55:48 +0800 Message-Id: <1453805753-27564-10-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--.26091S11 X-Coremail-Antispam: 1Uf129KBjvJXoWxZw48Gr1UCr1xJw4fuFyrtFb_yoW5Gr13pF WxZFsxtw47Gr4DXrWfJr1qqF1Ykws7t348Krn2yr4Iyr17JryUJ3WkX3y8Jw47tFZ29FWf Xa4kZFy5tw45taUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zREfOcUUUUU= X-Originating-IP: [101.254.142.162] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/xtbBEgT7xlZXv1jULQABs1 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 09/14] hw/timmer: QOM'ify milkymist_sysctl 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 milkymist_sysctl_init into milkymist_sysctl_info.instance_init and milkymist_sysctl_realize * use DeviceClass::realize instead of SysBusDeviceClass::init Signed-off-by: xiaoqiang zhao --- hw/timer/milkymist-sysctl.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/hw/timer/milkymist-sysctl.c b/hw/timer/milkymist-sysctl.c index 30535a4..e29c823 100644 --- a/hw/timer/milkymist-sysctl.c +++ b/hw/timer/milkymist-sysctl.c @@ -269,9 +269,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); @@ -281,14 +282,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, "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 = { @@ -318,9 +323,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; @@ -330,6 +334,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, };