From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBKwA-0004xY-2Q for qemu-devel@nongnu.org; Fri, 10 Jun 2016 07:49:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bBKw8-0007Kd-3L for qemu-devel@nongnu.org; Fri, 10 Jun 2016 07:49:17 -0400 Received: from mail-vk0-x232.google.com ([2607:f8b0:400c:c05::232]:34779) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBKw7-0007KT-Lb for qemu-devel@nongnu.org; Fri, 10 Jun 2016 07:49:16 -0400 Received: by mail-vk0-x232.google.com with SMTP id e4so93921814vkb.1 for ; Fri, 10 Jun 2016 04:49:15 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Peter Maydell Date: Fri, 10 Jun 2016 12:48:55 +0100 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH v6 09/13] qdev: Define qdev_get_gpio_out List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alistair Francis Cc: QEMU Developers , Peter Crosthwaite , Edgar Iglesias , "Edgar E. Iglesias" , =?UTF-8?Q?Andreas_F=C3=A4rber?= , =?UTF-8?B?S09OUkFEIEZyw6lkw6lyaWM=?= , =?UTF-8?B?QWxleCBCZW5uw6ll?= On 12 May 2016 at 23:46, Alistair Francis wrote: > From: Peter Crosthwaite > > 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 > Signed-off-by: Alistair Francis > --- > > 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 db41aa1..e3015d2 100644 > --- a/hw/core/qdev.c > +++ b/hw/core/qdev.c > @@ -489,6 +489,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); > +} This appears to be identical to the existing function qdev_get_gpio_out_connector() ? > + > +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 1ce02b2..0e216af 100644 > --- a/include/hw/qdev-core.h > +++ b/include/hw/qdev-core.h > @@ -285,6 +285,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); Doc comments for new global functions would be nice. thanks -- PMM