summaryrefslogtreecommitdiffstats
path: root/hw/core/qdev.c
diff options
context:
space:
mode:
authorPeter Crosthwaite2014-09-26 07:18:14 +0200
committerAndreas Färber2014-10-13 16:39:27 +0200
commit688b057aece53003f9d5a1dadc8961482dc2d948 (patch)
treebdfe7bcd7fa3b54764acedb4bf11cf5cab388af5 /hw/core/qdev.c
parentqdev: gpio: Register GPIO inputs as child objects (diff)
downloadqemu-688b057aece53003f9d5a1dadc8961482dc2d948.tar.gz
qemu-688b057aece53003f9d5a1dadc8961482dc2d948.tar.xz
qemu-688b057aece53003f9d5a1dadc8961482dc2d948.zip
qdev: gpio: Register GPIO outputs as QOM links
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 <agraf@suse.de> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/core/qdev.c')
-rw-r--r--hw/core/qdev.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index a140c79757..2b42d5b58c 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)