Skip to contentSkip to conversation

PM / devfreq: make module code usage consistent.

PATCH In review Paul Gortmaker 2 participants 11 messages Jun 25, 2016 – Jun 27, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover PM / devfreq: make module code usage consistent.

For anyone new to the underlying goal of this cleanup, we are trying to not use module support for code that can never be built as a module since:

(1) it is easy to accidentally write unused module_exit and remove code
(2) it can be misleading when reading the source, thinking it can be modular when the Makefile and/or Kconfig prohibit it
(3) it requires the include of the module.h header file which in turn includes nearly everything else, thus adding to CPP overhead.
(4) it gets copied/replicated into other code and spreads like weeds.

We have already merged lots of these for mainline to date, so there is really nothing new to see here, in terms of the type of change.

That said, devfreq changes seen here cover the following categories:

-just replacement of modular macros with their non-modular
equivalents that CPP would have inserted anyway

-the removal of including module.h ; replaced with init.h
and export.h as required based on whether the file used it.

-the removal of the unused __exit functions that would never
be called.

-the conversion of 3 bool Kconfig to tristate to reflect the
module author's intended or re-evaluated choice. (new in v2).

There are no initcall level changes here; everything stays at the level of initcall it was previously; simply by the fact that it was not using modular versions to begin with.

Build tested for arm and arm64 allmodconfig (for which all the drivers touched here get coverage) on the linux-next tree from Fri. to ensure no silly typos crept in.

The three drivers converted from bool to trisate are done as per Chanwoo's request. I have confirmed they build and modpost to a .ko file but I don't have the hardware to test module loading and/or any other runtime behaviour.

Paul.
---

[v2: convert patch #3,4,5 from demodule cleanup to one line conversion
from bool to tristate; confirm =m after "allmodconfig"; retest.]

[v1: https://lkml.kernel.org/r/[email protected] ]

Cc Chanwoo Choi <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc MyungJoo Ham <[email protected]>

Paul Gortmaker (5):
PM / devfreq: make devfreq explicitly non-modular
PM / devfreq: make devfreq-event explicitly non-modular PM / devfreq: make exynos-bus ARM_EXYNOS_BUS_DEVFREQ tristate PM / devfreq: make event/exynos-nocp DEVFREQ_EVENT_EXYNOS_NOCP
tristate
PM / devfreq: make event/exynos-ppmu DEVFREQ_EVENT_EXYNOS_PPMU
tristate

 drivers/devfreq/Kconfig         |  2 +-
 drivers/devfreq/devfreq-event.c | 12 +-----------
 drivers/devfreq/devfreq.c       | 13 +------------
 drivers/devfreq/event/Kconfig   |  4 ++--
 4 files changed, 5 insertions(+), 26 deletions(-)
Signature · 1 line
2.8.4
#1 lore raw

PATCH v2 1/5 PM / devfreq: make devfreq explicitly non-modular

The Kconfig currently controlling compilation of this code is:

menuconfig PM_DEVFREQ
bool "Generic Dynamic Voltage and Frequency Scaling (DVFS) support"

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only.

This code wasn't using module_init, so we don't need to be concerned with altering the initcall level here.

We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.

We don't replace module.h with init.h since the file already has that. But we do add export.h since this file does export some symbols.

---
 drivers/devfreq/devfreq.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/devfreq/devfreq.c +1 -12
index e92418facc92..3cc558df8295 100644
@@ -15,7 +15,7 @@
 #include <linux/errno.h>
 #include <linux/err.h>
 #include <linux/init.h>
-#include <linux/module.h>
+#include <linux/export.h>
 #include <linux/slab.h>
 #include <linux/stat.h>
 #include <linux/pm_opp.h>
@@ -1199,13 +1199,6 @@ static int __init devfreq_init(void)
 }
 subsys_initcall(devfreq_init);
 
