aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2012-05-18 15:46:34 -0400
committerBjorn Helgaas <bhelgaas@google.com>2012-06-13 17:42:26 -0400
commita8e4b9c101ae58cc64cda0201229d3318701a7f0 (patch)
treee97410734e1b8d889c7a1d90e29a3f6efc2d860b /drivers/pci
parent85019faf4a88477cc72f56b6e371955ea0bb7a2a (diff)
PCI: add generic pci_hp_add_bridge()
This creates a generic pci_hp_add_bridge() that can be used by several hotplug drivers. [bhelgaas: split out from pciehp patch] Signed-off-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/hotplug-pci.c23
-rw-r--r--drivers/pci/pci.h1
2 files changed, 24 insertions, 0 deletions
diff --git a/drivers/pci/hotplug-pci.c b/drivers/pci/hotplug-pci.c
index d3509cdeb554..44088c4fe687 100644
--- a/drivers/pci/hotplug-pci.c
+++ b/drivers/pci/hotplug-pci.c
@@ -4,6 +4,29 @@
4#include <linux/export.h> 4#include <linux/export.h>
5#include "pci.h" 5#include "pci.h"
6 6
7int __ref pci_hp_add_bridge(struct pci_dev *dev)
8{
9 struct pci_bus *parent = dev->bus;
10 int pass, busnr, start = parent->busn_res.start;
11 int end = parent->busn_res.end;
12
13 for (busnr = start; busnr <= end; busnr++) {
14 if (!pci_find_bus(pci_domain_nr(parent), busnr))
15 break;
16 }
17 if (busnr-- > end) {
18 printk(KERN_ERR "No bus number available for hot-added bridge %s\n",
19 pci_name(dev));
20 return -1;
21 }
22 for (pass = 0; pass < 2; pass++)
23 busnr = pci_scan_bridge(parent, dev, busnr, pass);
24 if (!dev->subordinate)
25 return -1;
26
27 return 0;
28}
29EXPORT_SYMBOL_GPL(pci_hp_add_bridge);
7 30
8unsigned int __devinit pci_do_scan_bus(struct pci_bus *bus) 31unsigned int __devinit pci_do_scan_bus(struct pci_bus *bus)
9{ 32{
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index e4943479b234..f3e14ce8eab7 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -124,6 +124,7 @@ static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; }
124#endif 124#endif
125 125
126/* Functions for PCI Hotplug drivers to use */ 126/* Functions for PCI Hotplug drivers to use */
127int pci_hp_add_bridge(struct pci_dev *dev);
127extern unsigned int pci_do_scan_bus(struct pci_bus *bus); 128extern unsigned int pci_do_scan_bus(struct pci_bus *bus);
128 129
129#ifdef HAVE_PCI_LEGACY 130#ifdef HAVE_PCI_LEGACY