summaryrefslogtreecommitdiff
path: root/drivers/pci/hotplug-pci.c
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2012-05-18 23:46:34 +0400
committerBjorn Helgaas <bhelgaas@google.com>2012-06-14 01:42:26 +0400
commita8e4b9c101ae58cc64cda0201229d3318701a7f0 (patch)
treee97410734e1b8d889c7a1d90e29a3f6efc2d860b /drivers/pci/hotplug-pci.c
parent85019faf4a88477cc72f56b6e371955ea0bb7a2a (diff)
downloadlinux-a8e4b9c101ae58cc64cda0201229d3318701a7f0.tar.xz
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/hotplug-pci.c')
-rw-r--r--drivers/pci/hotplug-pci.c23
1 files changed, 23 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 @@
#include <linux/export.h>
#include "pci.h"
+int __ref pci_hp_add_bridge(struct pci_dev *dev)
+{
+ struct pci_bus *parent = dev->bus;
+ int pass, busnr, start = parent->busn_res.start;
+ int end = parent->busn_res.end;
+
+ for (busnr = start; busnr <= end; busnr++) {
+ if (!pci_find_bus(pci_domain_nr(parent), busnr))
+ break;
+ }
+ if (busnr-- > end) {
+ printk(KERN_ERR "No bus number available for hot-added bridge %s\n",
+ pci_name(dev));
+ return -1;
+ }
+ for (pass = 0; pass < 2; pass++)
+ busnr = pci_scan_bridge(parent, dev, busnr, pass);
+ if (!dev->subordinate)
+ return -1;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(pci_hp_add_bridge);
unsigned int __devinit pci_do_scan_bus(struct pci_bus *bus)
{