hw: Use the PCI_DEVFN() macro from 'hw/pci/pci.h'
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>
Mon, 12 Oct 2020 06:36:41 +0000 (08:36 +0200)
committerPhilippe Mathieu-Daudé <f4bug@amsat.org>
Mon, 4 Jan 2021 22:24:44 +0000 (23:24 +0100)
We already have a generic PCI_DEVFN() macro in "hw/pci/pci.h"
to pack the PCI slot/function identifiers, use it.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <20201012124506.3406909-6-philmd@redhat.com>
Reviewed-by: Huacai Chen <chenhuacai@kernel.org>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20201231224911.1467352-4-f4bug@amsat.org>

hw/arm/virt.c
hw/pci-host/bonito.c
hw/pci-host/uninorth.c

index 96985917d3b23ca9c3c94d415dc2c205a77d56f8..bf3a717111879476c4e5a8d54b12c1377783758c 100644 (file)
@@ -1147,7 +1147,8 @@ static void create_pcie_irq_map(const VirtMachineState *vms,
                      full_irq_map, sizeof(full_irq_map));
 
     qemu_fdt_setprop_cells(vms->fdt, nodename, "interrupt-map-mask",
-                           0x1800, 0, 0, /* devfn (PCI_SLOT(3)) */
+                           cpu_to_be16(PCI_DEVFN(3, 0)), /* Slot 3 */
+                           0, 0,
                            0x7           /* PCI irq */);
 }
 
index ee8b193e15b10eec3aec7436068a52b724fda2d0..40dda237d8e9e992311c6ff5d6a9f4272f3b918a 100644 (file)
@@ -631,7 +631,7 @@ static void bonito_pcihost_realize(DeviceState *dev, Error **errp)
     phb->bus = pci_register_root_bus(dev, "pci",
                                      pci_bonito_set_irq, pci_bonito_map_irq,
                                      dev, &bs->pci_mem, get_system_io(),
-                                     0x28, 32, TYPE_PCI_BUS);
+                                     PCI_DEVFN(5, 0), 32, TYPE_PCI_BUS);
 
     for (size_t i = 0; i < 3; i++) {
         char *name = g_strdup_printf("pci.lomem%zu", i);
index f0a4d8c71786faaef9831008d63bd5d204aeb9ea..d25b62d6a5b2c34e3ced939f217d80955c46a9e5 100644 (file)
@@ -68,10 +68,8 @@ static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr)
         /* ... and then convert them to x86 format */
         /* config pointer */
         retval = (reg & (0xff - 7)) | (addr & 7);
-        /* slot */
-        retval |= slot << 11;
-        /* fn */
-        retval |= func << 8;
+        /* slot, fn */
+        retval |= PCI_DEVFN(slot, func) << 8;
     }
 
     trace_unin_get_config_reg(reg, addr, retval);