linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] serial: pxa: make it explicitly non-modular
       [not found] <20160620225505.7320-1-paul.gortmaker@windriver.com>
@ 2016-06-20 22:55 ` Paul Gortmaker
  2016-06-20 22:55 ` [PATCH 2/3] serial: vt8500_serial: " Paul Gortmaker
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: Paul Gortmaker @ 2016-06-20 22:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: Paul Gortmaker, Greg Kroah-Hartman, Jiri Slaby, linux-serial

The Kconfig currently controlling compilation of this code is:

drivers/tty/serial/Kconfig:config SERIAL_PXA
drivers/tty/serial/Kconfig:     bool "PXA serial port support"

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

Also note that MODULE_DEVICE_TABLE and MODULE_ALIAS are both a
no-op for non-modular builds.

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

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/pxa.c | 31 +++----------------------------
 1 file changed, 3 insertions(+), 28 deletions(-)

diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c
index 41eab75ba2af..29c2309b4b28 100644
--- a/drivers/tty/serial/pxa.c
+++ b/drivers/tty/serial/pxa.c
@@ -27,7 +27,6 @@
 #define SUPPORT_SYSRQ
 #endif
 
-#include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/console.h>
@@ -829,7 +829,6 @@ static const struct of_device_id serial_pxa_dt_ids[] = {
 	{ .compatible = "mrvl,mmp-uart", },
 	{}
 };
-MODULE_DEVICE_TABLE(of, serial_pxa_dt_ids);
 
 static int serial_pxa_probe_dt(struct platform_device *pdev,
 			       struct uart_pxa_port *sport)
@@ -914,28 +913,15 @@ static int serial_pxa_probe(struct platform_device *dev)
 	return ret;
 }
 
-static int serial_pxa_remove(struct platform_device *dev)
-{
-	struct uart_pxa_port *sport = platform_get_drvdata(dev);
-
-	uart_remove_one_port(&serial_pxa_reg, &sport->port);
-
-	clk_unprepare(sport->clk);
-	clk_put(sport->clk);
-	kfree(sport);
-
-	return 0;
-}
-
 static struct platform_driver serial_pxa_driver = {
         .probe          = serial_pxa_probe,
-        .remove         = serial_pxa_remove,
 
 	.driver		= {
 	        .name	= "pxa2xx-uart",
 #ifdef CONFIG_PM
 		.pm	= &serial_pxa_pm_ops,
 #endif
+		.suppress_bind_attrs = true,
 		.of_match_table = serial_pxa_dt_ids,
 	},
 };
@@ -954,15 +940,4 @@ static int __init serial_pxa_init(void)
 
 	return ret;
 }
-
-static void __exit serial_pxa_exit(void)
-{
-	platform_driver_unregister(&serial_pxa_driver);
-	uart_unregister_driver(&serial_pxa_reg);
-}
-
-module_init(serial_pxa_init);
-module_exit(serial_pxa_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:pxa2xx-uart");
+device_initcall(serial_pxa_init);
-- 
2.8.4

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

* [PATCH 2/3] serial: vt8500_serial: make it explicitly non-modular
       [not found] <20160620225505.7320-1-paul.gortmaker@windriver.com>
  2016-06-20 22:55 ` [PATCH 1/3] serial: pxa: make it explicitly non-modular Paul Gortmaker
@ 2016-06-20 22:55 ` Paul Gortmaker
  2016-06-20 22:55 ` [PATCH 3/3] serial: m32r_sio: " Paul Gortmaker
  2016-06-21  5:30 ` [PATCH 0/3] serial: remove modular code from a few more non-modular drivers Paul Gortmaker
  3 siblings, 0 replies; 4+ messages in thread
From: Paul Gortmaker @ 2016-06-20 22:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, Tony Prisk, Greg Kroah-Hartman, Jiri Slaby,
	Alexey Charkov, linux-serial

The Kconfig currently controlling compilation of this code is:

drivers/tty/serial/Kconfig:config SERIAL_VT8500
drivers/tty/serial/Kconfig:     bool "VIA VT8500 on-chip serial port support"

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

We don't replace module.h with 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: Tony Prisk <linux@prisktech.co.nz>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Alexey Charkov <alchark@gmail.com>
Cc: linux-serial@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/tty/serial/vt8500_serial.c | 30 ++----------------------------
 1 file changed, 2 insertions(+), 28 deletions(-)

diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c
index b384060e3b1f..23cfc5e16b45 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -21,7 +21,6 @@
 
 #include <linux/hrtimer.h>
 #include <linux/delay.h>
-#include <linux/module.h>
 #include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/irq.h>
@@ -730,22 +729,12 @@ static int vt8500_serial_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int vt8500_serial_remove(struct platform_device *pdev)
-{
-	struct vt8500_port *vt8500_port = platform_get_drvdata(pdev);
-
-	clk_disable_unprepare(vt8500_port->clk);
-	uart_remove_one_port(&vt8500_uart_driver, &vt8500_port->uart);
-
-	return 0;
-}
-
 static struct platform_driver vt8500_platform_driver = {
 	.probe  = vt8500_serial_probe,
-	.remove = vt8500_serial_remove,
 	.driver = {
 		.name = "vt8500_serial",
 		.of_match_table = wmt_dt_ids,
+		.suppress_bind_attrs = true,
 	},
 };
 
@@ -764,19 +753,4 @@ static int __init vt8500_serial_init(void)
 
 	return ret;
 }
