Patchwork [34/40] PPC: E500: PCI: Make IRQ calculation more generic

login
register
mail settings
Submitter Alexander Graf
Date Dec. 14, 2012, 12:13 p.m.
Message ID <1355487236-27451-35-git-send-email-agraf@suse.de>
Download mbox | patch
Permalink /patch/206467/
State New
Headers show

Comments

Alexander Graf - Dec. 14, 2012, 12:13 p.m.
The IRQ line calculation is more or less hardcoded today. Instead, let's
write it as an algorithmic function that theoretically allows an arbitrary
number of PCI slots.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/ppce500_pci.c |   13 +++----------
 1 files changed, 3 insertions(+), 10 deletions(-)

Patch

diff --git a/hw/ppce500_pci.c b/hw/ppce500_pci.c
index 4cd4edc..561a776 100644
--- a/hw/ppce500_pci.c
+++ b/hw/ppce500_pci.c
@@ -253,17 +253,10 @@  static const MemoryRegionOps e500_pci_reg_ops = {
 
 static int mpc85xx_pci_map_irq(PCIDevice *pci_dev, int irq_num)
 {
-    int devno = pci_dev->devfn >> 3, ret = 0;
+    int devno = pci_dev->devfn >> 3;
+    int ret;
 
-    switch (devno) {
-        /* Two PCI slot */
-        case 0x11:
-        case 0x12:
-            ret = (irq_num + devno - 0x10) % 4;
-            break;
-        default:
-            printf("Error:%s:unknown dev number\n", __func__);
-    }
+    ret = (irq_num + devno) % 4;
 
     pci_debug("%s: devfn %x irq %d -> %d  devno:%x\n", __func__,
            pci_dev->devfn, irq_num, ret, devno);