From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Alberto Garcia" <berto@igalia.com>,
"Bernhard Beschow" <shentey@gmail.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v3 1/3] hw/irq: Introduce qemu_init_irqs() helper
Date: Tue, 21 Jan 2025 16:55:24 +0100 [thread overview]
Message-ID: <20250121155526.29982-2-philmd@linaro.org> (raw)
In-Reply-To: <20250121155526.29982-1-philmd@linaro.org>
While qemu_init_irq() initialize a single IRQ,
qemu_init_irqs() initialize an array of them.
Suggested-by: Bernhard Beschow <shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/irq.h | 11 +++++++++++
hw/core/irq.c | 8 ++++++++
2 files changed, 19 insertions(+)
diff --git a/include/hw/irq.h b/include/hw/irq.h
index c861c1debda..b3012237acd 100644
--- a/include/hw/irq.h
+++ b/include/hw/irq.h
@@ -41,6 +41,17 @@ static inline void qemu_irq_pulse(qemu_irq irq)
void qemu_init_irq(IRQState *irq, qemu_irq_handler handler, void *opaque,
int n);
+/**
+ * qemu_init_irqs: Initialize an array of IRQs.
+ *
+ * @irq: Array of IRQs to initialize
+ * @count: number of IRQs to initialize
+ * @handler: handler to assign to each IRQ
+ * @opaque: opaque data to pass to @handler
+ */
+void qemu_init_irqs(IRQState irq[], size_t count,
+ qemu_irq_handler handler, void *opaque);
+
/* Returns an array of N IRQs. Each IRQ is assigned the argument handler and
* opaque data.
*/
diff --git a/hw/core/irq.c b/hw/core/irq.c
index 7d5b0038c12..6dd8d47bd6e 100644
--- a/hw/core/irq.c
+++ b/hw/core/irq.c
@@ -49,6 +49,14 @@ void qemu_init_irq(IRQState *irq, qemu_irq_handler handler, void *opaque,
init_irq_fields(irq, handler, opaque, n);
}
+void qemu_init_irqs(IRQState irq[], size_t count,
+ qemu_irq_handler handler, void *opaque)
+{
+ for (size_t i = 0; i < count; i++) {
+ qemu_init_irq(&irq[i], handler, opaque, i);
+ }
+}
+
qemu_irq *qemu_extend_irqs(qemu_irq *old, int n_old, qemu_irq_handler handler,
void *opaque, int n)
{
--
2.47.1
next prev parent reply other threads:[~2025-01-21 15:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-21 15:55 [PATCH v3 0/3] hw/ipack: Minor dust removal Philippe Mathieu-Daudé
2025-01-21 15:55 ` Philippe Mathieu-Daudé [this message]
2025-01-21 23:02 ` [PATCH v3 1/3] hw/irq: Introduce qemu_init_irqs() helper Richard Henderson
2025-01-21 15:55 ` [PATCH v3 2/3] hw/ipack: Clarify KConfig symbols Philippe Mathieu-Daudé
2025-01-22 7:02 ` Philippe Mathieu-Daudé
2025-01-21 15:55 ` [PATCH v3 3/3] hw/ipack: Remove legacy qemu_allocate_irqs() use Philippe Mathieu-Daudé
2025-01-21 23:03 ` Richard Henderson
2025-01-30 21:47 ` [PATCH v3 0/3] hw/ipack: Minor dust removal Philippe Mathieu-Daudé
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=20250121155526.29982-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=berto@igalia.com \
--cc=qemu-devel@nongnu.org \
--cc=shentey@gmail.com \
/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).