summaryrefslogtreecommitdiff
path: root/drivers/pci
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2018-05-15 11:07:06 +0200
committerJason Liu <jason.hui.liu@nxp.com>2019-02-12 10:33:27 +0800
commita1541b174157a1a6e0f2881d9573ee1408da1661 (patch)
tree722a5eadc9a85d0deeeaa5946478d820dc300ff4 /drivers/pci
parentd70cf5ab02edfcd67b8178ec641a248b9c780e77 (diff)
PCI: Add support for unbinding the generic PCI host controller
Add support for unbinding the generic PCI host controller. This is particularly useful when working in virtual environments where the controller may come and go, but possibly not only there. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> CC: Will Deacon <will.deacon@arm.com> CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> (cherry picked from commit 01fcb7f777a9f5d216a1ff41228f15656e50fb63) (cherry picked from commit 6a8a0e11c827908864cdd45623aa17b5bc80d2e5) Signed-off-by: Peng Fan <peng.fan@nxp.com>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/host/pci-host-common.c14
-rw-r--r--drivers/pci/host/pci-host-generic.c1
2 files changed, 15 insertions, 0 deletions
diff --git a/drivers/pci/host/pci-host-common.c b/drivers/pci/host/pci-host-common.c
index 148896f73c06..ec523cdc1b5f 100644
--- a/drivers/pci/host/pci-host-common.c
+++ b/drivers/pci/host/pci-host-common.c
@@ -176,5 +176,19 @@ int pci_host_common_probe(struct platform_device *pdev,
}
pci_bus_add_devices(bus);
+
+ platform_set_drvdata(pdev, bus);
+ return 0;
+}
+
+int pci_host_common_remove(struct platform_device *pdev)
+{
+ struct pci_bus *bus = platform_get_drvdata(pdev);
+
+ pci_lock_rescan_remove();
+ pci_stop_root_bus(bus);
+ pci_remove_root_bus(bus);
+ pci_unlock_rescan_remove();
+
return 0;
}
diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c
index 7d709a7e0aa8..b35057e6e4f8 100644
--- a/drivers/pci/host/pci-host-generic.c
+++ b/drivers/pci/host/pci-host-generic.c
@@ -63,5 +63,6 @@ static struct platform_driver gen_pci_driver = {
.suppress_bind_attrs = true,
},
.probe = gen_pci_probe,
+ .remove = pci_host_common_remove,
};
builtin_platform_driver(gen_pci_driver);