Skip to contentSkip to conversation

cpuidle: avoid module usage in non-modular code

PATCH In review Paul Gortmaker 3 participants 7 messages Dec 13, 2015 – Dec 14, 2015

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

cover cpuidle: avoid module usage in non-modular code

This series of commits is a part of a larger project to ensure people don't reference modular support functions in non-modular code. Overall there was roughly 5k lines of dead code in the kernel due to this. So far we've fixed several areas, like tty, x86, net, ... and we continue to work on other areas.

There are several reasons to not use module support for code that can never be built as a module, but the big ones are:

(1) it is easy to accidentally code up 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.

Fortunately for cpuidle, the changes are largely trivial and change zero runtime. All the changes here just remap the modular functions onto the non-modular ones that they would be remapped onto anyway.

Changes are against linux-next and compile tested on ARM allmodconfig. I've Cc'd ARM list because all of these are used on ARM, but I'm thinking these probably can go in via the PM tree.

Paul.
---

Cc Alexander Shiyan <[email protected]>
Cc Bartlomiej Zolnierkiewicz <[email protected]>
Cc Daniel Lezcano <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc linux-pm at vger.kernel.org
Cc linux-samsung-soc at vger.kernel.org

Paul Gortmaker (3):
drivers/cpuidle: make cpuidle-clps711x.c explicitly non-modular drivers/cpuidle: make cpuidle-ux500.c explicitly non-modular drivers/cpuidle: make cpuidle-exynos.c explicitly non-modular

 drivers/cpuidle/cpuidle-clps711x.c | 8 ++------
 drivers/cpuidle/cpuidle-exynos.c   | 5 ++---
 drivers/cpuidle/cpuidle-ux500.c    | 5 ++---
 3 files changed, 6 insertions(+), 12 deletions(-)
Signature · 1 line
2.6.1
#1 lore raw

PATCH 1/3 drivers/cpuidle: make cpuidle-clps711x.c explicitly non-modular

The Kconfig currently controlling compilation of this code is:

drivers/cpuidle/Kconfig.arm:config ARM_CLPS711X_CPUIDLE
drivers/cpuidle/Kconfig.arm: bool "CPU Idle Driver for CLPS711X processors"

...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 "Rafael J. Wysocki" <[email protected]>
Cc Daniel Lezcano <[email protected]>
Cc Alexander Shiyan <[email protected]>
Cc linux-pm at vger.kernel.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/cpuidle/cpuidle-clps711x.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/cpuidle/cpuidle-clps711x.c +2 -6
index 18a7f7380508..66a9f231ec41 100644
@@ -12,7 +12,7 @@
 #include <linux/cpuidle.h>
 #include <linux/err.h>
 #include <linux/io.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/platform_device.h>
 
 #define CLPS711X_CPUIDLE_NAME	"clps711x-cpuidle"
@@ -56,8 +56,4 @@ static struct platform_driver clps711x_cpuidle_driver = {
 		.name	= CLPS711X_CPUIDLE_NAME,
 	},
 };
-module_platform_driver_probe(clps711x_cpuidle_driver, clps711x_cpuidle_probe);
-
-MODULE_AUTHOR("Alexander Shiyan <[email protected]>");
-MODULE_DESCRIPTION("CLPS711X CPU idle driver");
-MODULE_LICENSE("GPL");
+builtin_platform_driver_probe(clps711x_cpuidle_driver, clps711x_cpuidle_probe);
Signature · 1 line
2.6.1
#2 lore raw

PATCH 2/3 drivers/cpuidle: make cpuidle-ux500.c explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

cpuidle/Kconfig.arm:config ARM_U8500_CPUIDLE
cpuidle/Kconfig.arm: bool "Cpu Idle Driver for the ST-E u8500 processors"

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

Lets remove the couple traces of modularity 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.

Cc "Rafael J. Wysocki" <[email protected]>
Cc Daniel Lezcano <[email protected]>
Cc linux-pm at vger.kernel.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/cpuidle/cpuidle-ux500.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/cpuidle/cpuidle-ux500.c +2 -3
index 8bf895c0017d..7941a090bea6 100644
@@ -9,7 +9,7 @@
  * published by the Free Software Foundation.
  */
 
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/cpuidle.h>
 #include <linux/spinlock.h>
 #include <linux/atomic.h>
