Skip to contentSkip to conversation

wdt: clean up unused modular infrastructure

PATCH In review Paul Gortmaker 5 participants 18 messages Apr 23, 2019 – May 12, 2019

Subsystems (2)
lore
Share & tools
lore
#12 lore raw

PATCH 4/5 watchdog: intel_scu: make it explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config INTEL_SCU_WATCHDOG
bool "Intel SCU Watchdog for Mobile Platforms"

...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 also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.

We leave the moduleparam.h include since the file does declare some module parameters, and leaving them as such is currently the easiest way to remain compatible with existing boot arg use cases.

---
 drivers/watchdog/intel_scu_watchdog.c | 18 ------------------
 1 file changed, 18 deletions(-)
drivers/watchdog/intel_scu_watchdog.c +0 -18
index 0caab6241eb7..32bc5611f0cc 100644
@@ -25,7 +25,6 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/compiler.h>
-#include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/moduleparam.h>
 #include <linux/types.h>
@@ -545,21 +544,4 @@ static int __init intel_scu_watchdog_init(void)
 	iounmap(watchdog_device.timer_load_count_addr);
 	return ret;
 }
-
-static void __exit intel_scu_watchdog_exit(void)
-{
-
-	misc_deregister(&watchdog_device.miscdev);
-	unregister_reboot_notifier(&watchdog_device.intel_scu_notifier);
-	/* disable the timer */
-	iowrite32(0x00000002, watchdog_device.timer_control_addr);
-	iounmap(watchdog_device.timer_load_count_addr);
-}
-
 late_initcall(intel_scu_watchdog_init);
-module_exit(intel_scu_watchdog_exit);
-
-MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION("Intel SCU Watchdog Device Driver");
-MODULE_LICENSE("GPL");
-MODULE_VERSION(WDT_VER);
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/5 watchdog: rtd119x: drop unused module.h include

In reply to Paul Gortmaker

The Kconfig for this driver is:

config RTD119X_WATCHDOG
bool "Realtek RTD118x/RTD129x watchdog support"

...and hence it doesn't need to include module.h for anything. There are no other signs of unused modular infrastructure.

---
 drivers/watchdog/rtd119x_wdt.c | 1 -
 1 file changed, 1 deletion(-)
drivers/watchdog/rtd119x_wdt.c +0 -1
index d001c17ddfde..a0787a50ac6d 100644
@@ -9,7 +9,6 @@
 #include <linux/bitops.h>
 #include <linux/clk.h>
 #include <linux/io.h>
-#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/platform_device.h>
Signature · 1 line
2.7.4
#14 lore raw

PATCH 5/5 watchdog: coh901327: make it explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config COH901327_WATCHDOG
bool "ST-Ericsson COH 901 327 watchdog"

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

We replace module.h with moduleparam.h since the file does actually declare some module parameters (i.e. boot args for non-modules).

Cc Linus Walleij <[email protected]>
Cc Wim Van Sebroeck <[email protected]>
Cc Guenter Roeck <[email protected]>
---
 drivers/watchdog/coh901327_wdt.c | 24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)
drivers/watchdog/coh901327_wdt.c +4 -20
index f29d1edc5bad..5914cc767c87 100644
@@ -6,7 +6,7 @@
  * Watchdog driver for the ST-Ericsson AB COH 901 327 IP core
  * Author: Linus Walleij <[email protected]>
  */
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/mod_devicetable.h>
 #include <linux/types.h>
 #include <linux/watchdog.h>
@@ -243,16 +243,6 @@ static struct watchdog_device coh901327_wdt = {
 	.timeout = U300_WDOG_DEFAULT_TIMEOUT,
 };
 
-static int __exit coh901327_remove(struct platform_device *pdev)
-{
-	watchdog_unregister_device(&coh901327_wdt);
-	coh901327_disable();
-	free_irq(irq, pdev);
-	clk_disable_unprepare(clk);
-	clk_put(clk);
-	return 0;
-}
-
 static int __init coh901327_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -408,19 +398,13 @@ static struct platform_driver coh901327_driver = {
 	.driver = {
 		.name	= "coh901327_wdog",
 		.of_match_table = coh901327_dt_match,
+		.suppress_bind_attrs = true,
 	},
-	.remove		= __exit_p(coh901327_remove),
 	.suspend	= coh901327_suspend,
 	.resume		= coh901327_resume,
 };
