Commit 526a7699 authored by Pali Rohár's avatar Pali Rohár Committed by Lorenzo Pieralisi

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/20200907111038.5811-5-pali@kernel.orgSigned-off-by: default avatarPali Rohár <pali@kernel.org>
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: default avatarMarek Behún <marek.behun@nic.cz>
parent d39ff8ee
...@@ -12,7 +12,7 @@ config PCI_MVEBU ...@@ -12,7 +12,7 @@ config PCI_MVEBU
select PCI_BRIDGE_EMUL select PCI_BRIDGE_EMUL
config PCI_AARDVARK config PCI_AARDVARK
bool "Aardvark PCIe controller" tristate "Aardvark PCIe controller"
depends on (ARCH_MVEBU && ARM64) || COMPILE_TEST depends on (ARCH_MVEBU && ARM64) || COMPILE_TEST
depends on OF depends on OF
depends on PCI_MSI_IRQ_DOMAIN depends on PCI_MSI_IRQ_DOMAIN
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/irqdomain.h> #include <linux/irqdomain.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/phy/phy.h> #include <linux/phy/phy.h>
...@@ -1121,6 +1122,7 @@ static int advk_pcie_probe(struct platform_device *pdev) ...@@ -1121,6 +1122,7 @@ static int advk_pcie_probe(struct platform_device *pdev)
pcie = pci_host_bridge_priv(bridge); pcie = pci_host_bridge_priv(bridge);
pcie->pdev = pdev; pcie->pdev = pdev;
platform_set_drvdata(pdev, pcie);
pcie->base = devm_platform_ioremap_resource(pdev, 0); pcie->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(pcie->base)) if (IS_ERR(pcie->base))
...@@ -1198,18 +1200,37 @@ static int advk_pcie_probe(struct platform_device *pdev) ...@@ -1198,18 +1200,37 @@ static int advk_pcie_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int advk_pcie_remove(struct platform_device *pdev)
{
struct advk_pcie *pcie = platform_get_drvdata(pdev);
struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
pci_lock_rescan_remove();
pci_stop_root_bus(bridge->bus);
pci_remove_root_bus(bridge->bus);
pci_unlock_rescan_remove();
advk_pcie_remove_msi_irq_domain(pcie);
advk_pcie_remove_irq_domain(pcie);
return 0;
}
static const struct of_device_id advk_pcie_of_match_table[] = { static const struct of_device_id advk_pcie_of_match_table[] = {
{ .compatible = "marvell,armada-3700-pcie", }, { .compatible = "marvell,armada-3700-pcie", },
{}, {},
}; };
MODULE_DEVICE_TABLE(of, advk_pcie_of_match_table);
static struct platform_driver advk_pcie_driver = { static struct platform_driver advk_pcie_driver = {
.driver = { .driver = {
.name = "advk-pcie", .name = "advk-pcie",
.of_match_table = advk_pcie_of_match_table, .of_match_table = advk_pcie_of_match_table,
/* Driver unloading/unbinding currently not supported */
.suppress_bind_attrs = true,
}, },
.probe = advk_pcie_probe, .probe = advk_pcie_probe,
.remove = advk_pcie_remove,
}; };
builtin_platform_driver(advk_pcie_driver); module_platform_driver(advk_pcie_driver);
MODULE_DESCRIPTION("Aardvark PCIe controller");
MODULE_LICENSE("GPL v2");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment