Skip to content

Commit 5a02413

Browse files
ij-intelbjorn-helgaas
authored andcommitted
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/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent de2cdf1 commit 5a02413

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

drivers/pci/hotplug/cpqphp_pci.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212
*
1313
*/
1414

15+
#define pr_fmt(fmt) "cpqphp: " fmt
16+
1517
#include <linux/module.h>
1618
#include <linux/kernel.h>
19+
#include <linux/printk.h>
1720
#include <linux/types.h>
1821
#include <linux/slab.h>
1922
#include <linux/workqueue.h>
@@ -190,8 +193,7 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 *dev_
190193
{
191194
u16 tdevice;
192195
u32 work;
193-
int ret;
194-
u8 tbus;
196+
int ret = -1;
195197

196198
ctrl->pci_bus->number = bus_num;
197199

@@ -208,26 +210,20 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 *dev_
208210
*dev_num = tdevice;
209211
dbg("found it !\n");
210212
return 0;
211-
}
212-
}
213-
for (tdevice = 0; tdevice < 0xFF; tdevice++) {
214-
/* Scan for access first */
215-
if (!pci_bus_read_dev_vendor_id(ctrl->pci_bus, tdevice, &work, 0))
216-
continue;
217-
ret = pci_bus_read_config_dword(ctrl->pci_bus, tdevice, PCI_CLASS_REVISION, &work);
218-
if (ret)
219-
continue;
220-
dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice);
221-
/* Yep we got one. bridge ? */
222-
if ((work >> 8) == PCI_TO_PCI_BRIDGE_CLASS) {
223-
pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(tdevice, 0), PCI_SECONDARY_BUS, &tbus);
224-
/* XXX: no recursion, wtf? */
225-
dbg("Recurse on bus_num %d tdevice %d\n", tbus, tdevice);
226-
return 0;
213+
} else {
214+
/*
215+
* XXX: Code whose debug printout indicated
216+
* recursion to buses underneath bridges might be
217+
* necessary was removed because it never did
218+
* any recursion.
219+
*/
220+
ret = 0;
221+
pr_warn("missing feature: bridge scan recursion not implemented\n");
227222
}
228223
}
229224

230-
return -1;
225+
226+
return ret;
231227
}
232228

233229

0 commit comments

Comments
 (0)