+builtin_platform_driver_probe(coh901327_driver, coh901327_probe);
 
-module_platform_driver_probe(coh901327_driver, coh901327_probe);
-
-MODULE_AUTHOR("Linus Walleij <[email protected]>");
-MODULE_DESCRIPTION("COH 901 327 Watchdog");
-
+/* not really modular, but ... */
 module_param(margin, uint, 0);
 MODULE_PARM_DESC(margin, "Watchdog margin in seconds (default 60s)");
-
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("platform:coh901327-watchdog");
Signature · 1 line
2.7.4
#3 lore raw

PATCH 2/5 watchdog: watchdog_core: make it explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config WATCHDOG_CORE
bool "WatchDog Timer Driver Core"

...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 replace module.h with export.h since the file does export some symbols. We don't add init.h since the file already has that.

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 Wim Van Sebroeck <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Alan Cox <[email protected]>
---
 drivers/watchdog/watchdog_core.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/watchdog/watchdog_core.c +1 -14
index eb8fa25f8eb2..f9f88f59d181 100644
@@ -28,7 +28,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
-#include <linux/module.h>	/* For EXPORT_SYMBOL/module stuff/... */
+#include <linux/export.h>	/* For EXPORT_SYMBOL stuff */
 #include <linux/types.h>	/* For standard types */
 #include <linux/errno.h>	/* For the -ENODEV/... values */
 #include <linux/kernel.h>	/* For printk/panic/... */
@@ -359,17 +359,4 @@ static int __init watchdog_init(void)
 	watchdog_deferred_registration();
 	return 0;
 }
-
-static void __exit watchdog_exit(void)
-{
-	watchdog_dev_exit();
-	ida_destroy(&watchdog_ida);
-}
-
 subsys_initcall_sync(watchdog_init);
-module_exit(watchdog_exit);
-
-MODULE_AUTHOR("Alan Cox <[email protected]>");
-MODULE_AUTHOR("Wim Van Sebroeck <[email protected]>");
-MODULE_DESCRIPTION("WatchDog Timer Driver Core");
-MODULE_LICENSE("GPL");
Signature · 1 line
2.7.4
#9 lore raw

PATCH 3/5 watchdog: npcm: make it explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config NPCM7XX_WATCHDOG
bool "Nuvoton NPCM750 watchdog"

...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 was (or is now) contained at the top of the file in the comments.

Cc Avi Fishman <[email protected]>
Cc Tomer Maimon <[email protected]>
Cc Tali Perry <[email protected]>
Cc Patrick Venture <[email protected]>
Cc Nancy Yuen <[email protected]>
Cc Benjamin Fair <[email protected]>
Cc Wim Van Sebroeck <[email protected]>
Cc Guenter Roeck <[email protected]>
---
 drivers/watchdog/npcm_wdt.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/watchdog/npcm_wdt.c +6 -7
index 0d4213652ecc..44d305683ab6 100644
@@ -2,11 +2,15 @@
 // Copyright (c) 2018 Nuvoton Technology corporation.
 // Copyright (c) 2018 IBM Corp.
 
+/*
+ * Watchdog driver for NPCM
+ * Author: Joel Stanley
+ */
+
 #include <linux/bitops.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
-#include <linux/module.h>
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
@@ -237,7 +241,6 @@ static const struct of_device_id npcm_wdt_match[] = {
 	{.compatible = "nuvoton,npcm750-wdt"},
 	{},
 };
-MODULE_DEVICE_TABLE(of, npcm_wdt_match);
 #endif
 
 static struct platform_driver npcm_wdt_driver = {
@@ -247,8 +250,4 @@ static struct platform_driver npcm_wdt_driver = {
 		.of_match_table = of_match_ptr(npcm_wdt_match),
 	},
 };
