aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pci/probe.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 9672760c7ade..233d1c275d96 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1222,11 +1222,19 @@ EXPORT_SYMBOL(pci_scan_single_device);
1222static unsigned next_ari_fn(struct pci_dev *dev, unsigned fn) 1222static unsigned next_ari_fn(struct pci_dev *dev, unsigned fn)
1223{ 1223{
1224 u16 cap; 1224 u16 cap;
1225 unsigned pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI); 1225 unsigned pos, next_fn;
1226
1227 if (!dev)
1228 return 0;
1229
1230 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI);
1226 if (!pos) 1231 if (!pos)
1227 return 0; 1232 return 0;
1228 pci_read_config_word(dev, pos + 4, &cap); 1233 pci_read_config_word(dev, pos + 4, &cap);
1229 return cap >> 8; 1234 next_fn = cap >> 8;
1235 if (next_fn <= fn)
1236 return 0;
1237 return next_fn;
1230} 1238}
1231 1239
1232static unsigned next_trad_fn(struct pci_dev *dev, unsigned fn) 1240static unsigned next_trad_fn(struct pci_dev *dev, unsigned fn)
@@ -1271,12 +1279,14 @@ int pci_scan_slot(struct pci_bus *bus, int devfn)
1271 return 0; /* Already scanned the entire slot */ 1279 return 0; /* Already scanned the entire slot */
1272 1280
1273 dev = pci_scan_single_device(bus, devfn); 1281 dev = pci_scan_single_device(bus, devfn);
1274 if (dev && !dev->is_added) /* new device? */ 1282 if (!dev)
1283 return 0;
1284 if (!dev->is_added)
1275 nr++; 1285 nr++;
1276 1286
1277 if (pci_ari_enabled(bus)) 1287 if (pci_ari_enabled(bus))
1278 next_fn = next_ari_fn; 1288 next_fn = next_ari_fn;
1279 else if (dev && dev->multifunction) 1289 else if (dev->multifunction)
1280 next_fn = next_trad_fn; 1290 next_fn = next_trad_fn;
1281 1291
1282 for (fn = next_fn(dev, 0); fn > 0; fn = next_fn(dev, fn)) { 1292 for (fn = next_fn(dev, 0); fn > 0; fn = next_fn(dev, fn)) {