]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
PCI: cpqphp: Simplify PCI_ScanBusForNonBridge()
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 22 Oct 2024 09:11:40 +0000 (12:11 +0300)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 22 Oct 2024 15:06:59 +0000 (10:06 -0500)
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>
drivers/pci/hotplug/cpqphp_pci.c

index 558866c15e03c07ead2fd2a4b309d30e99617e89..ef7534a3ca40ff7533238c970ef7119bab0452db 100644 (file)
  *
  */
 
+#define pr_fmt(fmt) "cpqphp: " fmt
+
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/printk.h>
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/workqueue.h>
@@ -190,8 +193,7 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 *dev_
 {
        u16 tdevice;
        u32 work;
-       int ret;
-       u8 tbus;
+       int ret = -1;
 
        ctrl->pci_bus->number = bus_num;
 
@@ -208,26 +210,20 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 *dev_
                        *dev_num = tdevice;
                        dbg("found it !\n");
                        return 0;
-               }
-       }
-       for (tdevice = 0; tdevice < 0xFF; tdevice++) {
-               /* Scan for access first */
-               if (!pci_bus_read_dev_vendor_id(ctrl->pci_bus, tdevice, &work, 0))
-                       continue;
-               ret = pci_bus_read_config_dword(ctrl->pci_bus, tdevice, PCI_CLASS_REVISION, &work);
-               if (ret)
-                       continue;
-               dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice);
-               /* Yep we got one. bridge ? */
-               if ((work >> 8) == PCI_TO_PCI_BRIDGE_CLASS) {
-                       pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(tdevice, 0), PCI_SECONDARY_BUS, &tbus);
-                       /* XXX: no recursion, wtf? */
-                       dbg("Recurse on bus_num %d tdevice %d\n", tbus, tdevice);
-                       return 0;
+               } else {
+                       /*
+                        * XXX: Code whose debug printout indicated
+                        * recursion to buses underneath bridges might be
+                        * necessary was removed because it never did
+                        * any recursion.
+                        */
+                       ret = 0;
+                       pr_warn("missing feature: bridge scan recursion not implemented\n");
                }
        }
 
-       return -1;
+
+       return ret;
 }