]> Git Repo - qemu.git/commitdiff
qdev: gpio: Register GPIO outputs as QOM links
authorPeter Crosthwaite <[email protected]>
Fri, 26 Sep 2014 05:18:14 +0000 (22:18 -0700)
committerAndreas Färber <[email protected]>
Mon, 13 Oct 2014 14:39:27 +0000 (16:39 +0200)
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 <[email protected]>
Signed-off-by: Peter Crosthwaite <[email protected]>
Signed-off-by: Andreas Färber <[email protected]>
hw/core/qdev.c

index a140c7975701ca8ac6b8a4d74ef7e5b0a1ef4e20..2b42d5b58c275eb166216729d08df8002b9fe64f 100644 (file)
@@ -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)
This page took 0.029592 seconds and 4 git commands to generate.