From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeExu-0005xi-4t for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:09:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XeExn-0004fQ-Qn for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:09:30 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49294 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeExn-0004eU-KR for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:09:23 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 15 Oct 2014 05:08:37 +0200 Message-Id: <1413342561-4754-4-git-send-email-afaerber@suse.de> In-Reply-To: <1413342561-4754-1-git-send-email-afaerber@suse.de> References: <1413342561-4754-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 03/47] 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 , =?UTF-8?q?Andreas=20F=C3=A4rber?= 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: Andreas F=C3=A4rber --- 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_h= andler handler, int n) void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins, const char *name, int n) { + int i; NamedGPIOList *gpio_list =3D qdev_get_named_gpio_list(dev, name); + char *propname =3D g_strdup_printf("%s[*]", name ? name : "unnamed-g= pio-out"); =20 assert(gpio_list->num_in =3D=3D 0 || !name); assert(gpio_list->num_out =3D=3D 0); gpio_list->num_out =3D n; gpio_list->out =3D pins; + + for (i =3D 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); } =20 void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n) --=20 1.8.4.5