-module_platform_driver(npcm_wdt_driver);
-
-MODULE_AUTHOR("Joel Stanley");
-MODULE_DESCRIPTION("Watchdog driver for NPCM");
-MODULE_LICENSE("GPL v2");
+builtin_platform_driver(npcm_wdt_driver);
Signature · 1 line
2.7.4
#0 lore raw

cover wdt: clean up unused modular infrastructure

People can embed modular includes and modular exit functions into code that never use any of it, and they won't get any errors or warnings.

Using modular infrastructure in non-modules might seem harmless, but some of the downfalls this leads to are:

(1) it is easy to accidentally write unused module_exit/remove code
(2) it can be misleading when reading the source, thinking a driver can be modular when the Makefile and/or Kconfig prohibit it
(3) an unused include of the module.h header file will in turn include nearly everything else; adding a lot to CPP overhead.
(4) it gets copied/replicated into other drivers and can spread.

As a data point for #3 above, an empty C file that just includes the module.h header generates over 750kB of CPP output. Repeating the same experiment with init.h and the result is less than 12kB; with export.h it is only about 1/2kB; with both it still is less than 12kB.

Here, In this series, we do what has been done for other subsystems, like, net, x86, mfd, iommu.... and audit for uses of modular infrastructure inside code that currently can't be built as a module.

As always, the option exists for driver authors to convert their code to tristate, if there is a valid use case for it to be so. But since I don't have the context for each driver to know if such a use case exists, I limit myself to simply removing the unused code in order to make the driver consistent with the Makefile/Kconfig settings that control it.

Paul.

---

Cc Benjamin Fair <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Nancy Yuen <[email protected]>
Cc Patrick Venture <[email protected]>
Cc Tali Perry <[email protected]>
Cc Tomer Maimon <[email protected]>
Cc Wim Van Sebroeck <[email protected]>
Cc Wim Van Sebroeck <[email protected]>

Paul Gortmaker (5):
watchdog: rtd119x: drop unused module.h include
watchdog: watchdog_core: make it explicitly non-modular
watchdog: npcm: make it explicitly non-modular
watchdog: intel_scu: make it explicitly non-modular
watchdog: coh901327: make it explicitly non-modular

 drivers/watchdog/coh901327_wdt.c      | 24 ++++--------------------
 drivers/watchdog/intel_scu_watchdog.c | 18 ------------------
 drivers/watchdog/npcm_wdt.c           | 13 ++++++-------
 drivers/watchdog/rtd119x_wdt.c        |  1 -
 drivers/watchdog/watchdog_core.c      | 15 +--------------
 5 files changed, 11 insertions(+), 60 deletions(-)
Signature · 1 line
2.7.4
Reviewed-by on v1 5/5
#15 lore raw

Re: [PATCH 5/5] watchdog: coh901327: make it explicitly non-modular

In reply to Paul Gortmaker
Quoted 23 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config COH901327_WATCHDOG
bool "ST-Ericsson COH 901 327 watchdog"

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

Quoted 8 lines

We replace module.h with moduleparam.h since the file does actually declare some module parameters (i.e. boot args for non-modules).

Cc Linus Walleij <[email protected]>
Cc Wim Van Sebroeck <[email protected]>
Cc Guenter Roeck <[email protected]>

Thanks for doing this Paul.

Yours,
Linus Walleij

maintainer
#4 lore raw

Re: [PATCH 2/5] watchdog: watchdog_core: make it explicitly non-modular

In reply to Paul Gortmaker
Quoted 7 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config WATCHDOG_CORE
bool "WatchDog Timer Driver Core"

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

Quoted 9 lines

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

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

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

I must admit that I am not at all happy about this change. While not configurable by default, I used tristate a lot (after enabling it manually) to test watchdog core code while changing it. It saves a lot of time to be able to reload the watchdog core without having to reboot the entire system after each change. Removing the ability to do that just because it is not enabled in the field and just to save a few lines of code (and because having modules seems to have come out of favor lately) does not make sense to me.

I won't NACK the series outright, but I'll leave it up to Wim as the senior maintainer to decide what he wants to do with it.

Guenter

