linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] tty/serial: delete orphaned code in non-modules
@ 2015-07-22  2:02 Paul Gortmaker
  2015-07-22  2:02 ` [PATCH 1/4] drivers/tty: make serial/sn_console.c driver explicitly non-modular Paul Gortmaker
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Paul Gortmaker @ 2015-07-22  2:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, David S. Miller, Greg Kroah-Hartman, Jiri Slaby,
	linux-serial, sparclinux

In the previous merge window, we made changes to allow better
delineation between modular and non-modular code in commit
0fd972a7d91d6e15393c449492a04d94c0b89351 ("module: relocate module_init
from init.h to module.h").  This allows us to now ensure module code
looks modular and non-modular code does not accidentally look modular
without suffering build breakage.

Here we target code that is, by nature of their Kconfig settings, only
available to be built-in, but implicitly presenting itself as being
possibly modular by way of using modular headers, macros, and functions.

The goal here is to remove that illusion of modularity from these
drivers, but in a way that leaves the actual runtime unchanged.
In doing so, we remove code that has never been tested and adds
no value to the tree.  And we begin the process of expecting a
level of consistency between the Kconfig of a driver and the code
that the driver uses.

Even though some of these drivers have their origin predating git
history, we change them as well; since the reality is that most linux
drivers are created by copying existing drivers.  Given that, our
new code will only be as good as the examples we have in tree.

Build tested for allyesconfig on sparc32, sparc64 and x86-64, on
tty/tty-next (currently v4.2-rc3).

Paul.
---

Cc: "David S. Miller" <davem@davemloft.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: linux-serial@vger.kernel.org
Cc: sparclinux@vger.kernel.org

Paul Gortmaker (4):
  drivers/tty: make serial/sn_console.c driver explicitly non-modular
  drivers/tty: make serial/lantic.c driver explicitly non-modular
  drivers/tty: make serial/suncore.c driver explicitly non-modular
  drivers/tty: make serial/sunhv.c driver explicitly non-modular

 drivers/tty/serial/lantiq.c     |  8 +-------
 drivers/tty/serial/sn_console.c | 32 +++++++++-----------------------
 drivers/tty/serial/suncore.c    | 11 +++--------
 drivers/tty/serial/sunhv.c      | 13 +++----------
 4 files changed, 16 insertions(+), 48 deletions(-)

-- 
2.2.1

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

* [PATCH 1/4] drivers/tty: make serial/sn_console.c driver explicitly non-modular
  2015-07-22  2:02 [PATCH 0/4] tty/serial: delete orphaned code in non-modules Paul Gortmaker
@ 2015-07-22  2:02 ` Paul Gortmaker
  2015-07-22  2:02 ` [PATCH 2/4] drivers/tty: make serial/lantic.c " Paul Gortmaker
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Gortmaker @ 2015-07-22  2:02 UTC (permalink / raw)
  To: linux-kernel; +Cc: Paul Gortmaker, Greg Kroah-Hartman, Jiri Slaby, linux-serial

The Kconfig for this option is currently:

config SERIAL_SGI_L1_CONSOLE
    bool "SGI Altix L1 serial console support"

...meaning that it currently is not being built as a module by anyone.
Lets remove the orphaned module code, so that when reading the
driver there is no doubt it is builtin-only.  We could consider
making it tristate, but the above bool has been there since before
the start of git history, which isn't all that surprising, since
consoles are typically critical to have at early boot.  So adding
tristate is really of no value here.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: linux-serial@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/tty/serial/sn_console.c | 32 +++++++++-----------------------
 1 file changed, 9 insertions(+), 23 deletions(-)

diff --git a/drivers/tty/serial/sn_console.c b/drivers/tty/serial/sn_console.c
index 33e94e56dcdb..d4692d888e9d 100644
--- a/drivers/tty/serial/sn_console.c
+++ b/drivers/tty/serial/sn_console.c
@@ -42,7 +42,7 @@
 #include <linux/tty_flip.h>
 #include <linux/serial.h>
 #include <linux/console.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/sysrq.h>
 #include <linux/circ_buf.h>
 #include <linux/serial_reg.h>
@@ -659,7 +659,7 @@ static void sn_sal_timer_poll(unsigned long data)
  * @port: Our sn_cons_port (which contains the uart port)
  *
  * So this is used by sn_sal_serial_console_init (early on, before we're
- * registered with serial core).  It's also used by sn_sal_module_init
+ * registered with serial core).  It's also used by sn_sal_init
  * right after we've registered with serial core.  The later only happens
  * if we didn't already come through here via sn_sal_serial_console_init.
  *
@@ -709,7 +709,7 @@ static void __init sn_sal_switch_to_asynch(struct sn_cons_port *port)
  * sn_sal_switch_to_interrupts - Switch to interrupt driven mode
  * @port: Our sn_cons_port (which contains the uart port)
  *
- * In sn_sal_module_init, after we're registered with serial core and
+ * In sn_sal_init, after we're registered with serial core and
  * the port is added, this function is called to switch us to interrupt
  * mode.  We were previously in asynch/polling mode (using init_timer).
  *
@@ -773,7 +773,7 @@ static struct uart_driver sal_console_uart = {
 };
 
 /**
- * sn_sal_module_init - When the kernel loads us, get us rolling w/ serial core
+ * sn_sal_init - When the kernel loads us, get us rolling w/ serial core
  *
  * Before this is called, we've been printing kernel messages in a special
  * early mode not making use of the serial core infrastructure.  When our
@@ -781,7 +781,7 @@ static struct uart_driver sal_console_uart = {
  * core and try to enable interrupt driven mode.
  *
  */
-static int __init sn_sal_module_init(void)
+static int __init sn_sal_init(void)
 {
 	int retval;
 
@@ -811,7 +811,7 @@ static int __init sn_sal_module_init(void)
 
 	if (uart_register_driver(&sal_console_uart) < 0) {
 		printk
-		    ("ERROR sn_sal_module_init failed uart_register_driver, line %d\n",
+		    ("ERROR sn_sal_init failed uart_register_driver, line %d\n",
 		     __LINE__);
 		return -ENODEV;
 	}
@@ -832,33 +832,19 @@ static int __init sn_sal_module_init(void)
 
 	/* when this driver is compiled in, the console initialization
 	 * will have already switched us into asynchronous operation
-	 * before we get here through the module initcalls */
+	 * before we get here through the initcalls */
 	if (!sal_console_port.sc_is_asynch) {
 		sn_sal_switch_to_asynch(&sal_console_port);
 	}
 
-	/* at this point (module_init) we can try to turn on interrupts */
+	/* at this point (device_init) we can try to turn on interrupts */
 	if (!IS_RUNNING_ON_SIMULATOR()) {
 		sn_sal_switch_to_interrupts(&sal_console_port);
 	}
 	sn_process_input = 1;
 	return 0;
 }
-
-/**
- * sn_sal_module_exit - When we're unloaded, remove the driver/port
- *
- */
-static void __exit sn_sal_module_exit(void)
-{
-	del_timer_sync(&sal_console_port.sc_timer);
-	uart_remove_one_port(&sal_console_uart, &sal_console_port.sc_port);
-	uart_unregister_driver(&sal_console_uart);
-	misc_deregister(&misc);
-}
-
-module_init(sn_sal_module_init);
-module_exit(sn_sal_module_exit);
+device_initcall(sn_sal_init);
 
 /**
  * puts_raw_fixed - sn_sal_console_write helper for adding \r's as required
-- 
2.2.1


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

* [PATCH 2/4] drivers/tty: make serial/lantic.c driver explicitly non-modular
  2015-07-22  2:02 [PATCH 0/4] tty/serial: delete orphaned code in non-modules Paul Gortmaker
  2015-07-22  2:02 ` [PATCH 1/4] drivers/tty: make serial/sn_console.c driver explicitly non-modular Paul Gortmaker