-
-static void __exit vt8500_serial_exit(void)
-{
-#ifdef CONFIG_SERIAL_VT8500_CONSOLE
-	unregister_console(&vt8500_console);
-#endif
-	platform_driver_unregister(&vt8500_platform_driver);
-	uart_unregister_driver(&vt8500_uart_driver);
-}
-
-module_init(vt8500_serial_init);
-module_exit(vt8500_serial_exit);
-
-MODULE_AUTHOR("Alexey Charkov <alchark@gmail.com>");
-MODULE_DESCRIPTION("Driver for vt8500 serial device");
-MODULE_LICENSE("GPL v2");
+device_initcall(vt8500_serial_init);
-- 
2.8.4

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

* [PATCH 3/3] serial: m32r_sio: make it explicitly non-modular
       [not found] <20160620225505.7320-1-paul.gortmaker@windriver.com>
  2016-06-20 22:55 ` [PATCH 1/3] serial: pxa: make it explicitly non-modular Paul Gortmaker
  2016-06-20 22:55 ` [PATCH 2/3] serial: vt8500_serial: " Paul Gortmaker
@ 2016-06-20 22:55 ` Paul Gortmaker
  2016-06-21  5:30 ` [PATCH 0/3] serial: remove modular code from a few more non-modular drivers Paul Gortmaker
  3 siblings, 0 replies; 4+ messages in thread
From: Paul Gortmaker @ 2016-06-20 22:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: Paul Gortmaker, Greg Kroah-Hartman, Jiri Slaby, linux-serial

The Kconfig currently controlling compilation of this code is:

drivers/tty/serial/Kconfig:config SERIAL_M32R_SIO
drivers/tty/serial/Kconfig:     bool "M32R SIO I/F"

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

We don't replace module.h with init.h since the file already has that.

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/m32r_sio.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/tty/serial/m32r_sio.c b/drivers/tty/serial/m32r_sio.c
index 68765f7c2645..ea29017d320a 100644
--- a/drivers/tty/serial/m32r_sio.c
+++ b/drivers/tty/serial/m32r_sio.c
@@ -30,7 +30,6 @@
 #define SUPPORT_SYSRQ
 #endif
 
-#include <linux/module.h>
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
 #include <linux/ioport.h>
@@ -1060,19 +1059,4 @@ static int __init m32r_sio_init(void)
 
 	return ret;
 }
