From patchwork Fri Oct 17 16:24:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 400578 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B5AE41400D6 for ; Sat, 18 Oct 2014 03:30:07 +1100 (AEDT) Received: from localhost ([::1]:33444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XfAPl-0002ds-Gd for incoming@patchwork.ozlabs.org; Fri, 17 Oct 2014 12:30:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XfAL8-0003Iw-6b for qemu-devel@nongnu.org; Fri, 17 Oct 2014 12:25:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XfAL3-0004bY-6R for qemu-devel@nongnu.org; Fri, 17 Oct 2014 12:25:18 -0400 Received: from mail-wg0-x22f.google.com ([2a00:1450:400c:c00::22f]:50611) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XfAL3-0004bJ-0F for qemu-devel@nongnu.org; Fri, 17 Oct 2014 12:25:13 -0400 Received: by mail-wg0-f47.google.com with SMTP id x13so1277813wgg.6 for ; Fri, 17 Oct 2014 09:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=st5OaDv8gVIZiwLvyAWm73j2GiDVhOpNbEnV7gnuzxM=; b=IrnSKZaoFXCziApcHepk+jQVzQItAj6kXlXh1C5rKRJPW/mb0zdXZnP/lQstqu9FDZ BYHDNf9izfoLkm8XQs3S9GVFp9u/mygONiXexGg3HtYVWo/93Ky+LTcXlG+Pb6buHeDa T8m99Us92/LT9B8NUxGvgx/gV0Va1QD0JEkoBxeEuVWjfgyeZnOOxcSCUOviqnJBB+y2 kw871yyxVv1boAjJHHmLL14gy5ixHQE1AnL7TPnWZKcntKP8CdwhbdYYVoyZ9asusc5r PTml3RDuMfTvhibnWVVAerf9u+3MYE85zIyV1x9WyiI7ap01xDmF3Y44lYcRJfdId8LD snGQ== X-Received: by 10.194.7.105 with SMTP id i9mr5072135wja.116.1413563112174; Fri, 17 Oct 2014 09:25:12 -0700 (PDT) Received: from yakj.usersys.redhat.com.com ([62.156.150.204]) by mx.google.com with ESMTPSA id h4sm2230141wjb.9.2014.10.17.09.25.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Oct 2014 09:25:11 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 17 Oct 2014 18:24:48 +0200 Message-Id: <1413563095-27301-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1413563095-27301-1-git-send-email-pbonzini@redhat.com> References: <1413563095-27301-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c00::22f Cc: Peter Crosthwaite , afaerber@suse.de, agraf@suse.de Subject: [Qemu-devel] [PATCH qom v4 06/13] qdev: gpio: Re-implement qdev_connect_gpio QOM style 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Crosthwaite Re-implement as a link setter. This should allow the QOM framework to keep track of ref counts properly etc. We need to add a default parent for the connecting input incase it's coming from a non-qdev source. We simply parent the IRQ to the machine in this case. Reviewed-by: Alexander Graf Signed-off-by: Peter Crosthwaite Signed-off-by: Paolo Bonzini --- v3->v4: add a comment --- hw/core/qdev.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 2b42d5b..121a40b 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -403,10 +403,19 @@ qemu_irq qdev_get_gpio_in(DeviceState *dev, int n) void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n, qemu_irq pin) { - NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name); - - assert(n >= 0 && n < gpio_list->num_out); - gpio_list->out[n] = pin; + char *propname = g_strdup_printf("%s[%d]", + name ? name : "unnamed-gpio-out", n); + if (pin) { + /* We need a name for object_property_set_link to work. If the + * object has a parent, object_property_add_child will come back + * with an error without doing anything. If it has none, it will + * never fail. So we can just call it with a NULL Error pointer. + */ + object_property_add_child(qdev_get_machine(), "non-qdev-gpio[*]", + OBJECT(pin), NULL); + } + object_property_set_link(OBJECT(dev), OBJECT(pin), propname, &error_abort); + g_free(propname); } void qdev_connect_gpio_out(DeviceState * dev, int n, qemu_irq pin)