Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- src/pciinit.c | 20 ++++++++------------ 1 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/src/pciinit.c b/src/pciinit.c index 7de72f4..a98f6e3 100644 --- a/src/pciinit.c +++ b/src/pciinit.c @@ -402,7 +402,7 @@ static void pci_bios_check_devices(struct pci_bus *busses)
struct pci_device *pci; struct pci_bus *bus; - int i; + int i, num_regions;
// init pci bridges foreachpci(pci) { @@ -414,12 +414,11 @@ static void pci_bios_check_devices(struct pci_bus *busses)
// discover pci bars foreachpci(pci) { - if (pci->class == PCI_CLASS_BRIDGE_PCI) - continue; + num_regions = (pci->class == PCI_CLASS_BRIDGE_PCI) ? 2 : PCI_NUM_REGIONS; dprintf(1, "PCI: check device bdf=%02x:%02x.%x\n", pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf), pci_bdf_to_fn(pci->bdf)); - for (i = 0; i < PCI_NUM_REGIONS; i++) { + for (i = 0; i < num_regions; i++) { pci_bios_get_bar(pci, i, &pci->bars[i]); if (pci->bars[i].addr == 0) continue; @@ -431,10 +430,9 @@ static void pci_bios_check_devices(struct pci_bus *busses)
// alloc ressources for pci bars foreachpci(pci) { - if (pci->class == PCI_CLASS_BRIDGE_PCI) - continue; + num_regions = (pci->class == PCI_CLASS_BRIDGE_PCI) ? 2 : PCI_NUM_REGIONS; bus = &busses[pci_bdf_to_bus(pci->bdf)]; - for (i = 0; i < PCI_NUM_REGIONS; i++) { + for (i = 0; i < num_regions; i++) { enum pci_region_type type; if (pci->bars[i].addr == 0) continue; @@ -543,7 +541,7 @@ static void pci_bios_map_devices(struct pci_bus *busses) pci_bios_init_bus_bases(&busses[0]);
// Map regions on each secondary bus. - int secondary_bus; + int secondary_bus, num_regions, i; for (secondary_bus=1; secondary_bus<=MaxPCIBus; secondary_bus++) { struct pci_bus *s = &busses[secondary_bus]; if (!s->bus_dev) @@ -581,14 +579,12 @@ static void pci_bios_map_devices(struct pci_bus *busses) // Map regions on each device. struct pci_device *pci; foreachpci(pci) { - if (pci->class == PCI_CLASS_BRIDGE_PCI) - continue; + num_regions = (pci->class == PCI_CLASS_BRIDGE_PCI) ? 2 : PCI_NUM_REGIONS; u16 bdf = pci->bdf; dprintf(1, "PCI: map device bdf=%02x:%02x.%x\n" , pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), pci_bdf_to_fn(bdf)); struct pci_bus *bus = &busses[pci_bdf_to_bus(bdf)]; - int i; - for (i = 0; i < PCI_NUM_REGIONS; i++) { + for (i = 0; i < num_regions; i++) { if (pci->bars[i].addr == 0) continue;