From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XfAL7-0003Io-1t for qemu-devel@nongnu.org; Fri, 17 Oct 2014 12:25:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XfAKy-0004ZW-RB for qemu-devel@nongnu.org; Fri, 17 Oct 2014 12:25:17 -0400 Received: from mail-wg0-x22e.google.com ([2a00:1450:400c:c00::22e]:51219) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XfAKy-0004Z6-KC for qemu-devel@nongnu.org; Fri, 17 Oct 2014 12:25:08 -0400 Received: by mail-wg0-f46.google.com with SMTP id l18so1286709wgh.17 for ; Fri, 17 Oct 2014 09:25:07 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 17 Oct 2014 18:24:45 +0200 Message-Id: <1413563095-27301-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1413563095-27301-1-git-send-email-pbonzini@redhat.com> References: <1413563095-27301-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH qom v4 03/13] qdev: gpio: Register GPIO outputs as QOM links List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Crosthwaite , afaerber@suse.de, agraf@suse.de From: Peter Crosthwaite Within the object that contains the GPIO output. This allows for connecting GPIO outputs via setting of a Link property. Also clear the link value to zero. This catch-alls the case where a device improperly inits a gpio_out (malloc instead of malloc0). Reviewed-by: Alexander Graf Signed-off-by: Peter Crosthwaite Signed-off-by: Paolo Bonzini --- hw/core/qdev.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index a140c79..2b42d5b 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -362,12 +362,24 @@ void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n) void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins, const char *name, int n) { + int i; NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name); + char *propname = g_strdup_printf("%s[*]", name ? name : "unnamed-gpio-out"); assert(gpio_list->num_in == 0 || !name); assert(gpio_list->num_out == 0); gpio_list->num_out = n; gpio_list->out = pins; + + for (i = 0; i < n; ++i) { + memset(&pins[i], 0, sizeof(*pins)); + object_property_add_link(OBJECT(dev), propname, TYPE_IRQ, + (Object **)&pins[i], + object_property_allow_set_link, + OBJ_PROP_LINK_UNREF_ON_RELEASE, + &error_abort); + } + g_free(propname); } void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n) -- 2.1.0