Commit 1b69dfc6 authored by Trent Piepho's avatar Trent Piepho Committed by Jesse Barnes

PCI: pci_scan_slot() returns newly found devices

pci_scan_slot() has been rewritten to be less complex and will now
return the number of *new* devices found.

Existing callers need not worry because they already assume that
they can't call pci_scan_slot() on an already-scanned slot.

Thus, there is no semantic change for existing callers: returning
newly found devices (this patch) is exactly equal to returning all
found devices (before this patch).

This patch adds some more groundwork to allow us to rescan the
PCI bus during runtime to discover newly added devices.
Signed-off-by: default avatarTrent Piepho <xyzzy@speakeasy.org>
Reviewed-by: default avatarAlex Chiang <achiang@hp.com>
Signed-off-by: default avatarAlex Chiang <achiang@hp.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent 90bdb311
...@@ -1043,35 +1043,27 @@ EXPORT_SYMBOL(pci_scan_single_device); ...@@ -1043,35 +1043,27 @@ EXPORT_SYMBOL(pci_scan_single_device);
* Scan a PCI slot on the specified PCI bus for devices, adding * Scan a PCI slot on the specified PCI bus for devices, adding
* discovered devices to the @bus->devices list. New devices * discovered devices to the @bus->devices list. New devices
* will not have is_added set. * will not have is_added set.
*
* Returns the number of new devices found.
*/ */
int pci_scan_slot(struct pci_bus *bus, int devfn) int pci_scan_slot(struct pci_bus *bus, int devfn)
{ {
int func, nr = 0; int fn, nr = 0;
int scan_all_fns; struct pci_dev *dev;
scan_all_fns = pcibios_scan_all_fns(bus, devfn);
for (func = 0; func < 8; func++, devfn++) {
struct pci_dev *dev;
dev = pci_scan_single_device(bus, devfn);
if (dev) {
nr++;
/* dev = pci_scan_single_device(bus, devfn);
* If this is a single function device, if (dev && !dev->is_added) /* new device? */
* don't scan past the first function. nr++;
*/
if (!dev->multifunction) { if ((dev && dev->multifunction) ||
if (func > 0) { (!dev && pcibios_scan_all_fns(bus, devfn))) {
dev->multifunction = 1; for (fn = 1; fn < 8; fn++) {
} else { dev = pci_scan_single_device(bus, devfn + fn);
break; if (dev) {
} if (!dev->is_added)
nr++;
dev->multifunction = 1;
} }
} else {
if (func == 0 && !scan_all_fns)
break;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment