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

PCI: Split out next_ari_fn() from next_fn()

In commit b1bd58e448f2 ("PCI: Consolidate "next-function" functions") the
next_fn() function subsumed the traditional and ARI-based next function
determination. This got rid of some needlessly complex function pointer
handling but also reduced the separation between these very different
methods of finding the next function. With the next_fn() cleaned up a bit
we can re-introduce this separation by moving out the ARI handling while
sticking with direct function calls.

Link: https://lore.kernel.org/r/20220628143100.3228092-3-schnelle@linux.ibm.com
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>

authored by

Niklas Schnelle and committed by
Bjorn Helgaas
fbed59ed c3df83e0

+18 -13
+18 -13
drivers/pci/probe.c
··· 2579 2579 } 2580 2580 EXPORT_SYMBOL(pci_scan_single_device); 2581 2581 2582 - static int next_fn(struct pci_bus *bus, struct pci_dev *dev, int fn) 2582 + static int next_ari_fn(struct pci_bus *bus, struct pci_dev *dev, int fn) 2583 2583 { 2584 2584 int pos; 2585 2585 u16 cap = 0; 2586 2586 unsigned int next_fn; 2587 2587 2588 - if (pci_ari_enabled(bus)) { 2589 - if (!dev) 2590 - return -ENODEV; 2591 - pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI); 2592 - if (!pos) 2593 - return -ENODEV; 2588 + if (!dev) 2589 + return -ENODEV; 2594 2590 2595 - pci_read_config_word(dev, pos + PCI_ARI_CAP, &cap); 2596 - next_fn = PCI_ARI_CAP_NFN(cap); 2597 - if (next_fn <= fn) 2598 - return -ENODEV; /* protect against malformed list */ 2591 + pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI); 2592 + if (!pos) 2593 + return -ENODEV; 2599 2594 2600 - return next_fn; 2601 - } 2595 + pci_read_config_word(dev, pos + PCI_ARI_CAP, &cap); 2596 + next_fn = PCI_ARI_CAP_NFN(cap); 2597 + if (next_fn <= fn) 2598 + return -ENODEV; /* protect against malformed list */ 2599 + 2600 + return next_fn; 2601 + } 2602 + 2603 + static int next_fn(struct pci_bus *bus, struct pci_dev *dev, int fn) 2604 + { 2605 + if (pci_ari_enabled(bus)) 2606 + return next_ari_fn(bus, dev, fn); 2602 2607 2603 2608 if (fn >= 7) 2604 2609 return -ENODEV;