From patchwork Fri Mar 20 20:56:05 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Chiang X-Patchwork-Id: 13376 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2KKufK6001652 for ; Fri, 20 Mar 2009 20:56:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755574AbZCTU4J (ORCPT ); Fri, 20 Mar 2009 16:56:09 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755907AbZCTU4J (ORCPT ); Fri, 20 Mar 2009 16:56:09 -0400 Received: from g4t0017.houston.hp.com ([15.201.24.20]:25385 "EHLO g4t0017.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755574AbZCTU4H (ORCPT ); Fri, 20 Mar 2009 16:56:07 -0400 Received: from smtp1.fc.hp.com (smtp.fc.hp.com [15.15.136.127]) by g4t0017.houston.hp.com (Postfix) with ESMTP id E6BCE3830B; Fri, 20 Mar 2009 20:56:05 +0000 (UTC) Received: from localhost.localdomain (lart.fc.hp.com [15.11.146.31]) by smtp1.fc.hp.com (Postfix) with ESMTP id 0544E247C4A; Fri, 20 Mar 2009 20:27:26 +0000 (UTC) Received: from bob.kio (localhost [127.0.0.1]) by localhost.localdomain (Postfix) with ESMTP id A2ADE2615B; Fri, 20 Mar 2009 14:56:05 -0600 (MDT) From: Alex Chiang Subject: [PATCH v5 03/13] PCI: pci_scan_slot() returns newly found devices To: jbarnes@virtuousgeek.org Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Trent Piepho , Alex Chiang Date: Fri, 20 Mar 2009 14:56:05 -0600 Message-ID: <20090320205605.12275.96326.stgit@bob.kio> In-Reply-To: <20090320204327.12275.43010.stgit@bob.kio> References: <20090320204327.12275.43010.stgit@bob.kio> User-Agent: StGIT/0.14.3.215.gff3d MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Trent Piepho 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. [achiang@hp.com: fix checkpatch errors] Signed-off-by: Trent Piepho Reviewed-by: Alex Chiang Signed-off-by: Alex Chiang --- drivers/pci/probe.c | 40 ++++++++++++++++------------------------ 1 files changed, 16 insertions(+), 24 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index b89a86e..f261741 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1037,35 +1037,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; } }