Skip to content

Commit c763fae

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: Clean up pci_scan_child_bus_extend() loop
pci_scan_child_bus_extend() open-codes device number iteration in the for loop. Convert to use PCI_DEVFN() and add PCI_MAX_NR_DEVS (there seems to be no pre-existing define for this purpose). Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Link: https://patch.msgid.link/20250610105820.7126-3-ilpo.jarvinen@linux.intel.com
1 parent aa84931 commit c763fae

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

drivers/pci/pci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ struct pcie_tlp_log;
88

99
/* Number of possible devfns: 0.0 to 1f.7 inclusive */
1010
#define MAX_NR_DEVFNS 256
11+
#define PCI_MAX_NR_DEVS 32
1112

1213
#define MAX_NR_LANES 16
1314

drivers/pci/probe.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3046,14 +3046,14 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus,
30463046
{
30473047
unsigned int used_buses, normal_bridges = 0, hotplug_bridges = 0;
30483048
unsigned int start = bus->busn_res.start;
3049-
unsigned int devfn, cmax, max = start;
3049+
unsigned int devnr, cmax, max = start;
30503050
struct pci_dev *dev;
30513051

30523052
dev_dbg(&bus->dev, "scanning bus\n");
30533053

30543054
/* Go find them, Rover! */
3055-
for (devfn = 0; devfn < 256; devfn += 8)
3056-
pci_scan_slot(bus, devfn);
3055+
for (devnr = 0; devnr < PCI_MAX_NR_DEVS; devnr++)
3056+
pci_scan_slot(bus, PCI_DEVFN(devnr, 0));
30573057

30583058
/* Reserve buses for SR-IOV capability */
30593059
used_buses = pci_iov_bus_range(bus);

0 commit comments

Comments
 (0)