cpuidle: avoid module usage in non-modular code
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.
---
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
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_CPUIDLEdrivers/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.
--- drivers/cpuidle/cpuidle-clps711x.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/cpuidle/cpuidle-clps711x.c +2 -6
@@ -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
PATCH 2/3 drivers/cpuidle: make cpuidle-ux500.c explicitly non-modular
In reply to Paul GortmakerThe 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.
--- drivers/cpuidle/cpuidle-ux500.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/cpuidle/cpuidle-ux500.c +2 -3
@@ -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
PATCH 3/3 drivers/cpuidle: make cpuidle-exynos.c explicitly non-modular
In reply to Paul GortmakerThe 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.
--- drivers/cpuidle/cpuidle-exynos.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/cpuidle/cpuidle-exynos.c +2 -3
@@ -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
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_exitand remove code
(2) it can be misleading when reading the source, thinking it can be modular when theMakefileand/orKconfigprohibit it
(3) it requires the include of themodule.hheader 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
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_exitand remove code
(2) it can be misleading when reading the source, thinking it can be modular when theMakefileand/orKconfigprohibit it
(3) it requires the include of themodule.hheader 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
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