From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ymr2e-00028J-Fq for qemu-devel@nongnu.org; Mon, 27 Apr 2015 17:58:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ymr2W-0003BM-Et for qemu-devel@nongnu.org; Mon, 27 Apr 2015 17:58:16 -0400 Received: from mail-bn1bon0094.outbound.protection.outlook.com ([157.56.111.94]:22464 helo=na01-bn1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ymr2W-0003B6-9b for qemu-devel@nongnu.org; Mon, 27 Apr 2015 17:58:08 -0400 From: Peter Crosthwaite Date: Mon, 27 Apr 2015 14:58:04 -0700 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [RFC PATCH v5 10/14] qdev: Define qdev_get_gpio_out List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, zachp@xilinx.com, jues@xilinx.com, edgari@xilinx.com, kraxel@redhat.com, edgar.iglesias@gmail.com An API similar to the existing qdev_get_gpio_in() except gets outputs. Useful for: 1: Implementing lightweight devices that don't want to keep pointers to their own GPIOs. They can get their GPIO pointers at runtime from QOM using this API. 2: testing or debugging code which may wish to override the hardware generated value of of a GPIO with a user specified value (E.G. interrupt injection). Signed-off-by: Peter Crosthwaite --- hw/core/qdev.c | 12 ++++++++++++ include/hw/qdev-core.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 6e6a65d..d736613 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -490,6 +490,18 @@ qemu_irq qdev_get_gpio_in(DeviceState *dev, int n) return qdev_get_gpio_in_named(dev, NULL, n); } +qemu_irq qdev_get_gpio_out_named(DeviceState *dev, const char *name, int n) +{ + char *propname = g_strdup_printf("%s[%d]", + name ? name : "unnamed-gpio-out", n); + return (qemu_irq)object_property_get_link(OBJECT(dev), propname, NULL); +} + +qemu_irq qdev_get_gpio_out(DeviceState *dev, int n) +{ + return qdev_get_gpio_out_named(dev, NULL, n); +} + void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n, qemu_irq pin) { diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 4e673f9..95f7f0e 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -274,6 +274,8 @@ bool qdev_machine_modified(void); qemu_irq qdev_get_gpio_in(DeviceState *dev, int n); qemu_irq qdev_get_gpio_in_named(DeviceState *dev, const char *name, int n); +qemu_irq qdev_get_gpio_out(DeviceState *dev, int n); +qemu_irq qdev_get_gpio_out_named(DeviceState *dev, const char *name, int n); void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin); void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n, -- 2.3.6.3.g2cc70ee