Skip to contentSkip to conversation

PM / devfreq: remove modular references from non-modules

PATCH Superseded Paul Gortmaker 2 participants 7 messages Jun 21, 2016

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover PM / devfreq: remove modular references from non-modules

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 over 100 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/or export.h as required based on whether the file used it.

-the removal of any/all unused/orphaned __exit functions that
would never be called.

-the removal of any ".remove" functions that were hooked into
the driver struct. This ".remove" function would of
course not be called from the __exit function since that was never run. However in theory, someone could have triggered it via sysfs unbind, even though there isn't a sensible use case for doing so. So to cover that possibility, we've also disabled sysfs unbind in the driver.

There are no initcall level changes here; everything stays at the level of initcall it was previously - either by not using modular versions to begin with, or by using the builtin level equivalents.

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

If there is a desire for any of these to be modular, we can definitely consider that, but by default the changes here keep the code consistent with existing behaviour. Thus I do not expand functionality into the modular realm that I can't run time test, or even know if the modular instance has a sensible modular use case.

Paul.
---

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 explicitly non-modular PM / devfreq: make event/exynos-nocp explicitly non-modular PM / devfreq: make event/exynos-ppmu explicitly non-modular

 drivers/devfreq/devfreq-event.c     | 12 +-----------
 drivers/devfreq/devfreq.c           | 13 +------------
 drivers/devfreq/event/exynos-nocp.c | 19 +++----------------
 drivers/devfreq/event/exynos-ppmu.c |  8 ++------
 drivers/devfreq/exynos-bus.c        |  9 ++-------
 5 files changed, 9 insertions(+), 52 deletions(-)
Signature · 1 line
2.8.4
#1 lore raw

PATCH 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 1d6c803804d5..6723f31c3973 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>
@@ -1198,13 +1198,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.
@@ -1470,7 +1463,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
#3 lore raw

PATCH 3/5 PM / devfreq: make exynos-bus explicitly non-modular

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.

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

Since module_platform_driver() uses the same init level priority as builtin_platform_driver() the init ordering remains unchanged with this commit.

Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

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 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/exynos-bus.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/devfreq/exynos-bus.c +2 -7
index 2363d0a189b7..2e018d80e0f7 100644
@@ -17,7 +17,7 @@
 #include <linux/devfreq-event.h>
 #include <linux/device.h>
 #include <linux/export.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/of_device.h>
 #include <linux/pm_opp.h>
 #include <linux/platform_device.h>
@@ -553,7 +553,6 @@ static const struct of_device_id exynos_bus_of_match[] = {
 	{ .compatible = "samsung,exynos-bus", },
 	{ /* sentinel */ },
 };
-MODULE_DEVICE_TABLE(of, exynos_bus_of_match);
 
 static struct platform_driver exynos_bus_platdrv = {
 	.probe		= exynos_bus_probe,
@@ -563,8 +562,4 @@ static struct platform_driver exynos_bus_platdrv = {
 		.of_match_table = of_match_ptr(exynos_bus_of_match),
 	},
 };
-module_platform_driver(exynos_bus_platdrv);
-
-MODULE_DESCRIPTION("Generic Exynos Bus frequency driver");
-MODULE_AUTHOR("Chanwoo Choi <[email protected]>");
-MODULE_LICENSE("GPL v2");
+builtin_platform_driver(exynos_bus_platdrv);
Signature · 1 line
2.8.4
#4 lore raw

PATCH 4/5 PM / devfreq: make event/exynos-nocp explicitly non-modular

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.

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

We explicitly disallow a driver unbind, since that doesn't have a sensible use case anyway, and it allows us to drop the ".remove" code for non-modular drivers.

Since module_platform_driver() uses the same init level priority as builtin_platform_driver() the init ordering remains unchanged with this commit.

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 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/exynos-nocp.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)
drivers/devfreq/event/exynos-nocp.c +3 -16
index 6b6a5f310486..f954578abfdf 100644
@@ -10,7 +10,7 @@
  */
 
 #include <linux/clk.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/devfreq-event.h>
 #include <linux/kernel.h>
 #include <linux/of_address.h>
