memory: tegra30-emc: Make driver modular
authorDmitry Osipenko <digetx@gmail.com>
Wed, 11 Nov 2020 01:14:37 +0000 (04:14 +0300)
committerKrzysztof Kozlowski <krzk@kernel.org>
Thu, 26 Nov 2020 17:50:36 +0000 (18:50 +0100)
Add modularization support to the Tegra30 EMC driver, which now can be
compiled as a loadable kernel module.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20201111011456.7875-8-digetx@gmail.com
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
drivers/memory/tegra/Kconfig
drivers/memory/tegra/mc.c
drivers/memory/tegra/tegra30-emc.c

index 8cc1ec5..2a4a16b 100644 (file)
@@ -21,7 +21,7 @@ config TEGRA20_EMC
          external memory.
 
 config TEGRA30_EMC
-       bool "NVIDIA Tegra30 External Memory Controller driver"
+       tristate "NVIDIA Tegra30 External Memory Controller driver"
        default y
        depends on TEGRA_MC && ARCH_TEGRA_3x_SOC
        help
index a7e6a8e..44064de 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
+#include <linux/export.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -346,6 +347,7 @@ int tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate)
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(tegra_mc_write_emem_configuration);
 
 unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc)
 {
@@ -357,6 +359,7 @@ unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc)
 
        return dram_count;
 }
+EXPORT_SYMBOL_GPL(tegra_mc_get_emem_device_count);
 
 static int load_one_timing(struct tegra_mc *mc,
                           struct tegra_mc_timing *timing,
index 1be28e2..d092608 100644 (file)
@@ -1330,6 +1330,13 @@ static int tegra_emc_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, emc);
        tegra_emc_debugfs_init(emc);
 
+       /*
+        * Don't allow the kernel module to be unloaded. Unloading adds some
+        * extra complexity which doesn't really worth the effort in a case of
+        * this driver.
+        */
+       try_module_get(THIS_MODULE);
+
        return 0;
 
 unset_cb:
@@ -1380,6 +1387,7 @@ static const struct of_device_id tegra_emc_of_match[] = {
        { .compatible = "nvidia,tegra30-emc", },
        {},
 };
+MODULE_DEVICE_TABLE(of, tegra_emc_of_match);
 
 static struct platform_driver tegra_emc_driver = {
        .probe = tegra_emc_probe,
@@ -1390,9 +1398,8 @@ static struct platform_driver tegra_emc_driver = {
                .suppress_bind_attrs = true,
        },
 };
+module_platform_driver(tegra_emc_driver);
 
-static int __init tegra_emc_init(void)
-{
-       return platform_driver_register(&tegra_emc_driver);
-}
-subsys_initcall(tegra_emc_init);
+MODULE_AUTHOR("Dmitry Osipenko <digetx@gmail.com>");
+MODULE_DESCRIPTION("NVIDIA Tegra30 EMC driver");
+MODULE_LICENSE("GPL v2");