From patchwork Wed Mar 30 10:09:45 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: 8695241 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 C5EA99F39A for ; Wed, 30 Mar 2016 10:16:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1E59E2035D for ; Wed, 30 Mar 2016 10:16:46 +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 6D72A20279 for ; Wed, 30 Mar 2016 10:16:45 +0000 (UTC) Received: from localhost ([::1]:52970 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alDB6-0006AF-Pt for patchwork-qemu-devel@patchwork.kernel.org; Wed, 30 Mar 2016 06:16:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alD6u-0007OR-5c for qemu-devel@nongnu.org; Wed, 30 Mar 2016 06:12:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1alD6r-00068K-Fz for qemu-devel@nongnu.org; Wed, 30 Mar 2016 06:12:24 -0400 Received: from m12-12.163.com ([220.181.12.12]:41054) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alD6r-00064b-1V for qemu-devel@nongnu.org; Wed, 30 Mar 2016 06:12:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=oijHmlkE/td1B+0zrQ TXCEjxgpaT0pl8JlUwcKjKQMo=; b=JlietXUbQrhqIBOpsVD4zmvHKiFBxtMgG6 CODXzG3YtbCkUr2SF44AUetD8MJvPMMKP+UZHFSEwqi0G/826bGPHZXlCdaWm2uH qR5sGIGncqAa4nr1hT+6nGQGAaabYwWP3rkrQ9ZwQUHVQyoOPS5tCFl72q0AWxp4 5gJr+mKUU= Received: from localhost.localdomain (unknown [118.187.28.42]) by smtp8 (Coremail) with SMTP id DMCowAAnIV84pvtWicgFBw--.798S4; Wed, 30 Mar 2016 18:11:35 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Wed, 30 Mar 2016 18:09:45 +0800 Message-Id: <1459332586-13693-3-git-send-email-zxq_yx_007@163.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1459332586-13693-1-git-send-email-zxq_yx_007@163.com> References: <1459332586-13693-1-git-send-email-zxq_yx_007@163.com> X-CM-TRANSID: DMCowAAnIV84pvtWicgFBw--.798S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7tw45uw48Xw15WrW3XF1UZFb_yoW8KFWxpF n5GFs5Ar4kJa1xAF4xJFWDJa4UJwn3Kry8Jr4Sy392k3WrJryvvwsFyr98KF4YgFZ2vFy5 Jr1rtFy8KF45Kr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jLEf5UUUUU= X-Originating-IP: [118.187.28.42] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/1tbiMxc8xlXlfaf66AABsn X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.12 Cc: peter.maydell@linaro.org, i.mitsyanko@gmail.com, chouteau@adacore.com, michael@walle.cc, peter.chubb@nicta.com.au, edgar.iglesias@gmail.com Subject: [Qemu-devel] [PATCH 8/9] hw/intc: QOM'ify grlib_irqmp.c 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 the old SysBus init into an instance_init and a DeviceClass::realize function * Drop the old SysBus init function Signed-off-by: xiaoqiang zhao --- hw/intc/grlib_irqmp.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/hw/intc/grlib_irqmp.c b/hw/intc/grlib_irqmp.c index f5ca8f7..34c400e 100644 --- a/hw/intc/grlib_irqmp.c +++ b/hw/intc/grlib_irqmp.c @@ -31,6 +31,7 @@ #include "hw/sparc/grlib.h" #include "trace.h" +#include "qapi/error.h" #define IRQMP_MAX_CPU 16 #define IRQMP_REG_SIZE 256 /* Size of memory mapped registers */ @@ -323,23 +324,27 @@ static void grlib_irqmp_reset(DeviceState *d) irqmp->state->parent = irqmp; } -static int grlib_irqmp_init(SysBusDevice *dev) +static void grlib_irqmp_init(Object *obj) { - IRQMP *irqmp = GRLIB_IRQMP(dev); + IRQMP *irqmp = GRLIB_IRQMP(obj); + SysBusDevice *dev = SYS_BUS_DEVICE(obj); - /* Check parameters */ - if (irqmp->set_pil_in == NULL) { - return -1; - } - - memory_region_init_io(&irqmp->iomem, OBJECT(dev), &grlib_irqmp_ops, irqmp, + memory_region_init_io(&irqmp->iomem, obj, &grlib_irqmp_ops, irqmp, "irqmp", IRQMP_REG_SIZE); irqmp->state = g_malloc0(sizeof *irqmp->state); sysbus_init_mmio(dev, &irqmp->iomem); +} - return 0; +static void grlib_irqmp_realize(DeviceState *dev, Error **errp) +{ + IRQMP *irqmp = GRLIB_IRQMP(dev); + + /* Check parameters */ + if (irqmp->set_pil_in == NULL) { + error_setg(errp, "set_pil_in can not be NULL."); + } } static Property grlib_irqmp_properties[] = { @@ -351,19 +356,19 @@ static Property grlib_irqmp_properties[] = { static void grlib_irqmp_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = grlib_irqmp_init; dc->reset = grlib_irqmp_reset; dc->props = grlib_irqmp_properties; /* Reason: pointer properties "set_pil_in", "set_pil_in_opaque" */ dc->cannot_instantiate_with_device_add_yet = true; + dc->realize = grlib_irqmp_realize; } static const TypeInfo grlib_irqmp_info = { .name = TYPE_GRLIB_IRQMP, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(IRQMP), + .instance_init = grlib_irqmp_init, .class_init = grlib_irqmp_class_init, };