-static void __exit devfreq_exit(void)
-{
-	class_destroy(devfreq_class);
-	destroy_workqueue(devfreq_wq);
-}
-module_exit(devfreq_exit);
-
 /*
  * The followings are helper functions for devfreq user device drivers with
  * OPP framework.
@@ -1471,7 +1464,3 @@ void devm_devfreq_unregister_notifier(struct device *dev,
 			       devm_devfreq_dev_match, devfreq));
 }
 EXPORT_SYMBOL(devm_devfreq_unregister_notifier);
-
-MODULE_AUTHOR("MyungJoo Ham <[email protected]>");
-MODULE_DESCRIPTION("devfreq class support");
-MODULE_LICENSE("GPL");
Signature · 1 line
2.8.4
maintainer Reviewed-by on v2 1/5
#2 lore raw

Re: [PATCH 1/5] PM / devfreq: make devfreq explicitly non-modular

Hi Paul,

Quoted 19 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

menuconfig PM_DEVFREQ
bool "Generic Dynamic Voltage and Frequency Scaling (DVFS) support"

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only.

This code wasn't using module_init, so we don't need to be concerned with altering the initcall level here.

We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.

We don't replace module.h with init.h since the file already has that. But we do add export.h since this file does export some symbols.

Quoted 7 lines
---
 drivers/devfreq/devfreq.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

Regards,
Chanwoo Choi

#3 lore raw

PATCH v2 2/5 PM / devfreq: make devfreq-event explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

menuconfig PM_DEVFREQ_EVENT
bool "DEVFREQ-Event device Support"

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only.

This code wasn't using module_init, so we don't need to be concerned with altering the initcall level here.

We don't replace module.h with init.h since the file already has that. But we do add export.h since this file does export some symbols.

We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.

Cc MyungJoo Ham <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Chanwoo Choi <[email protected]>
---
 drivers/devfreq/devfreq-event.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/devfreq/devfreq-event.c +1 -11
index 39b048eda2ce..9aea2c7ecbe6 100644
@@ -15,7 +15,7 @@
 #include <linux/kernel.h>
 #include <linux/err.h>
 #include <linux/init.h>
-#include <linux/module.h>
+#include <linux/export.h>
 #include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/of.h>
@@ -481,13 +481,3 @@ static int __init devfreq_event_init(void)
 	return 0;
 }
 subsys_initcall(devfreq_event_init);
-
-static void __exit devfreq_event_exit(void)
-{
-	class_destroy(devfreq_event_class);
-}
-module_exit(devfreq_event_exit);
-
-MODULE_AUTHOR("Chanwoo Choi <[email protected]>");
-MODULE_DESCRIPTION("DEVFREQ-Event class support");
-MODULE_LICENSE("GPL");
Signature · 1 line
2.8.4
maintainer Acked-by on v2 2/5
#4 lore raw

Re: [PATCH 2/5] PM / devfreq: make devfreq-event explicitly non-modular

Hi Paul,

Quoted 19 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

menuconfig PM_DEVFREQ_EVENT
bool "DEVFREQ-Event device Support"

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only.

This code wasn't using module_init, so we don't need to be concerned with altering the initcall level here.

We don't replace module.h with init.h since the file already has that. But we do add export.h since this file does export some symbols.

We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.

Quoted 8 lines
Cc MyungJoo Ham <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Chanwoo Choi <[email protected]>
---
 drivers/devfreq/devfreq-event.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

Regards,
Chanwoo Choi

#5 lore raw

PATCH v2 3/5 PM / devfreq: make exynos-bus ARM_EXYNOS_BUS_DEVFREQ tristate

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

devfreq/Kconfig:config ARM_EXYNOS_BUS_DEVFREQ
devfreq/Kconfig: bool "ARM EXYNOS Generic Memory Bus DEVFREQ Driver"

...meaning that it currently is not being built as a module by anyone.

Rather than rip out the existing modular code, Chanwoo indicated that he'd rather see the driver offered as tristate.

I don't have the hardware for runtime validation, so this change is only validated for compile and modpost.

Cc Chanwoo Choi <[email protected]>
Cc MyungJoo Ham <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
---
 drivers/devfreq/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/devfreq/Kconfig +1 -1
index 78dac0e9da11..a5be56ec57f2 100644
@@ -75,7 +75,7 @@ config DEVFREQ_GOV_PASSIVE
 comment "DEVFREQ Drivers"
 
 config ARM_EXYNOS_BUS_DEVFREQ
-	bool "ARM EXYNOS Generic Memory Bus DEVFREQ Driver"
+	tristate "ARM EXYNOS Generic Memory Bus DEVFREQ Driver"
 	depends on ARCH_EXYNOS
 	select DEVFREQ_GOV_SIMPLE_ONDEMAND
 	select DEVFREQ_GOV_PASSIVE
Signature · 1 line
2.8.4
maintainer Acked-by on v2 3/5
#6 lore raw

Re: [PATCH 3/5] PM / devfreq: make exynos-bus ARM_EXYNOS_BUS_DEVFREQ tristate

Hi Paul,

Quoted 31 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

devfreq/Kconfig:config ARM_EXYNOS_BUS_DEVFREQ
devfreq/Kconfig: bool "ARM EXYNOS Generic Memory Bus DEVFREQ Driver"

...meaning that it currently is not being built as a module by anyone.

Rather than rip out the existing modular code, Chanwoo indicated that he'd rather see the driver offered as tristate.

I don't have the hardware for runtime validation, so this change is only validated for compile and modpost.

Cc Chanwoo Choi <[email protected]>
Cc MyungJoo Ham <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
---
 drivers/devfreq/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/devfreq/Kconfig +0 -0
index 78dac0e9da11..a5be56ec57f2 100644

drivers/devfreq/Kconfig config DEVFREQ_GOV_PASSIVE · line 81

Quoted 8 lines
drivers/devfreq/Kconfig +1 -1
@@ -75,7 +75,7 @@ config DEVFREQ_GOV_PASSIVE
 comment "DEVFREQ Drivers"
 
 config ARM_EXYNOS_BUS_DEVFREQ
-	bool "ARM EXYNOS Generic Memory Bus DEVFREQ Driver"
+	tristate "ARM EXYNOS Generic Memory Bus DEVFREQ Driver"
 	depends on ARCH_EXYNOS
 	select DEVFREQ_GOV_SIMPLE_ONDEMAND
 	select DEVFREQ_GOV_PASSIVE

Regards,
Chanwoo Choi

#7 lore raw

PATCH v2 4/5 PM / devfreq: make event/exynos-nocp DEVFREQ_EVENT_EXYNOS_NOCP tristate

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

event/Kconfig:config DEVFREQ_EVENT_EXYNOS_NOCP
event/Kconfig: bool "EXYNOS NoC (Network On Chip) Probe DEVFREQ event Driver"

...meaning that it currently is not being built as a module by anyone.

Rather than rip out the existing modular code, Chanwoo indicated that he'd rather see the driver offered as tristate.

I don't have the hardware for runtime validation, so this change is only validated for compile and modpost.

Cc Chanwoo Choi <[email protected]>
Cc MyungJoo Ham <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
---
 drivers/devfreq/event/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/devfreq/event/Kconfig +1 -1
index 1e8b4f469f38..96ea29d1ede5 100644
@@ -14,7 +14,7 @@ menuconfig PM_DEVFREQ_EVENT
 if PM_DEVFREQ_EVENT
 
 config DEVFREQ_EVENT_EXYNOS_NOCP
-	bool "EXYNOS NoC (Network On Chip) Probe DEVFREQ event Driver"
+	tristate "EXYNOS NoC (Network On Chip) Probe DEVFREQ event Driver"
 	depends on ARCH_EXYNOS
 	select PM_OPP
 	help
Signature · 1 line
2.8.4
maintainer Acked-by on v2 4/5
#8 lore raw

Re: [PATCH 4/5] PM / devfreq: make event/exynos-nocp DEVFREQ_EVENT_EXYNOS_NOCP tristate

Hi Paul,

Quoted 31 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

event/Kconfig:config DEVFREQ_EVENT_EXYNOS_NOCP
event/Kconfig: bool "EXYNOS NoC (Network On Chip) Probe DEVFREQ event Driver"

...meaning that it currently is not being built as a module by anyone.

Rather than rip out the existing modular code, Chanwoo indicated that he'd rather see the driver offered as tristate.

I don't have the hardware for runtime validation, so this change is only validated for compile and modpost.

Cc Chanwoo Choi <[email protected]>
Cc MyungJoo Ham <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
---
 drivers/devfreq/event/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/devfreq/event/Kconfig +0 -0
index 1e8b4f469f38..96ea29d1ede5 100644

drivers/devfreq/event/Kconfig menuconfig PM_DEVFREQ_EVENT · line 20

Quoted 8 lines
drivers/devfreq/event/Kconfig +1 -1
@@ -14,7 +14,7 @@ menuconfig PM_DEVFREQ_EVENT
 if PM_DEVFREQ_EVENT
 
 config DEVFREQ_EVENT_EXYNOS_NOCP
-	bool "EXYNOS NoC (Network On Chip) Probe DEVFREQ event Driver"
+	tristate "EXYNOS NoC (Network On Chip) Probe DEVFREQ event Driver"
 	depends on ARCH_EXYNOS
 	select PM_OPP
 	help

Regards,
Chanwoo Choi

#9 lore raw

PATCH v2 5/5 PM / devfreq: make event/exynos-ppmu DEVFREQ_EVENT_EXYNOS_PPMU tristate

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config DEVFREQ_EVENT_EXYNOS_PPMU
bool "EXYNOS PPMU (Platform Performance Monitoring Unit) DEVFREQ event Driver"

...meaning that it currently is not being built as a module by anyone.

Rather than rip out the existing modular code, Chanwoo indicated that he'd rather see the driver offered as tristate.

I don't have the hardware for runtime validation, so this change is only validated for compile and modpost.

Cc MyungJoo Ham <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Chanwoo Choi <[email protected]>
---
 drivers/devfreq/event/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/devfreq/event/Kconfig +1 -1
index 96ea29d1ede5..eb6f74a2b6b9 100644
@@ -22,7 +22,7 @@ config DEVFREQ_EVENT_EXYNOS_NOCP
 	  (Network on Chip) Probe counters to measure the bandwidth of AXI bus.
 
 config DEVFREQ_EVENT_EXYNOS_PPMU
-	bool "EXYNOS PPMU (Platform Performance Monitoring Unit) DEVFREQ event Driver"
+	tristate "EXYNOS PPMU (Platform Performance Monitoring Unit) DEVFREQ event Driver"
 	depends on ARCH_EXYNOS
 	select PM_OPP
 	help
Signature · 1 line
2.8.4
maintainer Acked-by on v2 5/5
#10 lore raw

Re: [PATCH 5/5] PM / devfreq: make event/exynos-ppmu DEVFREQ_EVENT_EXYNOS_PPMU tristate

Hi Paul,

Quoted 31 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config DEVFREQ_EVENT_EXYNOS_PPMU
bool "EXYNOS PPMU (Platform Performance Monitoring Unit) DEVFREQ event Driver"

...meaning that it currently is not being built as a module by anyone.

Rather than rip out the existing modular code, Chanwoo indicated that he'd rather see the driver offered as tristate.

I don't have the hardware for runtime validation, so this change is only validated for compile and modpost.

Cc MyungJoo Ham <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Chanwoo Choi <[email protected]>
---
 drivers/devfreq/event/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/devfreq/event/Kconfig +0 -0
index 96ea29d1ede5..eb6f74a2b6b9 100644

drivers/devfreq/event/Kconfig config DEVFREQ_EVENT_EXYNOS_NOCP · line 28

Quoted 8 lines
drivers/devfreq/event/Kconfig +1 -1
@@ -22,7 +22,7 @@ config DEVFREQ_EVENT_EXYNOS_NOCP
 	  (Network on Chip) Probe counters to measure the bandwidth of AXI bus.
 
 config DEVFREQ_EVENT_EXYNOS_PPMU
-	bool "EXYNOS PPMU (Platform Performance Monitoring Unit) DEVFREQ event Driver"
+	tristate "EXYNOS PPMU (Platform Performance Monitoring Unit) DEVFREQ event Driver"
 	depends on ARCH_EXYNOS
 	select PM_OPP
 	help

Regards,
Chanwoo Choi