[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 07/28] qdev: gpio: Re-implement qdev_connect_gpio QOM
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 07/28] qdev: gpio: Re-implement qdev_connect_gpio QOM style |
Date: |
Mon, 27 Oct 2014 16:13:24 +0100 |
From: Peter Crosthwaite <address@hidden>
Re-implement as a link setter. This should allow the QOM framework to
keep track of ref counts properly etc.
We need to add a default parent for the connecting input incase it's
coming from a non-qdev source. We simply parent the IRQ to the machine
in this case.
Reviewed-by: Alexander Graf <address@hidden>
Signed-off-by: Peter Crosthwaite <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/core/qdev.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index a1e9247..fc7860f 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -440,10 +440,19 @@ qemu_irq qdev_get_gpio_in(DeviceState *dev, int n)
void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n,
qemu_irq pin)
{
- NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name);
-
- assert(n >= 0 && n < gpio_list->num_out);
- gpio_list->out[n] = pin;
+ char *propname = g_strdup_printf("%s[%d]",
+ name ? name : "unnamed-gpio-out", n);
+ if (pin) {
+ /* We need a name for object_property_set_link to work. If the
+ * object has a parent, object_property_add_child will come back
+ * with an error without doing anything. If it has none, it will
+ * never fail. So we can just call it with a NULL Error pointer.
+ */
+ object_property_add_child(qdev_get_machine(), "non-qdev-gpio[*]",
+ OBJECT(pin), NULL);
+ }
+ object_property_set_link(OBJECT(dev), OBJECT(pin), propname, &error_abort);
+ g_free(propname);
}
void qdev_connect_gpio_out(DeviceState * dev, int n, qemu_irq pin)
--
1.8.3.1
- [Qemu-devel] [PULL 00/28] Changes for 2014-10-27, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 06/28] qom: Demote already-has-a-parent to a regular error, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 07/28] qdev: gpio: Re-implement qdev_connect_gpio QOM style,
Paolo Bonzini <=
- [Qemu-devel] [PULL 02/28] virtio-scsi: dataplane: print why starting failed, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 04/28] virtio-scsi: dataplane: stop trying on notifier error, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 01/28] virtio-scsi-dataplane: Add op blocker, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 05/28] qom: Allow clearing of a Link property, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 09/28] qtest/irq: Rework IRQ interception, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 03/28] virtio-scsi: dataplane: fail setup gracefully, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 10/28] irq: Remove qemu_irq_intercept_out, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 08/28] qdev: gpio: Add API for intercepting a GPIO, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 11/28] qdev: gpio: delete NamedGPIOList::out, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 12/28] qdev: gpio: Remove qdev_init_gpio_out x1 restriction, Paolo Bonzini, 2014/10/27