diff mbox

[RFC,v5,12/23] isa: Allow to un-associate an IRQ

Message ID 1308019077-61957-13-git-send-email-andreas.faerber@web.de
State New
Headers show

Commit Message

Andreas Färber June 14, 2011, 2:37 a.m. UTC
ISADevices keep a list of numeric IRQs. Remove one from that list.
Also optionally NULL the qemu_irq, calling it "uninit" for symmetry.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 hw/isa-bus.c |   17 +++++++++++++++++
 hw/isa.h     |    1 +
 2 files changed, 18 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 6e33d80..d037ed3 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -80,6 +80,23 @@  void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq)
     dev->nirqs++;
 }
 
+void isa_uninit_irq(ISADevice *dev, qemu_irq *p, int isairq)
+{
+    int i, j;
+    for (i = 0; i < dev->nirqs; i++) {
+        if (dev->isairq[i] == isairq) {
+            for (j = i + 1; j < dev->nirqs; j++) {
+                dev->isairq[j - 1] = dev->isairq[j];
+            }
+            dev->nirqs--;
+            break;
+        }
+    }
+    if (p != NULL) {
+        *p = NULL;
+    }
+}
+
 static void isa_init_ioport_one(ISADevice *dev, uint16_t ioport)
 {
     assert(dev->nioports < ARRAY_SIZE(dev->ioports));
diff --git a/hw/isa.h b/hw/isa.h
index fe1a20c..72829bb 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -32,6 +32,7 @@  ISABus *isa_bus_new(DeviceState *dev);
 void isa_bus_irqs(qemu_irq *irqs);
 qemu_irq isa_get_irq(int isairq);
 void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
+void isa_uninit_irq(ISADevice *dev, qemu_irq *p, int isairq);
 void isa_init_ioport(ISADevice *dev, uint16_t ioport);
 void isa_init_ioport_range(ISADevice *dev, uint16_t start, uint16_t length);
 void isa_discard_ioport_range(ISADevice *dev, uint16_t start, uint16_t length);