qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com>,
	afaerber@suse.de, agraf@suse.de
Subject: [Qemu-devel] [PATCH qom v4 06/13] qdev: gpio: Re-implement qdev_connect_gpio QOM style
Date: Fri, 17 Oct 2014 18:24:48 +0200	[thread overview]
Message-ID: <1413563095-27301-7-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1413563095-27301-1-git-send-email-pbonzini@redhat.com>

From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

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 <agraf@suse.de>
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
        v3->v4: add a comment
---
 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 2b42d5b..121a40b 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -403,10 +403,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)
-- 
2.1.0

  parent reply	other threads:[~2014-10-17 16:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-17 16:24 [Qemu-devel] [PATCH qom v4 00/13] GPIO/IRQ QOMification: Phase 2 - Getting rid of SYSBUS IRQs Paolo Bonzini
2014-10-17 16:24 ` [Qemu-devel] [PATCH qom v4 01/13] qdev: gpio: Don't allow name share between I and O Paolo Bonzini
2014-10-17 16:24 ` [Qemu-devel] [PATCH qom v4 02/13] qdev: gpio: Register GPIO inputs as child objects Paolo Bonzini
2014-10-17 16:24 ` [Qemu-devel] [PATCH qom v4 03/13] qdev: gpio: Register GPIO outputs as QOM links Paolo Bonzini
2014-10-17 16:24 ` [Qemu-devel] [PATCH qom v4 04/13] qom: Allow clearing of a Link property Paolo Bonzini
2014-10-17 16:24 ` [Qemu-devel] [PATCH qom v4 05/13] qom: Demote already-has-a-parent to a regular error Paolo Bonzini
2014-10-17 16:24 ` Paolo Bonzini [this message]
2014-10-17 16:24 ` [Qemu-devel] [PATCH qom v4 07/13] qdev: gpio: Add API for intercepting a GPIO Paolo Bonzini
2014-10-17 16:24 ` [Qemu-devel] [PATCH qom v4 08/13] qtest/irq: Rework IRQ interception Paolo Bonzini
2014-10-17 16:24 ` [Qemu-devel] [PATCH qom v4 09/13] irq: Remove qemu_irq_intercept_out Paolo Bonzini
2014-10-17 16:24 ` [Qemu-devel] [PATCH qom v4 10/13] qdev: gpio: delete NamedGPIOList::out Paolo Bonzini
2014-10-17 16:24 ` [Qemu-devel] [PATCH qom v4 11/13] qdev: gpio: Remove qdev_init_gpio_out x1 restriction Paolo Bonzini
2014-10-17 16:24 ` [Qemu-devel] [PATCH qom v4 12/13] qdev: gpio: Define qdev_pass_gpios() Paolo Bonzini
2014-10-17 16:24 ` [Qemu-devel] [PATCH qom v4 13/13] sysbus: Use TYPE_DEVICE GPIO functionality Paolo Bonzini
2014-10-20  0:46 ` [Qemu-devel] [PATCH qom v4 00/13] GPIO/IRQ QOMification: Phase 2 - Getting rid of SYSBUS IRQs Peter Crosthwaite

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1413563095-27301-7-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).