From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XhIXG-0005fq-Od for qemu-devel@nongnu.org; Thu, 23 Oct 2014 09:34:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XhIXB-0007Lf-R6 for qemu-devel@nongnu.org; Thu, 23 Oct 2014 09:34:38 -0400 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]:54605) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XhIXB-0007LS-KF for qemu-devel@nongnu.org; Thu, 23 Oct 2014 09:34:33 -0400 Received: by mail-wi0-f176.google.com with SMTP id n3so3660680wiv.15 for ; Thu, 23 Oct 2014 06:34:32 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 23 Oct 2014 15:33:55 +0200 Message-Id: <1414071252-7003-8-git-send-email-pbonzini@redhat.com> In-Reply-To: <1414071252-7003-1-git-send-email-pbonzini@redhat.com> References: <1414071252-7003-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 07/24] qdev: gpio: Re-implement qdev_connect_gpio QOM style List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Crosthwaite 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 --- 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 a1e9247..fc7860f 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -440,10 +440,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) -- 1.8.3.1