]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
PCI: Add support for unbinding the generic PCI host controller
authorJan Kiszka <jan.kiszka@siemens.com>
Tue, 15 May 2018 09:07:06 +0000 (11:07 +0200)
committerBjorn Helgaas <helgaas@kernel.org>
Wed, 30 May 2018 16:35:23 +0000 (11:35 -0500)
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>
drivers/pci/host/pci-host-common.c
drivers/pci/host/pci-host-generic.c
include/linux/pci-ecam.h

index 5d028f53fdcdbe7c8ee95eae473e0c9c89f4e924..d8f10451f2730e73117df18306ef08a4b698a9f2 100644 (file)
@@ -101,5 +101,18 @@ int pci_host_common_probe(struct platform_device *pdev,
                return ret;
        }
 
+       platform_set_drvdata(pdev, bridge->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;
 }
index 45319ee3b484b789969713b5f97326c4c45b2e06..dea3ec7592a231052010e4935d85ee1073352c6f 100644 (file)
@@ -95,5 +95,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);
index baadad1aabbcc6bb9186467f80b44f0fd525099e..29efa09d686b2d8062b827f20b1f8b21d08ac20f 100644 (file)
@@ -62,5 +62,6 @@ extern struct pci_ecam_ops xgene_v2_pcie_ecam_ops; /* APM X-Gene PCIe v2.x */
 /* for DT-based PCI controllers that support ECAM */
 int pci_host_common_probe(struct platform_device *pdev,
                          struct pci_ecam_ops *ops);
+int pci_host_common_remove(struct platform_device *pdev);
 #endif
 #endif