diff mbox

[1/4] pci: rearrange code for interrupts

Message ID 20091125165846.GB24783@redhat.com
State New
Headers show

Commit Message

Michael S. Tsirkin Nov. 25, 2009, 4:58 p.m. UTC
Rearranges code slightly in preparation
for interrupt status and interrupt
disable support: split actual irq change
from irq_state management.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/pci.c |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/hw/pci.c b/hw/pci.c
index 0359f30..5ff0d46 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -880,18 +880,9 @@  void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l)
 /***********************************************************/
 /* generic PCI irq support */
 
-/* 0 <= irq_num <= 3. level must be 0 or 1 */
-static void pci_set_irq(void *opaque, int irq_num, int level)
+static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change)
 {
-    PCIDevice *pci_dev = opaque;
     PCIBus *bus;
-    int change;
-
-    change = level - pci_dev->irq_state[irq_num];
-    if (!change)
-        return;
-
-    pci_dev->irq_state[irq_num] = level;
     for (;;) {
         bus = pci_dev->bus;
         irq_num = bus->map_irq(pci_dev, irq_num);
@@ -903,6 +894,21 @@  static void pci_set_irq(void *opaque, int irq_num, int level)
     bus->set_irq(bus->irq_opaque, irq_num, bus->irq_count[irq_num] != 0);
 }
 
+
+/* 0 <= irq_num <= 3. level must be 0 or 1 */
+static void pci_set_irq(void *opaque, int irq_num, int level)
+{
+    PCIDevice *pci_dev = opaque;
+    int change;
+
+    change = level - pci_dev->irq_state[irq_num];
+    if (!change)
+        return;
+
+    pci_dev->irq_state[irq_num] = level;
+    pci_change_irq_level(pci_dev, irq_num, change);
+}
+
 /***********************************************************/
 /* monitor info on PCI */