]> www.infradead.org Git - users/hch/misc.git/commitdiff
PCI: Clean up pci_scan_child_bus_extend() loop
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 10 Jun 2025 10:58:20 +0000 (13:58 +0300)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 11 Aug 2025 20:00:51 +0000 (15:00 -0500)
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
drivers/pci/pci.h
drivers/pci/probe.c

index 34f65d69662e9f61f0c489ec58de2ce17d21c0c6..e1ad32b9eb5608da635cbefc80868056831e6468 100644 (file)
@@ -8,6 +8,7 @@ struct pcie_tlp_log;
 
 /* Number of possible devfns: 0.0 to 1f.7 inclusive */
 #define MAX_NR_DEVFNS 256
+#define PCI_MAX_NR_DEVS        32
 
 #define MAX_NR_LANES 16
 
index b06f0d19f9a746b0b87fad21ca82525395a0c126..591aee60e3d0a5b5d87e2dc6bb063fed58c94892 100644 (file)
@@ -3046,14 +3046,14 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus,
 {
        unsigned int used_buses, normal_bridges = 0, hotplug_bridges = 0;
        unsigned int start = bus->busn_res.start;
-       unsigned int devfn, cmax, max = start;
+       unsigned int devnr, cmax, max = start;
        struct pci_dev *dev;
 
        dev_dbg(&bus->dev, "scanning bus\n");
 
        /* Go find them, Rover! */
-       for (devfn = 0; devfn < 256; devfn += 8)
-               pci_scan_slot(bus, devfn);
+       for (devnr = 0; devnr < PCI_MAX_NR_DEVS; devnr++)
+               pci_scan_slot(bus, PCI_DEVFN(devnr, 0));
 
        /* Reserve buses for SR-IOV capability */
        used_buses = pci_iov_bus_range(bus);