blob: 44088c4fe687cfb02996e816c5065ccfb1df22be [file] [log] [blame]
Sam Ravnborg41057172008-02-02 22:32:23 +01001/* Core PCI functionality used only by PCI hotplug */
2
3#include <linux/pci.h>
Paul Gortmaker363c75d2011-05-27 09:37:25 -04004#include <linux/export.h>
Sam Ravnborg41057172008-02-02 22:32:23 +01005#include "pci.h"
6
Yinghai Lua8e4b9c2012-05-18 13:46:34 -06007int __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);
Sam Ravnborg41057172008-02-02 22:32:23 +010030
Sam Ravnborg0ab2b572008-02-17 10:45:28 +010031unsigned int __devinit pci_do_scan_bus(struct pci_bus *bus)
Sam Ravnborg41057172008-02-02 22:32:23 +010032{
33 unsigned int max;
34
35 max = pci_scan_child_bus(bus);
36
37 /*
38 * Make the discovered devices available.
39 */
40 pci_bus_add_devices(bus);
41
42 return max;
43}
44EXPORT_SYMBOL(pci_do_scan_bus);