From patchwork Mon Jun 20 16:39:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 9188219 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 EB0B1601C0 for ; Mon, 20 Jun 2016 16:48:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D802625227 for ; Mon, 20 Jun 2016 16:48:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C972C27B16; Mon, 20 Jun 2016 16:48:34 +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 4B2C125227 for ; Mon, 20 Jun 2016 16:48:34 +0000 (UTC) Received: from localhost ([::1]:44974 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF2NF-0007fN-Hh for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Jun 2016 12:48:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF2FJ-0008EO-6U for qemu-devel@nongnu.org; Mon, 20 Jun 2016 12:40:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bF2FD-0007Bw-K5 for qemu-devel@nongnu.org; Mon, 20 Jun 2016 12:40:19 -0400 Received: from ssl.serverraum.org ([213.133.101.245]:53031) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF2FD-0007Bq-Dd for qemu-devel@nongnu.org; Mon, 20 Jun 2016 12:40:15 -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 92ED922460; Mon, 20 Jun 2016 18:40:12 +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=1466440812; bh=sTnR2wRmxtZmckstkysHJA+qXICt0RSZNk8Qw+InYtA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PFJJuxCnUQmtnltfUNNAtQklFaOTT0ZHP48X41oIdgbjobSN/q83Eg9f7Pka6veBY ozRGSNou6iPRd1gRDf6X1D3WiuEAsfreXawbaXPH7sbIBv3HlHoWarxZhI2gBErs31 Z/dsV6rQiCIKvSEei1PIzFMg745A7Lp5637KtV3I= From: Michael Walle To: qemu-devel@nongnu.org Date: Mon, 20 Jun 2016 18:39:06 +0200 Message-Id: <1466440749-17195-4-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 3/6] hw/display: QOM'ify milkymist-tmu2.c 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 * Drop the old SysBus init function and use instance_init * Move tmu2_glx_init into realize stage Signed-off-by: xiaoqiang zhao Reviewed-by: Peter Maydell Acked-by: Michael Walle Tested-by: Michael Walle Signed-off-by: Michael Walle --- hw/display/milkymist-tmu2.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/hw/display/milkymist-tmu2.c b/hw/display/milkymist-tmu2.c index 9bc88f9..cee8fb0 100644 --- a/hw/display/milkymist-tmu2.c +++ b/hw/display/milkymist-tmu2.c @@ -443,21 +443,25 @@ static void milkymist_tmu2_reset(DeviceState *d) } } -static int milkymist_tmu2_init(SysBusDevice *dev) +static void milkymist_tmu2_init(Object *obj) { - MilkymistTMU2State *s = MILKYMIST_TMU2(dev); - - if (tmu2_glx_init(s)) { - return 1; - } + MilkymistTMU2State *s = MILKYMIST_TMU2(obj); + SysBusDevice *dev = SYS_BUS_DEVICE(obj); sysbus_init_irq(dev, &s->irq); - memory_region_init_io(&s->regs_region, OBJECT(s), &tmu2_mmio_ops, s, + memory_region_init_io(&s->regs_region, obj, &tmu2_mmio_ops, s, "milkymist-tmu2", R_MAX * 4); sysbus_init_mmio(dev, &s->regs_region); +} - return 0; +static void milkymist_tmu2_realize(DeviceState *dev, Error **errp) +{ + MilkymistTMU2State *s = MILKYMIST_TMU2(dev); + + if (tmu2_glx_init(s)) { + error_setg(errp, "tmu2_glx_init failed"); + } } static const VMStateDescription vmstate_milkymist_tmu2 = { @@ -473,9 +477,8 @@ static const VMStateDescription vmstate_milkymist_tmu2 = { static void milkymist_tmu2_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = milkymist_tmu2_init; + dc->realize = milkymist_tmu2_realize; dc->reset = milkymist_tmu2_reset; dc->vmsd = &vmstate_milkymist_tmu2; } @@ -484,6 +487,7 @@ static const TypeInfo milkymist_tmu2_info = { .name = TYPE_MILKYMIST_TMU2, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(MilkymistTMU2State), + .instance_init = milkymist_tmu2_init, .class_init = milkymist_tmu2_class_init, };