Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH RFC] power: reset: restart-poweroff: convert to module
@ 2024-02-21 17:46 A. Sverdlin
  2024-02-21 21:01 ` Sebastian Reichel
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: A. Sverdlin @ 2024-02-21 17:46 UTC (permalink / raw)
  To: linux-pm; +Cc: Alexander Sverdlin, Andrew Lunn, Sebastian Reichel, linux-kernel

From: Alexander Sverdlin <alexander.sverdlin@siemens.com>

The necessity of having a fake platform device for a generic, platform
independent functionality is not obvious.
Some platforms requre device tree modification for this, some would require
ACPI tables modification, while functionality may be useful even to
end-users without required expertise. Convert the platform driver to
a simple module.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
---
This RFC is merely to understand if this approach would be accepted.
Converting to "tristate" could follow or preceed this patch.

diff --git a/drivers/power/reset/restart-poweroff.c b/drivers/power/reset/restart-poweroff.c
index 28f1822db1626..e1d94109f6823 100644
--- a/drivers/power/reset/restart-poweroff.c
+++ b/drivers/power/reset/restart-poweroff.c
@@ -20,7 +20,7 @@ static void restart_poweroff_do_poweroff(void)
 	machine_restart(NULL);
 }
 
-static int restart_poweroff_probe(struct platform_device *pdev)
+static int __init restart_poweroff_init(void)
 {
 	/* If a pm_power_off function has already been added, leave it alone */
 	if (pm_power_off != NULL) {
@@ -33,12 +33,10 @@ static int restart_poweroff_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int restart_poweroff_remove(struct platform_device *pdev)
+static void __exit restart_poweroff_exit(void)
 {
 	if (pm_power_off == &restart_poweroff_do_poweroff)
 		pm_power_off = NULL;
-
-	return 0;
 }
 
 static const struct of_device_id of_restart_poweroff_match[] = {
@@ -47,15 +45,8 @@ static const struct of_device_id of_restart_poweroff_match[] = {
 };
 MODULE_DEVICE_TABLE(of, of_restart_poweroff_match);
 
-static struct platform_driver restart_poweroff_driver = {
-	.probe = restart_poweroff_probe,
-	.remove = restart_poweroff_remove,
-	.driver = {
-		.name = "poweroff-restart",
-		.of_match_table = of_restart_poweroff_match,
-	},
-};
-module_platform_driver(restart_poweroff_driver);
+module_init(restart_poweroff_init);
+module_exit(restart_poweroff_exit);
 
 MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch");
 MODULE_DESCRIPTION("restart poweroff driver");
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-02-22 14:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-21 17:46 [PATCH RFC] power: reset: restart-poweroff: convert to module A. Sverdlin
2024-02-21 21:01 ` Sebastian Reichel
2024-02-21 21:56 ` Andrew Lunn
2024-02-22  7:16   ` Sverdlin, Alexander
2024-02-22 14:44     ` Andrew Lunn
2024-02-21 22:37 ` Andrew Lunn
2024-02-22  7:55   ` Sverdlin, Alexander
2024-02-22 14:55     ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox