hw: Use the PCI_SLOT() macro from 'hw/pci/pci.h'
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>
Sun, 11 Oct 2020 15:04:23 +0000 (17:04 +0200)
committerPhilippe Mathieu-Daudé <f4bug@amsat.org>
Mon, 4 Jan 2021 22:24:44 +0000 (23:24 +0100)
We already have a generic PCI_SLOT() macro in "hw/pci/pci.h"
to extract the PCI slot identifier, use it.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: Paul Durrant <paul@xen.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20201012124506.3406909-5-philmd@redhat.com>

hw/hppa/dino.c
hw/i386/xen/xen-hvm.c
hw/isa/piix3.c
hw/mips/gt64xxx_pci.c
hw/pci-host/bonito.c
hw/pci-host/ppce500.c
hw/ppc/ppc4xx_pci.c
hw/sh4/sh_pci.c

index 81053b5fb647b1dedeabc47cd5b1c89f331377d6..5b82c9440d1d59307e3964d3e8727af10377fb8e 100644 (file)
@@ -496,7 +496,7 @@ static void dino_set_irq(void *opaque, int irq, int level)
 
 static int dino_pci_map_irq(PCIDevice *d, int irq_num)
 {
-    int slot = d->devfn >> 3;
+    int slot = PCI_SLOT(d->devfn);
 
     assert(irq_num >= 0 && irq_num <= 3);
 
index 096c46fef15166cf43993696864c0c8015bc5b27..68821d90f52c6c7e1832c5420413217652dd332e 100644 (file)
@@ -140,7 +140,7 @@ typedef struct XenIOState {
 
 int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
 {
-    return irq_num + ((pci_dev->devfn >> 3) << 2);
+    return irq_num + (PCI_SLOT(pci_dev->devfn) << 2);
 }
 
 void xen_piix3_set_irq(void *opaque, int irq_num, int level)
index 587850b88817d32f09fbd231d4b2f6cf1bc06cce..f46ccae25cf7360fc2b51e57ea0e5fd45d06ac7c 100644 (file)
@@ -361,7 +361,7 @@ type_init(piix3_register_types)
 static int pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx)
 {
     int slot_addend;
-    slot_addend = (pci_dev->devfn >> 3) - 1;
+    slot_addend = PCI_SLOT(pci_dev->devfn) - 1;
     return (pci_intx + slot_addend) & 3;
 }
 
index e091bc4ed55fbba6caf9be04c6ba78ee2d8306ea..588e6f993017d1d2804634858ae5752252bda85b 100644 (file)
@@ -982,7 +982,7 @@ static int gt64120_pci_map_irq(PCIDevice *pci_dev, int irq_num)
 {
     int slot;
 
-    slot = (pci_dev->devfn >> 3);
+    slot = PCI_SLOT(pci_dev->devfn);
 
     switch (slot) {
     /* PIIX4 USB */
index b05295639a670b5a2a252188853baf31537ccbb3..ee8b193e15b10eec3aec7436068a52b724fda2d0 100644 (file)
@@ -570,7 +570,7 @@ static int pci_bonito_map_irq(PCIDevice *pci_dev, int irq_num)
 {
     int slot;
 
-    slot = (pci_dev->devfn >> 3);
+    slot = PCI_SLOT(pci_dev->devfn);
 
     switch (slot) {
     case 5:   /* FULOONG2E_VIA_SLOT, SouthBridge, IDE, USB, ACPI, AC97, MC97 */
index 9517aab913e23795e73baebbc589d0eb244653d6..5ad1424b31a43547ce71004d02d19c0e4a92839a 100644 (file)
@@ -342,7 +342,7 @@ static const MemoryRegionOps e500_pci_reg_ops = {
 
 static int mpc85xx_pci_map_irq(PCIDevice *pci_dev, int pin)
 {
-    int devno = pci_dev->devfn >> 3;
+    int devno = PCI_SLOT(pci_dev->devfn);
     int ret;
 
     ret = ppce500_pci_map_irq_slot(devno, pin);
index 28724c06f8822933472c4d55081d49a54119fb6a..e8789f64e80069288b092b66a6de9ff282be7e5c 100644 (file)
@@ -243,7 +243,7 @@ static void ppc4xx_pci_reset(void *opaque)
  * may need further refactoring for other boards. */
 static int ppc4xx_pci_map_irq(PCIDevice *pci_dev, int irq_num)
 {
-    int slot = pci_dev->devfn >> 3;
+    int slot = PCI_SLOT(pci_dev->devfn);
 
     trace_ppc4xx_pci_map_irq(pci_dev->devfn, irq_num, slot);
 
index 73d2d0bccb0e6ad067c091c02ed96562ee97de33..734892f47c7d7567cee0226a0dbfdc36e8226ff8 100644 (file)
@@ -109,7 +109,7 @@ static const MemoryRegionOps sh_pci_reg_ops = {
 
 static int sh_pci_map_irq(PCIDevice *d, int irq_num)
 {
-    return (d->devfn >> 3);
+    return PCI_SLOT(d->devfn);
 }
 
 static void sh_pci_set_irq(void *opaque, int irq_num, int level)