qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC v1 13/25] qdev: gpio: Register GPIO inputs as child ob


From: Peter Crosthwaite
Subject: [Qemu-devel] [RFC v1 13/25] qdev: gpio: Register GPIO inputs as child objects
Date: Thu, 15 May 2014 18:57:22 -0700

To the device that contains them. This will allow for referencing
a GPIO input from its canonical path (exciting for dynamic machine
generation!)

Signed-off-by: Peter Crosthwaite <address@hidden>
---

 hw/core/qdev.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 3330838..cd273e8 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -336,11 +336,21 @@ static NamedGPIOList 
*qdev_get_named_gpio_list(DeviceState *dev,
 void qdev_init_gpio_in_named(DeviceState *dev, qemu_irq_handler handler,
                              const char *name, int n)
 {
+    int i;
     NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name);
 
     assert(gpio_list->num_out == 0 || !name);
     gpio_list->in = qemu_extend_irqs(gpio_list->in, gpio_list->num_in, handler,
                                      dev, n);
+
+    for (i = gpio_list->num_in; i < gpio_list->num_in + n; i++) {
+        char *propname = g_strdup_printf("%s-%d",
+                                         name ? name : "unnamed-gpio-in", i);
+        object_property_add_child(OBJECT(dev), propname,
+                                  OBJECT(gpio_list->in[i]), &error_abort);
+        g_free(propname);
+    }
+
     gpio_list->num_in += n;
 }
 
-- 
1.9.3.1.ga73a6ad




reply via email to

[Prev in Thread] Current Thread [Next in Thread]