qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	BALATON Zoltan <balaton@eik.bme.hu>
Subject: [PULL 03/18] hw: Move declaration of IRQState to header and add init function
Date: Wed, 11 Sep 2024 09:51:32 -0400	[thread overview]
Message-ID: <e72a7f65c11565d2f216711588a4e767a1f6cd80.1726062663.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1726062663.git.mst@redhat.com>

From: BALATON Zoltan <balaton@eik.bme.hu>

To allow embedding a qemu_irq in a struct move its definition to the
header and add a function to init it in place without allocating it.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Message-Id: <e3ffd0f6ef8845d0f7247c9b6ff33f7ee8b432cf.1719690591.git.balaton@eik.bme.hu>
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 include/hw/irq.h | 18 ++++++++++++++++++
 hw/core/irq.c    | 25 +++++++++++--------------
 2 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/include/hw/irq.h b/include/hw/irq.h
index 645b73d251..c861c1debd 100644
--- a/include/hw/irq.h
+++ b/include/hw/irq.h
@@ -1,9 +1,20 @@
 #ifndef QEMU_IRQ_H
 #define QEMU_IRQ_H
 
+#include "qom/object.h"
+
 /* Generic IRQ/GPIO pin infrastructure.  */
 
 #define TYPE_IRQ "irq"
+OBJECT_DECLARE_SIMPLE_TYPE(IRQState, IRQ)
+
+struct IRQState {
+    Object parent_obj;
+
+    qemu_irq_handler handler;
+    void *opaque;
+    int n;
+};
 
 void qemu_set_irq(qemu_irq irq, int level);
 
@@ -23,6 +34,13 @@ static inline void qemu_irq_pulse(qemu_irq irq)
     qemu_set_irq(irq, 0);
 }
 
+/*
+ * Init a single IRQ. The irq is assigned with a handler, an opaque data
+ * and the interrupt number.
+ */
+void qemu_init_irq(IRQState *irq, qemu_irq_handler handler, void *opaque,
+                   int n);
+
 /* 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 3f14e2dda7..db95ffc18f 100644
--- a/hw/core/irq.c
+++ b/hw/core/irq.c
@@ -26,16 +26,6 @@
 #include "hw/irq.h"
 #include "qom/object.h"
 
-OBJECT_DECLARE_SIMPLE_TYPE(IRQState, IRQ)
-
-struct IRQState {
-    Object parent_obj;
-
-    qemu_irq_handler handler;
-    void *opaque;
-    int n;
-};
-
 void qemu_set_irq(qemu_irq irq, int level)
 {
     if (!irq)
@@ -44,6 +34,15 @@ void qemu_set_irq(qemu_irq irq, int level)
     irq->handler(irq->opaque, irq->n, level);
 }
 
+void qemu_init_irq(IRQState *irq, qemu_irq_handler handler, void *opaque,
+                   int n)
+{
+    object_initialize(irq, sizeof(*irq), TYPE_IRQ);
+    irq->handler = handler;
+    irq->opaque = opaque;
+    irq->n = n;
+}
+
 qemu_irq *qemu_extend_irqs(qemu_irq *old, int n_old, qemu_irq_handler handler,
                            void *opaque, int n)
 {
@@ -69,10 +68,8 @@ qemu_irq qemu_allocate_irq(qemu_irq_handler handler, void *opaque, int n)
 {
     IRQState *irq;
 
-    irq = IRQ(object_new(TYPE_IRQ));
-    irq->handler = handler;
-    irq->opaque = opaque;
-    irq->n = n;
+    irq = g_new(IRQState, 1);
+    qemu_init_irq(irq, handler, opaque, n);
 
     return irq;
 }
-- 
MST



  parent reply	other threads:[~2024-09-11 15:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-11 13:51 [PULL 00/18] virtio,pc,pci: features, fixes, cleanups Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 01/18] virtio: Allow .get_vhost() without vhost_started Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 02/18] virtio: Always reset vhost devices Michael S. Tsirkin
2024-09-11 13:51 ` Michael S. Tsirkin [this message]
2024-09-11 13:51 ` [PULL 04/18] hw/isa/vt82c686.c: Embed i8259 irq in device state instead of allocating Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 05/18] pci: don't skip function 0 occupancy verification for devfn auto assign Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 06/18] hw/pci/pci-hmp-cmds: Avoid displaying bogus size in 'info pci' Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 07/18] virtio: rename virtio_split_packed_update_used_idx Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 08/18] intel_iommu: Fix invalidation descriptor type field Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 09/18] intel_iommu: Make PASID-cache and PIOTLB type invalid in legacy mode Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 10/18] tests/acpi: pc: allow DSDT acpi table changes Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 11/18] hw/i386/acpi-build: Return a pre-computed _PRT table Michael S. Tsirkin
2024-09-11 13:52 ` [PULL 12/18] tests/acpi: pc: update golden masters for DSDT Michael S. Tsirkin
2024-09-11 13:52 ` [PULL 13/18] vhost_net: configure all host notifiers in a single MR transaction Michael S. Tsirkin
2024-09-11 13:52 ` [PULL 14/18] virtio-pci: Add lookup subregion of VirtIOPCIRegion MR Michael S. Tsirkin
2024-09-17 20:19   ` Peter Xu
2024-09-11 13:52 ` [PULL 15/18] hw/cxl: fix physical address field in get scan media results output Michael S. Tsirkin
2024-09-11 13:52 ` [PULL 16/18] hw/audio/virtio-sound: fix heap buffer overflow Michael S. Tsirkin
2024-09-13 18:47   ` Volker Rümelin
2024-09-11 13:52 ` [PULL 17/18] virtio-mem: don't warn about THP sizes on a kernel without THP support Michael S. Tsirkin
2024-09-11 13:52 ` [PULL 18/18] hw/acpi/ich9: Add periodic and swsmi timer Michael S. Tsirkin
2024-09-13  9:24 ` [PULL 00/18] virtio,pc,pci: features, fixes, cleanups Peter Maydell

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=e72a7f65c11565d2f216711588a4e767a1f6cd80.1726062663.git.mst@redhat.com \
    --to=mst@redhat.com \
    --cc=balaton@eik.bme.hu \
    --cc=peter.maydell@linaro.org \
    --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).