linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] rtc: remove modular usage from non-modular code
@ 2016-10-31 18:55 Paul Gortmaker
  2016-10-31 18:55 ` [PATCH 1/3] rtc: make rtc-lib explicitly non-modular Paul Gortmaker
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Paul Gortmaker @ 2016-10-31 18:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, Alessandro Zummo, Alexandre Belloni,
	David S. Miller, rtc-linux, sparclinux

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.

---

Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: rtc-linux@googlegroups.com
Cc: sparclinux@vger.kernel.org

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(-)

-- 
2.10.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] rtc: make rtc-lib explicitly non-modular
  2016-10-31 18:55 [PATCH 0/3] rtc: remove modular usage from non-modular code Paul Gortmaker
@ 2016-10-31 18:55 ` Paul Gortmaker
  2016-10-31 18:55 ` [PATCH 2/3] rtc: sparc: make starfire " Paul Gortmaker
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Paul Gortmaker @ 2016-10-31 18:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, Alessandro Zummo, Alexandre Belloni, rtc-linux

The Kconfig currently controlling compilation of this code is:

drivers/rtc/Kconfig:config RTC_LIB
drivers/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.

Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: rtc-linux@googlegroups.com
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/rtc/rtc-lib.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c
index e6bfb9c42a10..1ae7da5cfc60 100644
--- a/drivers/rtc/rtc-lib.c
+++ b/drivers/rtc/rtc-lib.c
@@ -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");
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] rtc: sparc: make starfire explicitly non-modular
  2016-10-31 18:55 [PATCH 0/3] rtc: remove modular usage from non-modular code Paul Gortmaker
  2016-10-31 18:55 ` [PATCH 1/3] rtc: make rtc-lib explicitly non-modular Paul Gortmaker
@ 2016-10-31 18:55 ` Paul Gortmaker
  2016-11-20 21:29   ` David Miller
  2016-10-31 18:55 ` [PATCH 3/3] rtc: sparc: make sun4v " Paul Gortmaker
  2016-11-04 22:30 ` [PATCH 0/3] rtc: remove modular usage from non-modular code Alexandre Belloni
  3 siblings, 1 reply; 8+ messages in thread
From: Paul Gortmaker @ 2016-10-31 18:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, Alessandro Zummo, Alexandre Belloni,
	David S. Miller, sparclinux, rtc-linux

The Kconfig currently controlling compilation of this code is:

drivers/rtc/Kconfig:config RTC_DRV_STARFIRE
drivers/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.

Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Cc: rtc-linux@googlegroups.com
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/rtc/rtc-starfire.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/rtc/rtc-starfire.c b/drivers/rtc/rtc-starfire.c
index 83a057a03060..7fc36973fa33 100644
--- a/drivers/rtc/rtc-starfire.c
+++ b/drivers/rtc/rtc-starfire.c
@@ -1,20 +1,18 @@
 /* rtc-starfire.c: Starfire platform RTC driver.
  *
+ * Author: David S. Miller
+ * License: GPL
+ *
  * Copyright (C) 2008 David S. Miller <davem@davemloft.net>
  */
 
 #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 <davem@davemloft.net>");
-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);
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] rtc: sparc: make sun4v explicitly non-modular
  2016-10-31 18:55 [PATCH 0/3] rtc: remove modular usage from non-modular code Paul Gortmaker
  2016-10-31 18:55 ` [PATCH 1/3] rtc: make rtc-lib explicitly non-modular Paul Gortmaker
  2016-10-31 18:55 ` [PATCH 2/3] rtc: sparc: make starfire " Paul Gortmaker
@ 2016-10-31 18:55 ` Paul Gortmaker
  2016-11-20 21:29   ` David Miller
  2016-11-04 22:30 ` [PATCH 0/3] rtc: remove modular usage from non-modular code Alexandre Belloni
  3 siblings, 1 reply; 8+ messages in thread
From: Paul Gortmaker @ 2016-10-31 18:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, Alessandro Zummo, Alexandre Belloni,
	David S. Miller, sparclinux, rtc-linux

The Kconfig currently controlling compilation of this code is:

drivers/rtc/Kconfig:config RTC_DRV_SUN4V
drivers/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.

Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Cc: rtc-linux@googlegroups.com
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/rtc/rtc-sun4v.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/rtc/rtc-sun4v.c b/drivers/rtc/rtc-sun4v.c
index 7c696c12f28f..11bc562eba5d 100644
--- a/drivers/rtc/rtc-sun4v.c
+++ b/drivers/rtc/rtc-sun4v.c
@@ -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 <davem@davemloft.net>
  */
 
 #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 <davem@davemloft.net>");
-MODULE_DESCRIPTION("SUN4V RTC driver");
-MODULE_LICENSE("GPL");
+builtin_platform_driver_probe(sun4v_rtc_driver, sun4v_rtc_probe);
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] rtc: remove modular usage from non-modular code
  2016-10-31 18:55 [PATCH 0/3] rtc: remove modular usage from non-modular code Paul Gortmaker
                   ` (2 preceding siblings ...)
  2016-10-31 18:55 ` [PATCH 3/3] rtc: sparc: make sun4v " Paul Gortmaker
@ 2016-11-04 22:30 ` Alexandre Belloni
  3 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2016-11-04 22:30 UTC (permalink / raw)
  To: Paul Gortmaker
  Cc: linux-kernel, Alessandro Zummo, David S. Miller, rtc-linux, sparclinux