Quoted 41 lines
Cc Wim Van Sebroeck <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Alan Cox <[email protected]>
---
  drivers/watchdog/watchdog_core.c | 15 +--------------
  1 file changed, 1 insertion(+), 14 deletions(-)
drivers/watchdog/watchdog_core.c +1 -14
index eb8fa25f8eb2..f9f88f59d181 100644
@@ -28,7 +28,7 @@
 
  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
-#include <linux/module.h>	/* For EXPORT_SYMBOL/module stuff/... */
+#include <linux/export.h>	/* For EXPORT_SYMBOL stuff */
  #include <linux/types.h>	/* For standard types */
  #include <linux/errno.h>	/* For the -ENODEV/... values */
  #include <linux/kernel.h>	/* For printk/panic/... */
@@ -359,17 +359,4 @@ static int __init watchdog_init(void)
  	watchdog_deferred_registration();
  	return 0;
  }
-
-static void __exit watchdog_exit(void)
-{
-	watchdog_dev_exit();
-	ida_destroy(&watchdog_ida);
-}
-
  subsys_initcall_sync(watchdog_init);
-module_exit(watchdog_exit);
-
-MODULE_AUTHOR("Alan Cox <[email protected]>");
-MODULE_AUTHOR("Wim Van Sebroeck <[email protected]>");
-MODULE_DESCRIPTION("WatchDog Timer Driver Core");
-MODULE_LICENSE("GPL");
#5 lore raw

Re: [PATCH 2/5] watchdog: watchdog_core: make it explicitly non-modular

Quoted 18 lines · [Re: [PATCH 2/5] watchdog: watchdog_core: make it explicitly non-modular] On…
Quoted 7 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config WATCHDOG_CORE
bool "WatchDog Timer Driver Core"

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

Quoted 9 lines

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

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

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 5 lines

I must admit that I am not at all happy about this change. While not configurable by default, I used tristate a lot (after enabling it manually) to test watchdog core code while changing it. It saves a lot of time to be able to reload the watchdog core without having to reboot the entire system after each change. Removing the ability

I'm confused. If it is useful, then why not formally make it tristate so other people can do the same as you do, and nobody is manually making the change over and over again each time? I'd support that update.

Quoted 3 lines

to do that just because it is not enabled in the field and just to save a few lines of code (and because having modules seems to have come out of favor lately) does not make sense to me.

I'd have to say this is a mischaracterization. Modules are not out of favour. A disconnect between the code and Kconfig is out of favour.

Of all the hundred or so(?) of these type patches that have been merged so far, I have not created a single change with the intent of reduction in the existing out-of-box mainline support of drivers as modules.

Rather, It is in fact the opposite. As I said in the 0/5 preamble:

As always, the option exists for driver authors to convert their code to tristate...

...and a lot of drivers are now tristate because the author simply didn't realize they'd chosen "bool". We managed to make a new uart driver get bool ---> tristate conversion just this week, for example.

https://marc.info/?l=linux-serial&m=155602656610079&w=2

Quoted 2 lines

I won't NACK the series outright, but I'll leave it up to Wim as the senior maintainer to decide what he wants to do with it.

Yes, the decision is entirely up to you guys, but I just wanted to clarify once again that this or any one of the other similar changes are in no way some kind of "attack on modules". Quite the opposite as you can see in the above thread.

Thanks,
Paul.
--

Quoted 43 lines

Guenter

Quoted 39 lines
Cc Wim Van Sebroeck <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Alan Cox <[email protected]>
---
 drivers/watchdog/watchdog_core.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/watchdog/watchdog_core.c +1 -14
index eb8fa25f8eb2..f9f88f59d181 100644
@@ -28,7 +28,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-#include <linux/module.h>	/* For EXPORT_SYMBOL/module stuff/... */
+#include <linux/export.h>	/* For EXPORT_SYMBOL stuff */
 #include <linux/types.h>	/* For standard types */
 #include <linux/errno.h>	/* For the -ENODEV/... values */
 #include <linux/kernel.h>	/* For printk/panic/... */
@@ -359,17 +359,4 @@ static int __init watchdog_init(void)
 	watchdog_deferred_registration();
 	return 0;
 }
