Skip to content

Commit 526a769

Browse files
paliLorenzo Pieralisi
authored andcommitted
PCI: aardvark: Implement driver 'remove' function and allow to build it as module
Providing driver's 'remove' function allows kernel to bind and unbind devices from aardvark driver. It also allows to build aardvark driver as a module. Compiling aardvark as a module simplifies development and debugging of this driver as it can be reloaded at runtime without the need to reboot to new kernel. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Pali Rohár <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Reviewed-by: Marek Behún <[email protected]>
1 parent d39ff8e commit 526a769

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

drivers/pci/controller/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ config PCI_MVEBU
1212
select PCI_BRIDGE_EMUL
1313

1414
config PCI_AARDVARK
15-
bool "Aardvark PCIe controller"
15+
tristate "Aardvark PCIe controller"
1616
depends on (ARCH_MVEBU && ARM64) || COMPILE_TEST
1717
depends on OF
1818
depends on PCI_MSI_IRQ_DOMAIN

drivers/pci/controller/pci-aardvark.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/irq.h>
1515
#include <linux/irqdomain.h>
1616
#include <linux/kernel.h>
17+
#include <linux/module.h>
1718
#include <linux/pci.h>
1819
#include <linux/init.h>
1920
#include <linux/phy/phy.h>
@@ -1121,6 +1122,7 @@ static int advk_pcie_probe(struct platform_device *pdev)
11211122

11221123
pcie = pci_host_bridge_priv(bridge);
11231124
pcie->pdev = pdev;
1125+
platform_set_drvdata(pdev, pcie);
11241126

11251127
pcie->base = devm_platform_ioremap_resource(pdev, 0);
11261128
if (IS_ERR(pcie->base))
@@ -1198,18 +1200,37 @@ static int advk_pcie_probe(struct platform_device *pdev)
11981200
return 0;
11991201
}
12001202

1203+
static int advk_pcie_remove(struct platform_device *pdev)
1204+
{
1205+
struct advk_pcie *pcie = platform_get_drvdata(pdev);
1206+
struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
1207+
1208+
pci_lock_rescan_remove();
1209+
pci_stop_root_bus(bridge->bus);
1210+
pci_remove_root_bus(bridge->bus);
1211+
pci_unlock_rescan_remove();
1212+
1213+
advk_pcie_remove_msi_irq_domain(pcie);
1214+
advk_pcie_remove_irq_domain(pcie);
1215+
1216+
return 0;
1217+
}
1218+
12011219
static const struct of_device_id advk_pcie_of_match_table[] = {
12021220
{ .compatible = "marvell,armada-3700-pcie", },
12031221
{},
12041222
};
1223+
MODULE_DEVICE_TABLE(of, advk_pcie_of_match_table);
12051224

12061225
static struct platform_driver advk_pcie_driver = {
12071226
.driver = {
12081227
.name = "advk-pcie",
12091228
.of_match_table = advk_pcie_of_match_table,
1210-
/* Driver unloading/unbinding currently not supported */
1211-
.suppress_bind_attrs = true,
12121229
},
12131230
.probe = advk_pcie_probe,
1231+
.remove = advk_pcie_remove,
12141232
};
1215-
builtin_platform_driver(advk_pcie_driver);
1233+
module_platform_driver(advk_pcie_driver);
1234+
1235+
MODULE_DESCRIPTION("Aardvark PCIe controller");
1236+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)