-
-static void __exit m32r_sio_exit(void)
-{
-	int i;
-
-	for (i = 0; i < UART_NR; i++)
-		uart_remove_one_port(&m32r_sio_reg, &m32r_sio_ports[i].port);
-
-	uart_unregister_driver(&m32r_sio_reg);
-}
-
-module_init(m32r_sio_init);
-module_exit(m32r_sio_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("Generic M32R SIO serial driver");
+device_initcall(m32r_sio_init);
-- 
2.8.4

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

* Re: [PATCH 0/3] serial: remove modular code from a few more non-modular drivers
       [not found] <20160620225505.7320-1-paul.gortmaker@windriver.com>
                   ` (2 preceding siblings ...)
  2016-06-20 22:55 ` [PATCH 3/3] serial: m32r_sio: " Paul Gortmaker
@ 2016-06-21  5:30 ` Paul Gortmaker
  3 siblings, 0 replies; 4+ messages in thread
From: Paul Gortmaker @ 2016-06-21  5:30 UTC (permalink / raw)
  To: linux-kernel
  Cc: Alexey Charkov, Greg Kroah-Hartman, Jiri Slaby, Tony Prisk, linux-serial

[[PATCH 0/3] serial: remove modular code from a few more non-modular drivers] On 20/06/2016 (Mon 18:55) Paul Gortmaker wrote:

> 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.
> 
> We have already fixed a bunch of these in drivers/tty already, so there
> is really nothing new to see here (at least for the serial maintainers).

Apologies in advance to anyone who is trying to find these patches via
an archive of linux-kernel or linux-serial ; it seems that we hit a
window where a glitch at vger.kernel.org was rejecting incoming mails.

P.
--

> 
> Changes seen here cover the following categories:
> 
>   -just replacement of modular macros with their non-modular
>    equivalents that CPP would have inserted anyway
> 
>   -the removal of including module.h ; replaced with init.h
>    as required based on whether the file already had it.
> 
>   -the removal of any/all unused/orphaned __exit functions
>    that would never be called/exercised.
> 
>   -the removal of any ".remove" functions that were hooked into
>    the driver struct.   This ".remove" function would of
>    course not be called from the __exit function since that was
>    never run.  However in theory, someone could have triggered it
>    via sysfs unbind, even though there isn't a sensible use case
>    for doing so.  So to cover that possibility, we've also disabled
>    sysfs unbind in the driver.
> 
> In doing so we get rid of ~70 lines of dead code across 3 drivers.
> 
> There are no initcall level changes here; everything was at the level
> of device_initcall and remains so, by using the builtin equivalents.
> 
> Build tested for arm(2) and m32r(1) on the linux-next tree from today
> to ensure no silly typos crept in.
> 
> If there is a desire for any of these to be modular, we can definitely
> consider that, but by default the changes here keep the code consistent
> with existing behaviour.  Thus I do not expand functionality into the
> modular realm that I can't run time test, or even know if the modular
> instance has a sensible modular use case.
> 
> Paul.
> ---
> 
> Cc: Alexey Charkov <alchark@gmail.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jiri Slaby <jslaby@suse.com>
> Cc: Tony Prisk <linux@prisktech.co.nz>
> Cc: linux-serial@vger.kernel.org
> 
> Paul Gortmaker (3):
>   serial: pxa: make it explicitly non-modular
>   serial: vt8500_serial: make it explicitly non-modular
>   serial: m32r_sio: make it explicitly non-modular
> 
>  drivers/tty/serial/m32r_sio.c      | 18 +-----------------
>  drivers/tty/serial/pxa.c           | 31 +++----------------------------
>  drivers/tty/serial/vt8500_serial.c | 30 ++----------------------------
>  3 files changed, 6 insertions(+), 73 deletions(-)
> 
> -- 
> 2.8.4

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

end of thread, other threads:[~2016-06-21  5:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20160620225505.7320-1-paul.gortmaker@windriver.com>
2016-06-20 22:55 ` [PATCH 1/3] serial: pxa: make it explicitly non-modular Paul Gortmaker
2016-06-20 22:55 ` [PATCH 2/3] serial: vt8500_serial: " Paul Gortmaker
2016-06-20 22:55 ` [PATCH 3/3] serial: m32r_sio: " Paul Gortmaker
2016-06-21  5:30 ` [PATCH 0/3] serial: remove modular code from a few more non-modular drivers 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).