-
-static void __exit watchdog_exit(void)
-{
-	watchdog_dev_exit();
-	ida_destroy(&watchdog_ida);
-}
-
 subsys_initcall_sync(watchdog_init);
-module_exit(watchdog_exit);
-
-MODULE_AUTHOR("Alan Cox <[email protected]>");
-MODULE_AUTHOR("Wim Van Sebroeck <[email protected]>");
-MODULE_DESCRIPTION("WatchDog Timer Driver Core");
-MODULE_LICENSE("GPL");
maintainer
#6 lore raw

Re: [PATCH 2/5] watchdog: watchdog_core: make it explicitly non-modular

Quoted 26 lines · Paul Gortmaker
Quoted 18 lines · [Re: [PATCH 2/5] watchdog: watchdog_core: make it explicitly non-modular] On…
Quoted 7 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config WATCHDOG_CORE
bool "WatchDog Timer Driver Core"

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

Quoted 9 lines

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

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

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 5 lines

I must admit that I am not at all happy about this change. While not configurable by default, I used tristate a lot (after enabling it manually) to test watchdog core code while changing it. It saves a lot of time to be able to reload the watchdog core without having to reboot the entire system after each change. Removing the ability

Quoted 4 lines

I'm confused. If it is useful, then why not formally make it tristate so other people can do the same as you do, and nobody is manually making the change over and over again each time? I'd support that update.

No idea. That precedes my involvement in the watchdog subsystem. Let's wait for input from Wim. I have a set of patches ready, but it doesn't make sense to me to submit them if Wim wants to go the non-modular route.

FWIW, I am fine with the other patches except for the npcm patch, because several of the other npcm drivers are buildable as module.

Guenter

maintainer
#7 lore raw

Re: [PATCH 2/5] watchdog: watchdog_core: make it explicitly non-modular

Hi All,

Quoted 31 lines · Paul Gortmaker
Quoted 26 lines
Quoted 18 lines · [Re: [PATCH 2/5] watchdog: watchdog_core: make it explicitly non-modular] On…
Quoted 7 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config WATCHDOG_CORE
bool "WatchDog Timer Driver Core"

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

Quoted 9 lines

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

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

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 5 lines

I must admit that I am not at all happy about this change. While not configurable by default, I used tristate a lot (after enabling it manually) to test watchdog core code while changing it. It saves a lot of time to be able to reload the watchdog core without having to reboot the entire system after each change. Removing the ability

Quoted 4 lines

I'm confused. If it is useful, then why not formally make it tristate so other people can do the same as you do, and nobody is manually making the change over and over again each time? I'd support that update.

Quoted 7 lines

No idea. That precedes my involvement in the watchdog subsystem. Let's wait for input from Wim. I have a set of patches ready, but it doesn't make sense to me to submit them if Wim wants to go the non-modular route.

FWIW, I am fine with the other patches except for the npcm patch, because several of the other npcm drivers are buildable as module.

In general: If systems/devices can't handle modules then we should indeed make sure that we clean it up.

For the watchdog core however, I am not in favour of doing that. I also use it as a module when i'm testing.
I originally wanted to make it tristate (so that it can be loaded as a module), but I didn't had a clean way for the following situation:
driver built as part of kernel, but watchdog system build as a module. We should imho avoid that.
So no for this peticular patch and Guenter you can o ahead with another patch to make it tristate.

Kind regards,
Wim.

maintainer
#8 lore raw

Re: [PATCH 2/5] watchdog: watchdog_core: make it explicitly non-modular

Quoted 38 lines · Wim Van Sebroeck

Hi All,

Quoted 36 lines · Paul Gortmaker
Quoted 26 lines
Quoted 18 lines · [Re: [PATCH 2/5] watchdog: watchdog_core: make it explicitly non-modular] On…
Quoted 7 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config WATCHDOG_CORE
bool "WatchDog Timer Driver Core"

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

Quoted 9 lines

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

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

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 5 lines

I must admit that I am not at all happy about this change. While not configurable by default, I used tristate a lot (after enabling it manually) to test watchdog core code while changing it. It saves a lot of time to be able to reload the watchdog core without having to reboot the entire system after each change. Removing the ability