@ 2015-07-22  2:02 ` Paul Gortmaker
  2015-07-22  2:02 ` [PATCH 3/4] drivers/tty: make serial/suncore.c " Paul Gortmaker
  2015-07-22  2:02 ` [PATCH 4/4] drivers/tty: make serial/sunhv.c " Paul Gortmaker
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Gortmaker @ 2015-07-22  2:02 UTC (permalink / raw)
  To: linux-kernel; +Cc: Paul Gortmaker, Greg Kroah-Hartman, Jiri Slaby, linux-serial

The Kconfig for this option is currently:

config SERIAL_LANTIQ
    bool "Lantiq serial driver"

...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_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit.

We delete the MODULE_DESCRIPTION and LICENSE tags since they are
not adding any new information above and beyond what is at the top
of the file.  Also note that MODULE_DEVICE_TABLE is a no-op for
non-modular code, so we remove that as well.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: linux-serial@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/tty/serial/lantiq.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/tty/serial/lantiq.c b/drivers/tty/serial/lantiq.c
index 4ccc0397664c..b88832e8ee82 100644
--- a/drivers/tty/serial/lantiq.c
+++ b/drivers/tty/serial/lantiq.c
@@ -21,7 +21,6 @@
  */
 
 #include <linux/slab.h>
-#include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/console.h>
@@ -740,7 +739,6 @@ static const struct of_device_id ltq_asc_match[] = {
 	{ .compatible = DRVNAME },
 	{},
 };
-MODULE_DEVICE_TABLE(of, ltq_asc_match);
 
 static struct platform_driver lqasc_driver = {
 	.driver		= {
@@ -764,8 +762,4 @@ init_lqasc(void)
 
 	return ret;
 }
-
-module_init(init_lqasc);
-
-MODULE_DESCRIPTION("Lantiq serial port driver");
-MODULE_LICENSE("GPL");
+device_initcall(init_lqasc);
-- 
2.2.1


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

* [PATCH 3/4] drivers/tty: make serial/suncore.c driver explicitly non-modular
  2015-07-22  2:02 [PATCH 0/4] tty/serial: delete orphaned code in non-modules Paul Gortmaker
  2015-07-22  2:02 ` [PATCH 1/4] drivers/tty: make serial/sn_console.c driver explicitly non-modular Paul Gortmaker
  2015-07-22  2:02 ` [PATCH 2/4] drivers/tty: make serial/lantic.c " Paul Gortmaker
@ 2015-07-22  2:02 ` Paul Gortmaker
  2015-07-22  2:02 ` [PATCH 4/4] drivers/tty: make serial/sunhv.c " Paul Gortmaker
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Gortmaker @ 2015-07-22  2:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, David S. Miller, Greg Kroah-Hartman, Jiri Slaby,
	sparclinux, linux-serial

The Kconfig for this driver is currently:

config SERIAL_SUNCORE
        bool

...meaning that it currently is not being built as a module by
anyone.  Lets remove the modular and unused code here, 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 don't swap module.h for init.h since this file has init.h already.

We leave some tags like MODULE_LICENSE for documentation purposes, and
for the "git blame" value.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: sparclinux@vger.kernel.org
Cc: linux-serial@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/tty/serial/suncore.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/serial/suncore.c b/drivers/tty/serial/suncore.c
index 6e4ac8db2d79..127472bd6a7c 100644
--- a/drivers/tty/serial/suncore.c
+++ b/drivers/tty/serial/suncore.c
@@ -10,7 +10,6 @@
  * Copyright (C) 2002 David S. Miller (davem@redhat.com)
  */
 
-#include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/console.h>
 #include <linux/tty.h>
@@ -234,14 +233,10 @@ static int __init suncore_init(void)
 {
 	return 0;
 }
+device_initcall(suncore_init);
 
-static void __exit suncore_exit(void)
-{
-}
-
-module_init(suncore_init);
-module_exit(suncore_exit);
-
+#if 0 /* ..def MODULE ; never supported as such */
 MODULE_AUTHOR("Eddie C. Dost, David S. Miller");
 MODULE_DESCRIPTION("Sun serial common layer");
 MODULE_LICENSE("GPL");
+#endif
-- 
2.2.1


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

* [PATCH 4/4] drivers/tty: make serial/sunhv.c driver explicitly non-modular
  2015-07-22  2:02 [PATCH 0/4] tty/serial: delete orphaned code in non-modules Paul Gortmaker
                   ` (2 preceding siblings ...)
  2015-07-22  2:02 ` [PATCH 3/4] drivers/tty: make serial/suncore.c " Paul Gortmaker
@ 2015-07-22  2:02 ` Paul Gortmaker
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Gortmaker @ 2015-07-22  2:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, David S. Miller, Greg Kroah-Hartman, Jiri Slaby,
	sparclinux, linux-serial