On 31/10/2016 at 14:55:24 -0400, Paul Gortmaker wrote :
> 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.
> 
> ---
> 
> Cc: Alessandro Zummo <a.zummo@towertech.it>
> Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: rtc-linux@googlegroups.com
> Cc: sparclinux@vger.kernel.org
> 
> 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(-)
> 
Applied, thanks.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] rtc: sparc: make starfire explicitly non-modular
  2016-10-31 18:55 ` [PATCH 2/3] rtc: sparc: make starfire " Paul Gortmaker
@ 2016-11-20 21:29   ` David Miller
  2016-11-20 21:38     ` Alexandre Belloni
  0 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2016-11-20 21:29 UTC (permalink / raw)
  To: paul.gortmaker
  Cc: linux-kernel, a.zummo, alexandre.belloni, sparclinux, rtc-linux

From: Paul Gortmaker <paul.gortmaker@windriver.com>
Date: Mon, 31 Oct 2016 14:55:26 -0400

> The Kconfig currently controlling compilation of this code is:
> 
> drivers/rtc/Kconfig:config RTC_DRV_STARFIRE
> drivers/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.
> 
> Cc: Alessandro Zummo <a.zummo@towertech.it>
> Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: sparclinux@vger.kernel.org
> Cc: rtc-linux@googlegroups.com
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>

Applied.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] rtc: sparc: make sun4v explicitly non-modular
  2016-10-31 18:55 ` [PATCH 3/3] rtc: sparc: make sun4v " Paul Gortmaker
@ 2016-11-20 21:29   ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2016-11-20 21:29 UTC (permalink / raw)
  To: paul.gortmaker
  Cc: linux-kernel, a.zummo, alexandre.belloni, sparclinux, rtc-linux

From: Paul Gortmaker <paul.gortmaker@windriver.com>
Date: Mon, 31 Oct 2016 14:55:27 -0400

> The Kconfig currently controlling compilation of this code is:
> 
> drivers/rtc/Kconfig:config RTC_DRV_SUN4V
> drivers/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.
> 
> Cc: Alessandro Zummo <a.zummo@towertech.it>
> Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: sparclinux@vger.kernel.org
> Cc: rtc-linux@googlegroups.com
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>

Applied.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] rtc: sparc: make starfire explicitly non-modular
  2016-11-20 21:29   ` David Miller
@ 2016-11-20 21:38     ` Alexandre Belloni
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2016-11-20 21:38 UTC (permalink / raw)
  To: David Miller; +Cc: paul.gortmaker, linux-kernel, a.zummo, sparclinux, rtc-linux

Hi Dave,

I already carry both patches in my tree but I would gladly add an ack.

On 20/11/2016 at 16:29:19 -0500, David Miller wrote :
> From: Paul Gortmaker <paul.gortmaker@windriver.com>
> Date: Mon, 31 Oct 2016 14:55:26 -0400
> 
> > The Kconfig currently controlling compilation of this code is:
> > 
> > drivers/rtc/Kconfig:config RTC_DRV_STARFIRE
> > drivers/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.
> > 
> > Cc: Alessandro Zummo <a.zummo@towertech.it>
> > Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> > Cc: "David S. Miller" <davem@davemloft.net>
> > Cc: sparclinux@vger.kernel.org
> > Cc: rtc-linux@googlegroups.com
> > Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
> 
> Applied.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-11-20 21:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-31 18:55 [PATCH 0/3] rtc: remove modular usage from non-modular code Paul Gortmaker
2016-10-31 18:55 ` [PATCH 1/3] rtc: make rtc-lib explicitly non-modular Paul Gortmaker
2016-10-31 18:55 ` [PATCH 2/3] rtc: sparc: make starfire " Paul Gortmaker
2016-11-20 21:29   ` David Miller
2016-11-20 21:38     ` Alexandre Belloni
2016-10-31 18:55 ` [PATCH 3/3] rtc: sparc: make sun4v " Paul Gortmaker
2016-11-20 21:29   ` David Miller
2016-11-04 22:30 ` [PATCH 0/3] rtc: remove modular usage from non-modular code Alexandre Belloni

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