@@ -124,5 +124,4 @@ static struct platform_driver dbx500_cpuidle_plat_driver = {
 	},
 	.probe = dbx500_cpuidle_probe,
 };
-
-module_platform_driver(dbx500_cpuidle_plat_driver);
+builtin_platform_driver(dbx500_cpuidle_plat_driver);
Signature · 1 line
2.6.1
#3 lore raw

PATCH 3/3 drivers/cpuidle: make cpuidle-exynos.c explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

cpuidle/Kconfig.arm:config ARM_EXYNOS_CPUIDLE
cpuidle/Kconfig.arm: bool "Cpu Idle Driver for the Exynos processors"

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

Lets remove the couple traces of modularity 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.

Cc Bartlomiej Zolnierkiewicz <[email protected]>
Cc Daniel Lezcano <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc linux-pm at vger.kernel.org
Cc linux-samsung-soc at vger.kernel.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/cpuidle/cpuidle-exynos.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/cpuidle/cpuidle-exynos.c +2 -3
index b5f0a9cc8185..00cd129b10a4 100644
@@ -14,7 +14,7 @@
 #include <linux/cpuidle.h>
 #include <linux/cpu_pm.h>
 #include <linux/export.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
 #include <linux/platform_data/cpuidle-exynos.h>
@@ -142,5 +142,4 @@ static struct platform_driver exynos_cpuidle_driver = {
 		.name = "exynos_cpuidle",
 	},
 };
-
-module_platform_driver(exynos_cpuidle_driver);
+builtin_platform_driver(exynos_cpuidle_driver);
Signature · 1 line
2.6.1
#4 lore raw
In reply to Paul Gortmaker
Quoted 15 lines · Paul Gortmaker

This series of commits is a part of a larger project to ensure people don't reference modular support functions in non-modular code. Overall there was roughly 5k lines of dead code in the kernel due to this. So far we've fixed several areas, like tty, x86, net, ... and we continue to work on other areas.

There are several reasons to not use module support for code that can never be built as a module, but the big ones are:

(1) it is easy to accidentally code up 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.

Quoted 7 lines

Fortunately for cpuidle, the changes are largely trivial and change zero runtime. All the changes here just remap the modular functions onto the non-modular ones that they would be remapped onto anyway.

Changes are against linux-next and compile tested on ARM allmodconfig. I've Cc'd ARM list because all of these are used on ARM, but I'm thinking these probably can go in via the PM tree.

If no one objects, I can queue up this series for 4.5 unless you have other plans with respect to it.

Thanks,
Rafael

Acked-by on the v1 series
#6 lore raw
In reply to Paul Gortmaker
Quoted 15 lines · Paul Gortmaker

This series of commits is a part of a larger project to ensure people don't reference modular support functions in non-modular code. Overall there was roughly 5k lines of dead code in the kernel due to this. So far we've fixed several areas, like tty, x86, net, ... and we continue to work on other areas.

There are several reasons to not use module support for code that can never be built as a module, but the big ones are:

(1) it is easy to accidentally code up 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.

Quoted 7 lines

Fortunately for cpuidle, the changes are largely trivial and change zero runtime. All the changes here just remap the modular functions onto the non-modular ones that they would be remapped onto anyway.

Changes are against linux-next and compile tested on ARM allmodconfig. I've Cc'd ARM list because all of these are used on ARM, but I'm thinking these probably can go in via the PM tree.

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#5 lore raw
In reply to Rafael J. Wysocki
Quoted 6 lines · [Re: [PATCH 0/3] cpuidle: avoid module usage in non-modular code] On…
Quoted 5 lines · Paul Gortmaker

This series of commits is a part of a larger project to ensure people don't reference modular support functions in non-modular code. Overall there was roughly 5k lines of dead code in the kernel due to this. So far we've fixed several areas, like tty, x86, net, ... and we continue to work on other areas.

[...]

Quoted 3 lines

If no one objects, I can queue up this series for 4.5 unless you have other plans with respect to it.

Please do.

I was hoping to spread as many of these around as possible so I don't end up with a giant pull request to Linus. There is code out there without a clear maintainership path, so eventually I'll have to send some his way (or via akpm) but the less that end up in that pile, the better IMHO.

Thanks,
Paul.
--

Quoted 4 lines

Thanks,
Rafael