The Kconfig for this driver is currently:

config SERIAL_SUNHV
        bool "Sun4v Hypervisor Console support"

...meaning that it currently is not being built as a module by
anyone.  Lets remove the modular and unused code here, 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 don't swap module.h for init.h since this file has init.h already.

We leave some tags like MODULE_LICENSE for documentation purposes, and
for the "git blame" value.  Also note that MODULE_DEVICE_TABLE is a
no-op for non-modular code, so we remove that too.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: sparclinux@vger.kernel.org
Cc: linux-serial@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/tty/serial/sunhv.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/serial/sunhv.c b/drivers/tty/serial/sunhv.c
index 534754440fa8..064031870ba0 100644
--- a/drivers/tty/serial/sunhv.c
+++ b/drivers/tty/serial/sunhv.c
@@ -3,7 +3,6 @@
  * Copyright (C) 2006, 2007 David S. Miller (davem@davemloft.net)
  */
 
-#include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/tty.h>
@@ -621,7 +620,6 @@ static const struct of_device_id hv_match[] = {
 	},
 	{},
 };
-MODULE_DEVICE_TABLE(of, hv_match);
 
 static struct platform_driver hv_driver = {
 	.driver = {
@@ -639,16 +637,11 @@ static int __init sunhv_init(void)
 
 	return platform_driver_register(&hv_driver);
 }
+device_initcall(sunhv_init);
 
-static void __exit sunhv_exit(void)
-{
-	platform_driver_unregister(&hv_driver);
-}
-
-module_init(sunhv_init);
-module_exit(sunhv_exit);
-
+#if 0 /* ...def MODULE ; never supported as such */
 MODULE_AUTHOR("David S. Miller");
 MODULE_DESCRIPTION("SUN4V Hypervisor console driver");
 MODULE_VERSION("2.0");
 MODULE_LICENSE("GPL");
+#endif
-- 
2.2.1


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

end of thread, other threads:[~2015-07-22  2:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-22  2:02 [PATCH 0/4] tty/serial: delete orphaned code in non-modules Paul Gortmaker
2015-07-22  2:02 ` [PATCH 1/4] drivers/tty: make serial/sn_console.c driver explicitly non-modular Paul Gortmaker
2015-07-22  2:02 ` [PATCH 2/4] drivers/tty: make serial/lantic.c " Paul Gortmaker
2015-07-22  2:02 ` [PATCH 3/4] drivers/tty: make serial/suncore.c " Paul Gortmaker
2015-07-22  2:02 ` [PATCH 4/4] drivers/tty: make serial/sunhv.c " Paul Gortmaker

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