From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXNxv-0001xE-1q for qemu-devel@nongnu.org; Fri, 26 Sep 2014 01:21:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XXNxm-0005a0-OB for qemu-devel@nongnu.org; Fri, 26 Sep 2014 01:21:10 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:62789) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXNxm-0005ZX-JA for qemu-devel@nongnu.org; Fri, 26 Sep 2014 01:21:02 -0400 Received: by mail-pd0-f182.google.com with SMTP id y10so320547pdj.13 for ; Thu, 25 Sep 2014 22:20:57 -0700 (PDT) Sender: Peter Crosthwaite From: Peter Crosthwaite Date: Thu, 25 Sep 2014 22:20:25 -0700 Message-Id: <49bd5a0a38ec4aed5248f5cf7afb47ee9ec722ab.1411703316.git.peter.crosthwaite@xilinx.com> In-Reply-To: References: Subject: [Qemu-devel] [PATCH qom v3 07/14] qdev: gpio: Re-impement qdev_connect_gpio QOM style List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, pbonzini@redhat.com, agraf@suse.de, afaerber@suse.de 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 --- hw/core/qdev.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 2b42d5b..2cadacd 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -403,10 +403,14 @@ 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) { + 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) -- 2.1.0.1.g27b9230