aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2012-05-17 21:58:41 -0400
committerBjorn Helgaas <bhelgaas@google.com>2012-06-13 17:42:26 -0400
commit7d01f70ac6f48733d595f1a54aa7c4d2ae3fef0d (patch)
treeedc62b66e73206f3cac66ba07cc2c005144b5c28 /drivers/pci/hotplug
parent073ae10c0f8284b6c6dd9708656802507349ef91 (diff)
PCI: shpchp: use generic pci_hp_add_bridge()
Use the new generic pci_hp_add_bridge() interface. [bhelgaas: changelog] Signed-off-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/hotplug')
-rw-r--r--drivers/pci/hotplug/shpchp_pci.c47
1 files changed, 15 insertions, 32 deletions
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c
index 13069802b8c8..c627ed9957d1 100644
--- a/drivers/pci/hotplug/shpchp_pci.c
+++ b/drivers/pci/hotplug/shpchp_pci.c
@@ -37,9 +37,10 @@
37int __ref shpchp_configure_device(struct slot *p_slot) 37int __ref shpchp_configure_device(struct slot *p_slot)
38{ 38{
39 struct pci_dev *dev; 39 struct pci_dev *dev;
40 struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
41 int num, fn;
42 struct controller *ctrl = p_slot->ctrl; 40 struct controller *ctrl = p_slot->ctrl;
41 struct pci_dev *bridge = ctrl->pci_dev;
42 struct pci_bus *parent = bridge->subordinate;
43 int num, fn;
43 44
44 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); 45 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0));
45 if (dev) { 46 if (dev) {
@@ -61,41 +62,23 @@ int __ref shpchp_configure_device(struct slot *p_slot)
61 if (!dev) 62 if (!dev)
62 continue; 63 continue;
63 if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || 64 if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||
64 (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) { 65 (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS))
65 /* Find an unused bus number for the new bridge */ 66 pci_hp_add_bridge(dev);
66 struct pci_bus *child; 67 pci_dev_put(dev);
67 unsigned char busnr, start = parent->busn_res.start; 68 }
68 unsigned char end = parent->busn_res.end; 69
69 int max; 70 pci_assign_unassigned_bridge_resources(bridge);
70 for (busnr = start; busnr <= end; busnr++) { 71
71 if (!pci_find_bus(pci_domain_nr(parent), 72 for (fn = 0; fn < 8; fn++) {
72 busnr)) 73 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, fn));
73 break; 74 if (!dev)
74 } 75 continue;
75 if (busnr > end) {
76 ctrl_err(ctrl,
77 "No free bus for hot-added bridge\n");
78 pci_dev_put(dev);
79 continue;
80 }
81 child = pci_add_new_bus(parent, dev, busnr);
82 if (!child) {
83 ctrl_err(ctrl, "Cannot add new bus for %s\n",
84 pci_name(dev));
85 pci_dev_put(dev);
86 continue;
87 }
88 max = pci_do_scan_bus(child);
89 pci_bus_update_busn_res_end(child, max);
90 pci_bus_size_bridges(child);
91 }
92 pci_configure_slot(dev); 76 pci_configure_slot(dev);
93 pci_dev_put(dev); 77 pci_dev_put(dev);
94 } 78 }
95 79
96 pci_bus_assign_resources(parent);
97 pci_bus_add_devices(parent); 80 pci_bus_add_devices(parent);
98 pci_enable_bridges(parent); 81
99 return 0; 82 return 0;
100} 83}
101 84