diff options
author | Yinghai Lu <yinghai@kernel.org> | 2012-10-30 21:31:38 +0100 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-11-03 23:26:37 +0100 |
commit | cdfcc572be0a8b423cecfb4ab5fd735fafe9c54a (patch) | |
tree | df188f735b592a2a359969d451ed3dc51ac6e55a /drivers | |
parent | PCI/ACPI: Assign unassigned resource for hot-added root bus (diff) | |
download | linux-cdfcc572be0a8b423cecfb4ab5fd735fafe9c54a.tar.xz linux-cdfcc572be0a8b423cecfb4ab5fd735fafe9c54a.zip |
PCI: Add pci_stop_and_remove_root_bus()
It supports both PCI root bus and PCI bus under PCI bridge.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pci/remove.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index 513972f3ed13..7c0fd9252e6f 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -111,3 +111,39 @@ void pci_stop_and_remove_bus_device(struct pci_dev *dev) pci_remove_bus_device(dev); } EXPORT_SYMBOL(pci_stop_and_remove_bus_device); + +void pci_stop_root_bus(struct pci_bus *bus) +{ + struct pci_dev *child, *tmp; + struct pci_host_bridge *host_bridge; + + if (!pci_is_root_bus(bus)) + return; + + host_bridge = to_pci_host_bridge(bus->bridge); + list_for_each_entry_safe_reverse(child, tmp, + &bus->devices, bus_list) + pci_stop_bus_device(child); + + /* stop the host bridge */ + device_del(&host_bridge->dev); +} + +void pci_remove_root_bus(struct pci_bus *bus) +{ + struct pci_dev *child, *tmp; + struct pci_host_bridge *host_bridge; + + if (!pci_is_root_bus(bus)) + return; + + host_bridge = to_pci_host_bridge(bus->bridge); + list_for_each_entry_safe(child, tmp, + &bus->devices, bus_list) + pci_remove_bus_device(child); + pci_remove_bus(bus); + host_bridge->bus = NULL; + + /* remove the host bridge */ + put_device(&host_bridge->dev); +} |