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 03/13] qdev: gpio: Register GPIO outputs as QOM links
Date: Fri, 17 Oct 2014 18:24:45 +0200 [thread overview]
Message-ID: <1413563095-27301-4-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>
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: Paolo Bonzini <pbonzini@redhat.com>
---
hw/core/qdev.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index a140c79..2b42d5b 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)
--
2.1.0
next prev 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 ` Paolo Bonzini [this message]
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 ` [Qemu-devel] [PATCH qom v4 06/13] qdev: gpio: Re-implement qdev_connect_gpio QOM style Paolo Bonzini
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-4-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).