summaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2009-03-20 14:56:05 -0600
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-03-20 14:57:05 -0700
commit1b69dfc649e6658fc38499cf704750d74cabc73d (patch)
tree57dd8fff34d6be97a8bb19a733d3dc041ab81d0b /drivers/pci
parent90bdb3117f4209baa6d712b126f0e7791b24dc3f (diff)
downloadop-kernel-dev-1b69dfc649e6658fc38499cf704750d74cabc73d.zip
op-kernel-dev-1b69dfc649e6658fc38499cf704750d74cabc73d.tar.gz
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: Trent Piepho <xyzzy@speakeasy.org> Reviewed-by: Alex Chiang <achiang@hp.com> Signed-off-by: Alex Chiang <achiang@hp.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/probe.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 140b9de..f3aabdf 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1043,35 +1043,27 @@ EXPORT_SYMBOL(pci_scan_single_device);
* Scan a PCI slot on the specified PCI bus for devices, adding
* discovered devices to the @bus->devices list. New devices
* will not have is_added set.
+ *
+ * Returns the number of new devices found.
*/
int pci_scan_slot(struct pci_bus *bus, int devfn)
{
- int func, nr = 0;
- int scan_all_fns;
-
- 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++;
+ int fn, nr = 0;
+ struct pci_dev *dev;
- /*
- * If this is a single function device,
- * don't scan past the first function.
- */
- if (!dev->multifunction) {
- if (func > 0) {
- dev->multifunction = 1;
- } else {
- break;
- }
+ dev = pci_scan_single_device(bus, devfn);
+ if (dev && !dev->is_added) /* new device? */
+ nr++;
+
+ if ((dev && dev->multifunction) ||
+ (!dev && pcibios_scan_all_fns(bus, devfn))) {
+ for (fn = 1; fn < 8; fn++) {
+ dev = pci_scan_single_device(bus, devfn + fn);
+ if (dev) {
+ if (!dev->is_added)
+ nr++;
+ dev->multifunction = 1;
}
- } else {
- if (func == 0 && !scan_all_fns)
- break;
}
}
OpenPOWER on IntegriCloud