* [PATCH 0/3] leds: avoid module usage in non-modular code
@ 2015-12-13 21:45 Paul Gortmaker
2015-12-13 21:45 ` [PATCH 1/3] drivers/leds: make trigger/ledtrig-cpu.c driver explicitly non-modular Paul Gortmaker
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Paul Gortmaker @ 2015-12-13 21:45 UTC (permalink / raw)
To: linux-kernel
Cc: Paul Gortmaker, Bryan Wu, Linus Walleij, Jacek Anaszewski,
Richard Purdie, linux-leds
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.
For the LED subsystem, there are just three commits. Two are basically
trivial remapping to the appropriate non-modular counterparts. The
third also has a change to block driver unbinding since that doesn't
make any sense and it allows us to delete the .remove code. We've
already made similar unbind changes like this in drivers/tty.
Patches created on linux-next and build tested for ARM allmodconfig.
Paul.
---
Cc: Bryan Wu <cooloney@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: linux-leds@vger.kernel.org
Paul Gortmaker (3):
drivers/leds: make trigger/ledtrig-cpu.c driver explicitly non-modular
drivers/leds: make trigger/ledtrig-ide-disk.c driver explicitly non-modular
drivers/leds: make leds-syscon.c explicitly non-modular
drivers/leds/leds-syscon.c | 18 +++---------------
drivers/leds/trigger/ledtrig-cpu.c | 26 +-------------------------
drivers/leds/trigger/ledtrig-ide-disk.c | 14 +-------------
3 files changed, 5 insertions(+), 53 deletions(-)
--
2.6.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] drivers/leds: make trigger/ledtrig-cpu.c driver explicitly non-modular
2015-12-13 21:45 [PATCH 0/3] leds: avoid module usage in non-modular code Paul Gortmaker
@ 2015-12-13 21:45 ` Paul Gortmaker
2015-12-15 13:28 ` Linus Walleij
2015-12-13 21:45 ` [PATCH 2/3] drivers/leds: make trigger/ledtrig-ide-disk.c " Paul Gortmaker
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Paul Gortmaker @ 2015-12-13 21:45 UTC (permalink / raw)
To: linux-kernel
Cc: Paul Gortmaker, Bryan Wu, Richard Purdie, Jacek Anaszewski,
Linus Walleij, linux-leds
The Kconfig for this driver is currently:
config LEDS_TRIGGER_CPU
bool "LED CPU Trigger"
...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_init translates to device_initcall in the non-modular
case, 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: Bryan Wu <cooloney@gmail.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-leds@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
drivers/leds/trigger/ledtrig-cpu.c | 26 +-------------------------
1 file changed, 1 insertion(+), 25 deletions(-)
diff --git a/drivers/leds/trigger/ledtrig-cpu.c b/drivers/leds/trigger/ledtrig-cpu.c
index aec0f02b6b3e..938467fb82be 100644
--- a/drivers/leds/trigger/ledtrig-cpu.c
+++ b/drivers/leds/trigger/ledtrig-cpu.c
@@ -19,7 +19,6 @@
*
*/
-#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/slab.h>
@@ -140,27 +139,4 @@ static int __init ledtrig_cpu_init(void)
return 0;
}
-module_init(ledtrig_cpu_init);
-
-static void __exit ledtrig_cpu_exit(void)
-{
- int cpu;
-
- unregister_cpu_notifier(&ledtrig_cpu_nb);
-
- for_each_possible_cpu(cpu) {
- struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);
-
- led_trigger_unregister_simple(trig->_trig);
- trig->_trig = NULL;
- memset(trig->name, 0, MAX_NAME_LEN);
- }
-
- unregister_syscore_ops(&ledtrig_cpu_syscore_ops);
-}
-module_exit(ledtrig_cpu_exit);
-
-MODULE_AUTHOR("Linus Walleij <linus.walleij@linaro.org>");
-MODULE_AUTHOR("Bryan Wu <bryan.wu@canonical.com>");
-MODULE_DESCRIPTION("CPU LED trigger");
-MODULE_LICENSE("GPL");
+device_initcall(ledtrig_cpu_init);
--
2.6.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] drivers/leds: make trigger/ledtrig-ide-disk.c driver explicitly non-modular
2015-12-13 21:45 [PATCH 0/3] leds: avoid module usage in non-modular code Paul Gortmaker
2015-12-13 21:45 ` [PATCH 1/3] drivers/leds: make trigger/ledtrig-cpu.c driver explicitly non-modular Paul Gortmaker
@ 2015-12-13 21:45 ` Paul Gortmaker
2015-12-13 21:45 ` [PATCH 3/3] drivers/leds: make leds-syscon.c " Paul Gortmaker
2015-12-14 9:21 ` [PATCH 0/3] leds: avoid module usage in non-modular code Jacek Anaszewski
3 siblings, 0 replies; 6+ messages in thread
From: Paul Gortmaker @ 2015-12-13 21:45 UTC (permalink / raw)
To: linux-kernel
Cc: Paul Gortmaker, Bryan Wu, Richard Purdie, Jacek Anaszewski,
linux-leds
The Kconfig for this driver is currently:
config LEDS_TRIGGER_IDE_DISK
bool "LED IDE Disk Trigger"
...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_init translates to device_initcall in the non-modular
case, 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: Bryan Wu <cooloney@gmail.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: linux-leds@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
drivers/leds/trigger/ledtrig-ide-disk.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/drivers/leds/trigger/ledtrig-ide-disk.c b/drivers/leds/trigger/ledtrig-ide-disk.c
index 2cd7c0cf5924..c02a3ac3cd2b 100644
--- a/drivers/leds/trigger/ledtrig-ide-disk.c
+++ b/drivers/leds/trigger/ledtrig-ide-disk.c
@@ -11,7 +11,6 @@
*
*/
-#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/leds.h>
@@ -33,15 +32,4 @@ static int __init ledtrig_ide_init(void)
led_trigger_register_simple("ide-disk", &ledtrig_ide);
return 0;
}
-
-static void __exit ledtrig_ide_exit(void)
-{
- led_trigger_unregister_simple(ledtrig_ide);
-}
-
-module_init(ledtrig_ide_init);
-module_exit(ledtrig_ide_exit);
-
-MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>");
-MODULE_DESCRIPTION("LED IDE Disk Activity Trigger");
-MODULE_LICENSE("GPL");
+device_initcall(ledtrig_ide_init);
--
2.6.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] drivers/leds: make leds-syscon.c explicitly non-modular
2015-12-13 21:45 [PATCH 0/3] leds: avoid module usage in non-modular code Paul Gortmaker
2015-12-13 21:45 ` [PATCH 1/3] drivers/leds: make trigger/ledtrig-cpu.c driver explicitly non-modular Paul Gortmaker
2015-12-13 21:45 ` [PATCH 2/3] drivers/leds: make trigger/ledtrig-ide-disk.c " Paul Gortmaker
@ 2015-12-13 21:45 ` Paul Gortmaker
2015-12-14 9:21 ` [PATCH 0/3] leds: avoid module usage in non-modular code Jacek Anaszewski
3 siblings, 0 replies; 6+ messages in thread
From: Paul Gortmaker @ 2015-12-13 21:45 UTC (permalink / raw)
To: linux-kernel; +Cc: Paul Gortmaker, Richard Purdie, Jacek Anaszewski, linux-leds
The Kconfig currently controlling compilation of this code is:
drivers/leds/Kconfig:config LEDS_SYSCON
drivers/leds/Kconfig: bool "LED support for LEDs on system controllers"
...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.
Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: linux-leds@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
drivers/leds/leds-syscon.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/drivers/leds/leds-syscon.c b/drivers/leds/leds-syscon.c
index b88900d721e4..3be40f74f12a 100644
--- a/drivers/leds/leds-syscon.c
+++ b/drivers/leds/leds-syscon.c
@@ -20,7 +20,7 @@
* MA 02111-1307 USA
*/
#include <linux/io.h>
-#include <linux/module.h>
+#include <linux/init.h>
#include <linux/of_device.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
@@ -139,29 +139,17 @@ static int syscon_led_probe(struct platform_device *pdev)
return 0;
}
-static int syscon_led_remove(struct platform_device *pdev)
-{
- struct syscon_led *sled = platform_get_drvdata(pdev);
-
- led_classdev_unregister(&sled->cdev);
- /* Turn it off */
- regmap_update_bits(sled->map, sled->offset, sled->mask, 0);
- return 0;
-}
-
static const struct of_device_id of_syscon_leds_match[] = {
{ .compatible = "register-bit-led", },
{},
};
-MODULE_DEVICE_TABLE(of, of_syscon_leds_match);
-
static struct platform_driver syscon_led_driver = {
.probe = syscon_led_probe,
- .remove = syscon_led_remove,
.driver = {
.name = "leds-syscon",
.of_match_table = of_syscon_leds_match,
+ .suppress_bind_attrs = true,
},
};
-module_platform_driver(syscon_led_driver);
+builtin_platform_driver(syscon_led_driver);
--
2.6.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] leds: avoid module usage in non-modular code
2015-12-13 21:45 [PATCH 0/3] leds: avoid module usage in non-modular code Paul Gortmaker
` (2 preceding siblings ...)
2015-12-13 21:45 ` [PATCH 3/3] drivers/leds: make leds-syscon.c " Paul Gortmaker
@ 2015-12-14 9:21 ` Jacek Anaszewski
3 siblings, 0 replies; 6+ messages in thread
From: Jacek Anaszewski @ 2015-12-14 9:21 UTC (permalink / raw)
To: Paul Gortmaker
Cc: linux-kernel, Bryan Wu, Linus Walleij, Richard Purdie, linux-leds
On 12/13/2015 10:45 PM, Paul Gortmaker wrote:
> 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.
>
> For the LED subsystem, there are just three commits. Two are basically
> trivial remapping to the appropriate non-modular counterparts. The
> third also has a change to block driver unbinding since that doesn't
> make any sense and it allows us to delete the .remove code. We've
> already made similar unbind changes like this in drivers/tty.
>
> Patches created on linux-next and build tested for ARM allmodconfig.
>
> Paul.
> ---
>
> Cc: Bryan Wu <cooloney@gmail.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Jacek Anaszewski <j.anaszewski@samsung.com>
> Cc: Richard Purdie <rpurdie@rpsys.net>
> Cc: linux-leds@vger.kernel.org
>
> Paul Gortmaker (3):
> drivers/leds: make trigger/ledtrig-cpu.c driver explicitly non-modular
> drivers/leds: make trigger/ledtrig-ide-disk.c driver explicitly non-modular
> drivers/leds: make leds-syscon.c explicitly non-modular
>
> drivers/leds/leds-syscon.c | 18 +++---------------
> drivers/leds/trigger/ledtrig-cpu.c | 26 +-------------------------
> drivers/leds/trigger/ledtrig-ide-disk.c | 14 +-------------
> 3 files changed, 5 insertions(+), 53 deletions(-)
>
Patch set applied, thanks.
--
Best Regards,
Jacek Anaszewski
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] drivers/leds: make trigger/ledtrig-cpu.c driver explicitly non-modular
2015-12-13 21:45 ` [PATCH 1/3] drivers/leds: make trigger/ledtrig-cpu.c driver explicitly non-modular Paul Gortmaker
@ 2015-12-15 13:28 ` Linus Walleij
0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2015-12-15 13:28 UTC (permalink / raw)
To: Paul Gortmaker
Cc: linux-kernel@vger.kernel.org, Bryan Wu, Richard Purdie,
Jacek Anaszewski, linux-leds@vger.kernel.org
On Sun, Dec 13, 2015 at 10:45 PM, Paul Gortmaker
<paul.gortmaker@windriver.com> wrote:
> The Kconfig for this driver is currently:
>
> config LEDS_TRIGGER_CPU
> bool "LED CPU Trigger"
>
> ...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_init translates to device_initcall in the non-modular
> case, 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: Bryan Wu <cooloney@gmail.com>
> Cc: Richard Purdie <rpurdie@rpsys.net>
> Cc: Jacek Anaszewski <j.anaszewski@samsung.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: linux-leds@vger.kernel.org
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-12-15 13:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-13 21:45 [PATCH 0/3] leds: avoid module usage in non-modular code Paul Gortmaker
2015-12-13 21:45 ` [PATCH 1/3] drivers/leds: make trigger/ledtrig-cpu.c driver explicitly non-modular Paul Gortmaker
2015-12-15 13:28 ` Linus Walleij
2015-12-13 21:45 ` [PATCH 2/3] drivers/leds: make trigger/ledtrig-ide-disk.c " Paul Gortmaker
2015-12-13 21:45 ` [PATCH 3/3] drivers/leds: make leds-syscon.c " Paul Gortmaker
2015-12-14 9:21 ` [PATCH 0/3] leds: avoid module usage in non-modular code Jacek Anaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).