rtc: remove modular usage from non-modular code
cover rtc: remove modular usage from non-modular code
My ongoing audit looking for non-modular code that needlessly uses modular macros (vs. built-in equivalents) and/or has dead code relating to module unloading that can never be executed led to the creation of these rtc related commits.
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.
Build tested on current linux-next (sparc32) to ensure no silly typos or implicit include issues that would break compilation crept in.
---
Paul Gortmaker (3):
rtc: make rtc-lib explicitly non-modular
rtc: sparc: make starfire explicitly non-modular
rtc: sparc: make sun4v explicitly non-modular
drivers/rtc/rtc-lib.c | 4 +--- drivers/rtc/rtc-starfire.c | 10 ++++------ drivers/rtc/rtc-sun4v.c | 10 ++++------ 3 files changed, 9 insertions(+), 15 deletions(-)
Signature · 1 line
2.10.1
PATCH 1/3 rtc: make rtc-lib explicitly non-modular
The Kconfig currently controlling compilation of this code is:
drivers/rtc/Kconfig:config RTC_LIBdrivers/rtc/Kconfig: bool
...meaning that it currently is not being built as a module by anyone.
Lets remove the couple traces of modular infrastructure use, so that when reading the driver there is no doubt it is builtin-only.
We delete the MODULE_LICENSE tag 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 doesn't need that. However we do add export.h since the file uses EXPORT_SYMBOL.
--- drivers/rtc/rtc-lib.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/rtc/rtc-lib.c +1 -3
@@ -11,7 +11,7 @@* published by the Free Software Foundation. */ -#include <linux/module.h> +#include <linux/export.h> #include <linux/rtc.h> static const unsigned char rtc_days_in_month[] = {
@@ -148,5 +148,3 @@ struct rtc_time rtc_ktime_to_tm(ktime_t kt)return ret; }EXPORT_SYMBOL_GPL (rtc_ktime_to_tm); - -MODULE_LICENSE ("GPL" );
Signature · 11 lines
2.10.1 -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
PATCH 2/3 rtc: sparc: make starfire explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/rtc/Kconfig:config RTC_DRV_STARFIREdrivers/rtc/Kconfig: bool "Starfire RTC"
...meaning that it currently is not being built as a module by anyone.
Lets remove the couple traces of modular infrastructure use, so that when reading the driver there is no doubt it is builtin-only.
We delete the MODULE_LICENSE tag etc. since all that information was (or is now) contained at the top of the file in the comments.
--- drivers/rtc/rtc-starfire.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/rtc/rtc-starfire.c +4 -6
@@ -1,20 +1,18 @@/* rtc-starfire.c: Starfire platform RTC driver. * +* Author: David S. Miller +* License: GPL +* * Copyright (C) 2008 David S. Miller <[email protected]> */ #include <linux/kernel.h> -#include <linux/module.h> #include <linux/init.h> #include <linux/rtc.h> #include <linux/platform_device.h> #include <asm/oplib.h> -MODULE_AUTHOR ("David S. Miller <[email protected]>" ); -MODULE_DESCRIPTION ("Starfire RTC driver" ); -MODULE_LICENSE ("GPL" ); -static u32 starfire_get_time (void ) {static char obp_gettod[32 ];
@@ -57,4 +55,4 @@ static struct platform_driver starfire_rtc_driver = { }, }; -module_platform_driver_probe (starfire_rtc_driver, starfire_rtc_probe); +builtin_platform_driver_probe (starfire_rtc_driver, starfire_rtc_probe);
Signature · 1 line
2.10.1
David Miller
AppliedRe: [PATCH 2/3] rtc: sparc: make starfire explicitly non-modular
From: Paul Gortmaker <[email protected]>
Date: Mon, 31 Oct 2016 14:55:26 -0400
Quoted 13 lines
The
Kconfigcurrently controlling compilation of this code is:drivers/rtc/Kconfig:config
RTC_DRV_STARFIREdrivers/rtc/Kconfig: bool "Starfire RTC"...meaning that it currently is not being built as a module by anyone.
Lets remove the couple traces of modular infrastructure use, so that when reading the driver there is no doubt it is builtin-only.
We delete the
MODULE_LICENSEtag etc. since all that information was (or is now) contained at the top of the file in the comments.
Quoted 6 lines
Cc Alessandro Zummo <[email protected]>Cc Alexandre Belloni <[email protected]>Cc "David S. Miller" <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>
Applied.
Re: [PATCH 2/3] rtc: sparc: make starfire explicitly non-modular
Hi Dave,
I already carry both patches in my tree but I would gladly add an ack.
Quoted 24 lines · David Miller
From: Paul Gortmaker <[email protected]>
Date: Mon, 31 Oct 2016 14:55:26 -0400Quoted 13 lines
The
Kconfigcurrently controlling compilation of this code is:drivers/rtc/Kconfig:config
RTC_DRV_STARFIREdrivers/rtc/Kconfig: bool "Starfire RTC"...meaning that it currently is not being built as a module by anyone.
Lets remove the couple traces of modular infrastructure use, so that when reading the driver there is no doubt it is builtin-only.
We delete the
MODULE_LICENSEtag etc. since all that information was (or is now) contained at the top of the file in the comments.Quoted 6 lines
Cc Alessandro Zummo <[email protected]>Cc Alexandre Belloni <[email protected]>Cc "David S. Miller" <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>Applied.
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 3/3 rtc: sparc: make sun4v explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/rtc/Kconfig:config RTC_DRV_SUN4Vdrivers/rtc/Kconfig: bool "SUN4V Hypervisor RTC"
...meaning that it currently is not being built as a module by anyone.
Lets remove the couple traces of modular infrastructure use, so that when reading the driver there is no doubt it is builtin-only.
We delete the MODULE_LICENSE tag etc. since all that information was (or is now) contained at the top of the file in the comments.
--- drivers/rtc/rtc-sun4v.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/rtc/rtc-sun4v.c +4 -6
@@ -1,12 +1,14 @@/* rtc-sun4v.c: Hypervisor based RTC for SUN4V systems. * +* Author: David S. Miller +* License: GPL +* * Copyright (C) 2008 David S. Miller <[email protected]> */ #define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/kernel.h> -#include <linux/module.h> #include <linux/delay.h> #include <linux/init.h> #include <linux/rtc.h>
@@ -98,8 +100,4 @@ static struct platform_driver sun4v_rtc_driver = { }, }; -module_platform_driver_probe (sun4v_rtc_driver, sun4v_rtc_probe); - -MODULE_AUTHOR ("David S. Miller <[email protected]>" ); -MODULE_DESCRIPTION ("SUN4V RTC driver" ); -MODULE_LICENSE ("GPL" ); +builtin_platform_driver_probe (sun4v_rtc_driver, sun4v_rtc_probe);
Signature · 1 line
2.10.1
David Miller
AppliedRe: [PATCH 3/3] rtc: sparc: make sun4v explicitly non-modular
From: Paul Gortmaker <[email protected]>
Date: Mon, 31 Oct 2016 14:55:27 -0400
Quoted 13 lines
The
Kconfigcurrently controlling compilation of this code is:drivers/rtc/Kconfig:config
RTC_DRV_SUN4Vdrivers/rtc/Kconfig: bool "SUN4V Hypervisor RTC"...meaning that it currently is not being built as a module by anyone.
Lets remove the couple traces of modular infrastructure use, so that when reading the driver there is no doubt it is builtin-only.
We delete the
MODULE_LICENSEtag etc. since all that information was (or is now) contained at the top of the file in the comments.
Quoted 6 lines
Cc Alessandro Zummo <[email protected]>Cc Alexandre Belloni <[email protected]>Cc "David S. Miller" <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>
Applied.
Alexandre Belloni
AppliedQuoted 31 lines · Paul Gortmaker
My ongoing audit looking for non-modular code that needlessly uses modular macros (vs. built-in equivalents) and/or has dead code relating to module unloading that can never be executed led to the creation of these rtc related commits.
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_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, thus adding to CPP overhead.
(4) it gets copied/replicated into other code and spreads like weeds.Build tested on current linux-next (sparc32) to ensure no silly typos or implicit include issues that would break compilation crept in.
---
Cc Alessandro Zummo <[email protected]>Cc Alexandre Belloni <[email protected]>Cc "David S. Miller" <[email protected]>Paul Gortmaker (3):
rtc: make rtc-lib explicitly non-modular
rtc: sparc: make starfire explicitly non-modular
rtc: sparc: make sun4v explicitly non-modular
Quoted 5 lines
drivers/rtc/rtc-lib.c | 4 +--- drivers/rtc/rtc-starfire.c | 10 ++++------ drivers/rtc/rtc-sun4v.c | 10 ++++------ 3 files changed, 9 insertions(+), 15 deletions(-)
Applied, thanks.
Signature · 13 lines
Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.