Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: cpqphp: Simplify PCI_ScanBusForNonBridge()

PCI_ScanBusForNonBridge() has two loops, one to search for non-bridges and
a second to look for bridges. The second loop has hints in a debug print it
should do recursion for buses underneath the bridge, but no recursion is
attempted.

Since the second loop is quite useless in its current form, just eliminate
it. This code hasn't been touched for very long time so either it's unused
or the missing parts are not important enough for anyone to attempt to add
them.

Leave only a warning print and comment about the missing recursion for the
unlikely case that somebody comes across the lack of functionality. In any
case, search whether an endpoint exists downstream of a bridge sounds
generic enough to belong to core so if the functionality is to be extended
it should probably be moved into PCI core.

Link: https://lore.kernel.org/r/20241022091140.3504-5-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Ilpo Järvinen and committed by
Bjorn Helgaas
5a02413a de2cdf11

+15 -19
+15 -19
drivers/pci/hotplug/cpqphp_pci.c
··· 12 12 * 13 13 */ 14 14 15 + #define pr_fmt(fmt) "cpqphp: " fmt 16 + 15 17 #include <linux/module.h> 16 18 #include <linux/kernel.h> 19 + #include <linux/printk.h> 17 20 #include <linux/types.h> 18 21 #include <linux/slab.h> 19 22 #include <linux/workqueue.h> ··· 193 190 { 194 191 u16 tdevice; 195 192 u32 work; 196 - int ret; 197 - u8 tbus; 193 + int ret = -1; 198 194 199 195 ctrl->pci_bus->number = bus_num; 200 196 ··· 210 208 *dev_num = tdevice; 211 209 dbg("found it !\n"); 212 210 return 0; 213 - } 214 - } 215 - for (tdevice = 0; tdevice < 0xFF; tdevice++) { 216 - /* Scan for access first */ 217 - if (!pci_bus_read_dev_vendor_id(ctrl->pci_bus, tdevice, &work, 0)) 218 - continue; 219 - ret = pci_bus_read_config_dword(ctrl->pci_bus, tdevice, PCI_CLASS_REVISION, &work); 220 - if (ret) 221 - continue; 222 - dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice); 223 - /* Yep we got one. bridge ? */ 224 - if ((work >> 8) == PCI_TO_PCI_BRIDGE_CLASS) { 225 - pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(tdevice, 0), PCI_SECONDARY_BUS, &tbus); 226 - /* XXX: no recursion, wtf? */ 227 - dbg("Recurse on bus_num %d tdevice %d\n", tbus, tdevice); 228 - return 0; 211 + } else { 212 + /* 213 + * XXX: Code whose debug printout indicated 214 + * recursion to buses underneath bridges might be 215 + * necessary was removed because it never did 216 + * any recursion. 217 + */ 218 + ret = 0; 219 + pr_warn("missing feature: bridge scan recursion not implemented\n"); 229 220 } 230 221 } 231 222 232 - return -1; 223 + 224 + return ret; 233 225 } 234 226 235 227