Quoted 4 lines

I'm confused. If it is useful, then why not formally make it tristate so other people can do the same as you do, and nobody is manually making the change over and over again each time? I'd support that update.

No idea. That precedes my involvement in the watchdog subsystem. Let's wait for input from Wim. I have a set of patches ready, but it doesn't make sense to me to submit them if Wim wants to go the non-modular route.

Quoted 5 lines
Quoted 2 lines

FWIW, I am fine with the other patches except for the npcm patch, because several of the other npcm drivers are buildable as module.

In general: If systems/devices can't handle modules then we should indeed make sure that we clean it up.

Makes sense.

Quoted 5 lines

For the watchdog core however, I am not in favour of doing that. I also use it as a module when i'm testing.
I originally wanted to make it tristate (so that it can be loaded as a module), but I didn't had a clean way for the following situation:
driver built as part of kernel, but watchdog system build as a module. We should imho avoid that.
So no for this peticular patch and Guenter you can o ahead with another patch to make it tristate.

That should be addressed by "select WATCHDOG_CORE" which is used throughout the kernel. It would be a problem if we had any "depends on WATCHDOG_CORE". Fortunately, there are no such dependencies. There are a couple of "depends on WATCHDOG", but they are all "depends on WATCHDOG" followed by "select WATCHDOG_CORE" as it should be. So we should be fine; any watchdog driver built into the kernel forces WATCHDOG_CORE to be built into the kernel as well.

I'll try to clean up my series and send it out this week. It requires more than one patch since there are some dependencies on the pretimeout code.

Guenter

maintainer Reviewed-by on v1 5/5
#16 lore raw

Re: [PATCH 5/5] watchdog: coh901327: make it explicitly non-modular

In reply to Paul Gortmaker
Quoted 26 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config COH901327_WATCHDOG
bool "ST-Ericsson COH 901 327 watchdog"

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

We replace module.h with moduleparam.h since the file does actually declare some module parameters (i.e. boot args for non-modules).

Quoted 6 lines
maintainer Reviewed-by on v1 4/5
#13 lore raw

Re: [PATCH 4/5] watchdog: intel_scu: make it explicitly non-modular

In reply to Paul Gortmaker
Quoted 13 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config INTEL_SCU_WATCHDOG
bool "Intel SCU Watchdog for Mobile Platforms"

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

We leave the moduleparam.h include since the file does declare some module parameters, and leaving them as such is currently the easiest way to remain compatible with existing boot arg use cases.

Quoted 38 lines
---
 drivers/watchdog/intel_scu_watchdog.c | 18 ------------------
 1 file changed, 18 deletions(-)
drivers/watchdog/intel_scu_watchdog.c +0 -18
index 0caab6241eb7..32bc5611f0cc 100644
@@ -25,7 +25,6 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/compiler.h>
-#include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/moduleparam.h>
 #include <linux/types.h>
@@ -545,21 +544,4 @@ static int __init intel_scu_watchdog_init(void)
 	iounmap(watchdog_device.timer_load_count_addr);
 	return ret;
 }
-
-static void __exit intel_scu_watchdog_exit(void)
-{
-
-	misc_deregister(&watchdog_device.miscdev);
-	unregister_reboot_notifier(&watchdog_device.intel_scu_notifier);
-	/* disable the timer */
-	iowrite32(0x00000002, watchdog_device.timer_control_addr);
-	iounmap(watchdog_device.timer_load_count_addr);
-}
-
 late_initcall(intel_scu_watchdog_init);
-module_exit(intel_scu_watchdog_exit);
-
-MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION("Intel SCU Watchdog Device Driver");
-MODULE_LICENSE("GPL");
-MODULE_VERSION(WDT_VER);
maintainer Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] watchdog: rtd119x: drop unused module.h include

In reply to Paul Gortmaker
Quoted 5 lines · Paul Gortmaker

The Kconfig for this driver is:

config RTD119X_WATCHDOG
bool "Realtek RTD118x/RTD129x watchdog support"

Quoted 7 lines

...and hence it doesn't need to include module.h for anything. There are no other signs of unused modular infrastructure.

