[5/5] power: vexpress: make the reset driver a module
diff mbox series

Message ID 20200527112608.3886105-6-anders.roxell@linaro.org
State Changes Requested
Headers show
Series
  • vexpress: modularize power reset driver
Related show

Commit Message

Anders Roxell May 27, 2020, 11:26 a.m. UTC
Today the vexpress power driver can only be builtin.  Rework so it's
possible for the vexpress power driver to be a module.

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
 arch/arm/mach-vexpress/Kconfig          |  1 -
 drivers/power/reset/Kconfig             |  5 +++--
 drivers/power/reset/vexpress-poweroff.c | 12 +++++++++++-
 3 files changed, 14 insertions(+), 4 deletions(-)

Comments

Rob Herring May 27, 2020, 1:32 p.m. UTC | #1
On Wed, May 27, 2020 at 5:26 AM Anders Roxell <anders.roxell@linaro.org> wrote:
>
> Today the vexpress power driver can only be builtin.  Rework so it's
> possible for the vexpress power driver to be a module.

This is the same incomplete patch I did[1]. As a module, it needs to
clean-up everything probe did like overwriting global variables.

Rob

[1] https://lore.kernel.org/linux-arm-kernel/20200419170810.5738-5-robh@kernel.org/
Arnd Bergmann May 28, 2020, 10:28 a.m. UTC | #2
On Wed, May 27, 2020 at 3:32 PM Rob Herring <robh@kernel.org> wrote:
>
> On Wed, May 27, 2020 at 5:26 AM Anders Roxell <anders.roxell@linaro.org> wrote:
> >
> > Today the vexpress power driver can only be builtin.  Rework so it's
> > possible for the vexpress power driver to be a module.
>
> This is the same incomplete patch I did[1]. As a module, it needs to
> clean-up everything probe did like overwriting global variables.
>
> Rob
>
> [1] https://lore.kernel.org/linux-arm-kernel/20200419170810.5738-5-robh@kernel.org/

Your version was actually broken because it allowed unloading the
driver again. The version that Anders sent is a bit better because it
explicitly forbids unloading by having a module_init but not module_exit
function, so as long as the .suppress_bind_attrs flag is set, this will
not crash the kernel.

It would be nice to have a .remove callback, but for the merge window
I'm happy with a patch that fixes the build regression.

        Arnd

Patch
diff mbox series

diff --git a/arch/arm/mach-vexpress/Kconfig b/arch/arm/mach-vexpress/Kconfig
index 065e12991663..4b54d8cf897d 100644
--- a/arch/arm/mach-vexpress/Kconfig
+++ b/arch/arm/mach-vexpress/Kconfig
@@ -15,7 +15,6 @@  menuconfig ARCH_VEXPRESS
 	select NO_IOPORT_MAP
 	select PLAT_VERSATILE
 	select POWER_RESET
-	select POWER_RESET_VEXPRESS
 	select POWER_SUPPLY
 	select REGULATOR if MMC_ARMMMCI
 	select REGULATOR_FIXED_VOLTAGE if REGULATOR
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index f07b982c8dff..8468d42b0198 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -189,9 +189,10 @@  config POWER_RESET_VERSATILE
 	  reference boards.
 
 config POWER_RESET_VEXPRESS
-	bool "ARM Versatile Express power-off and reset driver"
+	tristate "ARM Versatile Express power-off and reset driver"
 	depends on ARM || ARM64
-	depends on VEXPRESS_CONFIG=y
+	depends on VEXPRESS_CONFIG
+	default VEXPRESS_CONFIG
 	help
 	  Power off and reset support for the ARM Ltd. Versatile
 	  Express boards.
diff --git a/drivers/power/reset/vexpress-poweroff.c b/drivers/power/reset/vexpress-poweroff.c
index 1fdbcbd95fc2..b1eef95132d9 100644
--- a/drivers/power/reset/vexpress-poweroff.c
+++ b/drivers/power/reset/vexpress-poweroff.c
@@ -5,6 +5,7 @@ 
  */
 
 #include <linux/delay.h>
+#include <linux/module.h>
 #include <linux/notifier.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -146,4 +147,13 @@  static struct platform_driver vexpress_reset_driver = {
 		.suppress_bind_attrs = true,
 	},
 };
-builtin_platform_driver(vexpress_reset_driver);
+
+static int __init vexpress_reset_init(void)
+{
+	return platform_driver_register(&vexpress_reset_driver);
+}
+module_init(vexpress_reset_init);
+
+MODULE_AUTHOR("Pawel Moll <pawel.moll@arm.com>");
+MODULE_DESCRIPTION("Vexpress reset driver");
+MODULE_LICENSE("GPL v2");