@@ -280,25 +280,12 @@ static int exynos_nocp_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int exynos_nocp_remove(struct platform_device *pdev)
-{
-	struct exynos_nocp *nocp = platform_get_drvdata(pdev);
-
-	clk_disable_unprepare(nocp->clk);
-
-	return 0;
-}
-
 static struct platform_driver exynos_nocp_driver = {
 	.probe	= exynos_nocp_probe,
-	.remove	= exynos_nocp_remove,
 	.driver = {
 		.name	= "exynos-nocp",
+		.suppress_bind_attrs = true,
 		.of_match_table = exynos_nocp_id_match,
 	},
 };
-module_platform_driver(exynos_nocp_driver);
-
-MODULE_DESCRIPTION("Exynos NoC (Network on Chip) Probe driver");
-MODULE_AUTHOR("Chanwoo Choi <[email protected]>");
-MODULE_LICENSE("GPL");
+builtin_platform_driver(exynos_nocp_driver);
Signature · 1 line
2.8.4
#5 lore raw

PATCH 5/5 PM / devfreq: make event/exynos-ppmu explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

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

...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.

Since module_platform_driver() uses the same init level priority as builtin_platform_driver() the init ordering remains unchanged with this commit.

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 Kukjin Kim <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Chanwoo Choi <[email protected]>
---
 drivers/devfreq/event/exynos-ppmu.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/devfreq/event/exynos-ppmu.c +2 -6
index f312485f1451..38a997807043 100644
@@ -14,7 +14,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/mutex.h>
 #include <linux/of_address.h>
 #include <linux/platform_device.h>
@@ -524,8 +524,4 @@ static struct platform_driver exynos_ppmu_driver = {
 		.of_match_table = exynos_ppmu_id_match,
 	},
 };
-module_platform_driver(exynos_ppmu_driver);
-
-MODULE_DESCRIPTION("Exynos PPMU(Platform Performance Monitoring Unit) driver");
-MODULE_AUTHOR("Chanwoo Choi <[email protected]>");
-MODULE_LICENSE("GPL");
+builtin_platform_driver(exynos_ppmu_driver);
Signature · 1 line
2.8.4
#2 lore raw

PATCH 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
#6 lore raw
In reply to Paul Gortmaker

Hi Paul,

It is good for devfreq/devfreq-event framework(patch1/patch2).

But, I think that the device driver (patch3/4/5) should change the type from 'bool' to 'tristate' instead of using the .

Thanks,
Chanwoo Choi

Quoted 72 lines · Paul Gortmaker

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 over 100 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/or export.h as required based on whether the file used it.

-the removal of any/all unused/orphaned __exit functions that
would never be called.

-the removal of any ".remove" functions that were hooked into
the driver struct. This ".remove" function would of
course not be called from the __exit function since that was never run. However in theory, someone could have triggered it via sysfs unbind, even though there isn't a sensible use case for doing so. So to cover that possibility, we've also disabled sysfs unbind in the driver.

There are no initcall level changes here; everything stays at the level of initcall it was previously - either by not using modular versions to begin with, or by using the builtin level equivalents.

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

If there is a desire for any of these to be modular, we can definitely consider that, but by default the changes here keep the code consistent with existing behaviour. Thus I do not expand functionality into the modular realm that I can't run time test, or even know if the modular instance has a sensible modular use case.

Paul.
---

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 explicitly non-modular PM / devfreq: make event/exynos-nocp explicitly non-modular PM / devfreq: make event/exynos-ppmu explicitly non-modular

 drivers/devfreq/devfreq-event.c     | 12 +-----------
 drivers/devfreq/devfreq.c           | 13 +------------
 drivers/devfreq/event/exynos-nocp.c | 19 +++----------------
 drivers/devfreq/event/exynos-ppmu.c |  8 ++------
 drivers/devfreq/exynos-bus.c        |  9 ++-------
 5 files changed, 9 insertions(+), 52 deletions(-)