From patchwork Mon Feb 27 19:38:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 9593823 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 726A5601D7 for ; Mon, 27 Feb 2017 19:39:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D77F284C9 for ; Mon, 27 Feb 2017 19:39:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50DF0284CF; Mon, 27 Feb 2017 19:39:41 +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.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, URIBL_RED 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 40DC0284C9 for ; Mon, 27 Feb 2017 19:39:40 +0000 (UTC) Received: from localhost ([::1]:56305 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciR91-0001ZH-Dj for patchwork-qemu-devel@patchwork.kernel.org; Mon, 27 Feb 2017 14:39:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48859) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciR8Z-0001Xx-Fb for qemu-devel@nongnu.org; Mon, 27 Feb 2017 14:39:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciR8V-0002Tf-1g for qemu-devel@nongnu.org; Mon, 27 Feb 2017 14:39:11 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:43599) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciR8U-0002SE-Qo for qemu-devel@nongnu.org; Mon, 27 Feb 2017 14:39:06 -0500 Received: from mail.nefkom.net (unknown [192.168.6.184]) by mail-out.m-online.net (Postfix) with ESMTP id 3vXBps5f5Yz3hjrF; Mon, 27 Feb 2017 20:39:01 +0100 (CET) X-Auth-Info: QfEFftiyOIrMuGyPVda1XS4jAQZldx6FYODzw1STBD0= Received: from kurokawa.lan (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA id 3vXBpr4Rc7zvdWQ; Mon, 27 Feb 2017 20:39:00 +0100 (CET) From: Marek Vasut To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 20:38:57 +0100 Message-Id: <20170227193857.9368-1-marex@denx.de> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 212.18.0.9 Subject: [Qemu-devel] [PATCH V2] nios2: iic: Convert CPU prop to qom link 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: Marek Vasut , Jeff Da Silva , Chris Wulff , Alexander Graf , Markus Armbruster , Sandra Loosemore , Ley Foon Tan , Yves Vandervennet , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a const qom link between the CPU and the IIC instead of passing the CPU link through a qom property. Signed-off-by: Marek Vasut Cc: Alexander Graf Cc: Chris Wulff Cc: Igor Mammedov Cc: Jeff Da Silva Cc: Ley Foon Tan Cc: Markus Armbruster Cc: Richard Henderson Cc: Sandra Loosemore Cc: Yves Vandervennet Reviewed-by: Markus Armbruster --- V2: Retain dc->cannot_instantiate_with_device_add_yet = true in altera_iic_class_init() since the device is still not device_add() creatable. --- hw/intc/nios2_iic.c | 12 ++++-------- hw/nios2/10m50_devboard.c | 3 ++- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/hw/intc/nios2_iic.c b/hw/intc/nios2_iic.c index 818ab1b315..fe15621202 100644 --- a/hw/intc/nios2_iic.c +++ b/hw/intc/nios2_iic.c @@ -62,17 +62,15 @@ static void altera_iic_init(Object *obj) sysbus_init_irq(SYS_BUS_DEVICE(obj), &pv->parent_irq); } -static Property altera_iic_properties[] = { - DEFINE_PROP_PTR("cpu", AlteraIIC, cpu), - DEFINE_PROP_END_OF_LIST(), -}; - static void altera_iic_realize(DeviceState *dev, Error **errp) { struct AlteraIIC *pv = ALTERA_IIC(dev); + Error *err = NULL; + pv->cpu = object_property_get_link(OBJECT(dev), "cpu", &err); if (!pv->cpu) { - error_setg(errp, "altera,iic: CPU not connected"); + error_setg(errp, "altera,iic: CPU link not found: %s", + error_get_pretty(err)); return; } } @@ -81,8 +79,6 @@ static void altera_iic_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - dc->props = altera_iic_properties; - /* Reason: pointer property "cpu" */ dc->cannot_instantiate_with_device_add_yet = true; dc->realize = altera_iic_realize; } diff --git a/hw/nios2/10m50_devboard.c b/hw/nios2/10m50_devboard.c index 0d8b9aa58f..c18e0b2a17 100644 --- a/hw/nios2/10m50_devboard.c +++ b/hw/nios2/10m50_devboard.c @@ -83,7 +83,8 @@ static void nios2_10m50_ghrd_init(MachineState *machine) /* Register: Internal Interrupt Controller (IIC) */ dev = qdev_create(NULL, "altera,iic"); - qdev_prop_set_ptr(dev, "cpu", cpu); + object_property_add_const_link(OBJECT(dev), "cpu", OBJECT(cpu), + &error_abort); qdev_init_nofail(dev); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, cpu_irq[0]); for (i = 0; i < 32; i++) {