maintainer
#10 lore raw

Re: [PATCH 3/5] watchdog: npcm: make it explicitly non-modular

In reply to Paul Gortmaker
Quoted 19 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config NPCM7XX_WATCHDOG
bool "Nuvoton NPCM750 watchdog"

...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 was (or is now) contained at the top of the file in the comments.

Quoted 11 lines
Cc Avi Fishman <[email protected]>
Cc Tomer Maimon <[email protected]>
Cc Tali Perry <[email protected]>
Cc Patrick Venture <[email protected]>
Cc Nancy Yuen <[email protected]>
Cc Benjamin Fair <[email protected]>
Cc Wim Van Sebroeck <[email protected]>
Cc Guenter Roeck <[email protected]>

I'll send a different patch to make the driver tristate, to follow the example given by other drivers for the same chipset.

Guenter

#11 lore raw

Re: [PATCH 3/5] watchdog: npcm: make it explicitly non-modular

Quoted 8 lines · [Re: [PATCH 3/5] watchdog: npcm: make it explicitly non-modular] On 29/04/2019…
Quoted 7 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config NPCM7XX_WATCHDOG
bool "Nuvoton NPCM750 watchdog"

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

[...]

Quoted 2 lines

I'll send a different patch to make the driver tristate, to follow the example given by other drivers for the same chipset.

Great, thanks. I'll drop this patch from my internal queue once I see it conflict with your tristate conversion in linux-next.

Paul.
--

Quoted 2 lines

Guenter

maintainer
#17 lore raw
In reply to Paul Gortmaker

I saw many drivers that are putting "#ifdef MODULE" around module specific code. I think it answers all 4 concerns above.
It also covers the case where a developer made the driver available to be compiled as a module and in the Kconfig didn't make it tristate. What do you think?

Quoted 64 lines · Paul Gortmaker

People can embed modular includes and modular exit functions into code that never use any of it, and they won't get any errors or warnings.

Using modular infrastructure in non-modules might seem harmless, but some of the downfalls this leads to are:

(1) it is easy to accidentally write unused module_exit/remove code
(2) it can be misleading when reading the source, thinking a driver can be modular when the Makefile and/or Kconfig prohibit it
(3) an unused include of the module.h header file will in turn include nearly everything else; adding a lot to CPP overhead.
(4) it gets copied/replicated into other drivers and can spread.

As a data point for #3 above, an empty C file that just includes the module.h header generates over 750kB of CPP output. Repeating the same experiment with init.h and the result is less than 12kB; with export.h it is only about 1/2kB; with both it still is less than 12kB.

Here, In this series, we do what has been done for other subsystems, like, net, x86, mfd, iommu.... and audit for uses of modular infrastructure inside code that currently can't be built as a module.

As always, the option exists for driver authors to convert their code to tristate, if there is a valid use case for it to be so. But since I don't have the context for each driver to know if such a use case exists, I limit myself to simply removing the unused code in order to make the driver consistent with the Makefile/Kconfig settings that control it.

Paul.

---

Cc Benjamin Fair <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Nancy Yuen <[email protected]>
Cc Patrick Venture <[email protected]>
Cc Tali Perry <[email protected]>
Cc Tomer Maimon <[email protected]>
Cc Wim Van Sebroeck <[email protected]>
Cc Wim Van Sebroeck <[email protected]>

Paul Gortmaker (5):
watchdog: rtd119x: drop unused module.h include
watchdog: watchdog_core: make it explicitly non-modular
watchdog: npcm: make it explicitly non-modular
watchdog: intel_scu: make it explicitly non-modular
watchdog: coh901327: make it explicitly non-modular

 drivers/watchdog/coh901327_wdt.c      | 24 ++++--------------------
 drivers/watchdog/intel_scu_watchdog.c | 18 ------------------
 drivers/watchdog/npcm_wdt.c           | 13 ++++++-------
 drivers/watchdog/rtd119x_wdt.c        |  1 -
 drivers/watchdog/watchdog_core.c      | 15 +--------------
 5 files changed, 11 insertions(+), 60 deletions(-)

--
2.7.4

Signature · 2 lines
Regards,
Avi