diff mbox series

[5/5] cpuidle: governor: Convert governors to modules

Message ID 20201015144431.9979-5-daniel.lezcano@linaro.org
State New
Headers show
Series [1/5] cpuidle: Remove pointless stub | expand

Commit Message

Daniel Lezcano Oct. 15, 2020, 2:44 p.m. UTC
This patch converts the cpuidle governors into modules. Even if it is
not the utmost importance, that will be consistent with the devfreq,
the watchdog and the cpufreq governors.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

---
 drivers/cpuidle/Kconfig              |  8 ++++----
 drivers/cpuidle/governors/haltpoll.c |  9 ++++++++-
 drivers/cpuidle/governors/ladder.c   | 12 ++++++++++--
 drivers/cpuidle/governors/menu.c     | 10 +++++++++-
 drivers/cpuidle/governors/teo.c      | 10 +++++++++-
 5 files changed, 40 insertions(+), 9 deletions(-)

-- 
2.17.1
diff mbox series

Patch

diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig
index c0aeedd66f02..ff83042edd50 100644
--- a/drivers/cpuidle/Kconfig
+++ b/drivers/cpuidle/Kconfig
@@ -19,13 +19,13 @@  config CPU_IDLE_MULTIPLE_DRIVERS
 	bool
 
 config CPU_IDLE_GOV_LADDER
-	bool "Ladder governor (for periodic timer tick)"
+	tristate "Ladder governor (for periodic timer tick)"
 
 config CPU_IDLE_GOV_MENU
-	bool "Menu governor (for tickless system)"
+	tristate "Menu governor (for tickless system)"
 
 config CPU_IDLE_GOV_TEO
-	bool "Timer events oriented (TEO) governor (for tickless systems)"
+	tristate "Timer events oriented (TEO) governor (for tickless systems)"
 	help
 	  This governor implements a simplified idle state selection method
 	  focused on timer events and does not do any interactivity boosting.
@@ -34,7 +34,7 @@  config CPU_IDLE_GOV_TEO
 	  to use.  Say Y here if you are not happy with the alternatives.
 
 config CPU_IDLE_GOV_HALTPOLL
-	bool "Haltpoll governor (for virtualized systems)"
+	tristate "Haltpoll governor (for virtualized systems)"
 	depends on KVM_GUEST
 	help
 	  This governor implements haltpoll idle state selection, to be
diff --git a/drivers/cpuidle/governors/haltpoll.c b/drivers/cpuidle/governors/haltpoll.c
index cb2a96eafc02..4756b758c324 100644
--- a/drivers/cpuidle/governors/haltpoll.c
+++ b/drivers/cpuidle/governors/haltpoll.c
@@ -146,4 +146,11 @@  static int __init init_haltpoll(void)
 	return 0;
 }
 
-postcore_initcall(init_haltpoll);
+static void __exit exit_haltpoll(void)
+{
+	cpuidle_unregister_governor(&haltpoll_governor);
+}
+
+module_init(init_haltpoll);
+module_exit(exit_haltpoll);
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/cpuidle/governors/ladder.c b/drivers/cpuidle/governors/ladder.c
index 8e9058c4ea63..78b622b75ce7 100644
--- a/drivers/cpuidle/governors/ladder.c
+++ b/drivers/cpuidle/governors/ladder.c
@@ -14,6 +14,7 @@ 
 
 #include <linux/kernel.h>
 #include <linux/cpuidle.h>
+#include <linux/module.h>
 #include <linux/jiffies.h>
 #include <linux/tick.h>
 
@@ -188,10 +189,17 @@  static int __init init_ladder(void)
 	 * governor is better so give it a higher rating than the menu
 	 * governor.
 	 */
-	if (!tick_nohz_enabled)
+	if (!tick_nohz_is_enabled())
 		ladder_governor.rating = 25;
 
 	return cpuidle_register_governor(&ladder_governor);
 }
 
-postcore_initcall(init_ladder);
+static void __exit exit_ladder(void)
+{
+	cpuidle_unregister_governor(&ladder_governor);
+}
+
+module_init(init_ladder);
+module_exit(exit_ladder);
+MODULE_LICENSE("GPL");
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index b0a7ad566081..fc92a5b18a7b 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -13,6 +13,7 @@ 
 #include <linux/time.h>
 #include <linux/ktime.h>
 #include <linux/hrtimer.h>
+#include <linux/module.h>
 #include <linux/tick.h>
 #include <linux/sched.h>
 #include <linux/sched/loadavg.h>
@@ -571,4 +572,11 @@  static int __init init_menu(void)
 	return cpuidle_register_governor(&menu_governor);
 }
 
-postcore_initcall(init_menu);
+static void __exit exit_menu(void)
+{
+	cpuidle_unregister_governor(&menu_governor);
+}
+
+module_init(init_menu);
+module_exit(exit_menu);
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c
index 6deaaf5f05b5..d11dab61113c 100644
--- a/drivers/cpuidle/governors/teo.c
+++ b/drivers/cpuidle/governors/teo.c
@@ -48,6 +48,7 @@ 
 #include <linux/cpuidle.h>
 #include <linux/jiffies.h>
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/sched/clock.h>
 #include <linux/tick.h>
 
@@ -491,4 +492,11 @@  static int __init teo_governor_init(void)
 	return cpuidle_register_governor(&teo_governor);
 }
 
-postcore_initcall(teo_governor_init);
+static void __exit teo_governor_exit(void)
+{
+	cpuidle_unregister_governor(&teo_governor);
+}
+
+module_init(teo_governor_init);
+module_exit(teo_governor_exit);
+MODULE_LICENSE("GPL v2");