Skip to contentSkip to conversation

gpio: batch #2: remove modular code from non-modular drivers

PATCH In review Paul Gortmaker 2 participants 13 messages Apr 1, 2016 – Apr 5, 2016 GPIO

lore
Share & tools
lore
#0 lore raw

cover gpio: batch #2: remove modular code from non-modular drivers

For GPIO, I've divided up the the audit of modular usage in non-modular drivers into three categories to ease review and limit the batch size. Group #1 has been submitted and merged ; this group here is group #2.

The breakdown of the three groups is as follows:

1) just replacement of modular macros with their non-modular equivalents that CPP would have inserted anyway ; this means runtime equivalence and actually also binary equivalence.

2) as per #1 but also with the removal of unused/orphaned __exit functions that could never be called/exercised. This also maintains runtime equivalence, but since the unused __exit function is gone, there is a reduction in the object file size and hence not binary equivalence, eg:

       before: -rw-rw-r-- 1 8828 drivers/gpio/gpio-rc5t583.o
       after:  -rw-rw-r-- 1 7396 drivers/gpio/gpio-rc5t583.o

3) as per #2 but also with the removal of a ".remove" function that is
hooked into the driver struct. This ".remove" function would of
course not be called from the __exit function since that is 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 these drivers.

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.

Interestingly enough, none of the drivers patched here were using the module_init() binding ; they all used subsys_initcall() instead, which I think reinforces point #4 above - i.e. nobody writes a new driver from scratch.

Build tested for x86-64, arm and arm64 on today's linux-next to ensure no silly typos crept in.

Paul.
---

Cc Alexandre Courbot <[email protected]>
Cc Graeme Gregory <[email protected]>
Cc Gregory Bean <[email protected]>
Cc Hanumath Prasad <[email protected]>
Cc Jorge Eduardo Candelaria <[email protected]>
Cc Laxman Dewangan <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Rabin Vincent <[email protected]>

Paul Gortmaker (6):
drivers/gpio: make gpio-rc5t583.c explicitly non-modular drivers/gpio: make gpio-tc3589x.c explicitly non-modular drivers/gpio: make gpio-sx150x.c explicitly non-modular drivers/gpio: make gpio-palmas.c explicitly non-modular drivers/gpio: make gpio-tps65910.c explicitly non-modular drivers/gpio: make gpio-tps6586x.c explicitly non-modular

 drivers/gpio/gpio-palmas.c   | 13 +------------
 drivers/gpio/gpio-rc5t583.c  | 12 ------------
 drivers/gpio/gpio-sx150x.c   | 15 ++++-----------
 drivers/gpio/gpio-tc3589x.c  | 11 -----------
 drivers/gpio/gpio-tps6586x.c | 13 +------------
 drivers/gpio/gpio-tps65910.c | 16 ++--------------
 6 files changed, 8 insertions(+), 72 deletions(-)
Signature · 1 line
2.6.1
#1 lore raw

PATCH 1/6 drivers/gpio: make gpio-rc5t583.c explicitly non-modular

The Kconfig currently controlling compilation of this code is:

drivers/gpio/Kconfig:config GPIO_RC5T583
drivers/gpio/Kconfig: bool "RICOH RC5T583 GPIO"

...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 was not in use by this code, 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.

Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
Cc Laxman Dewangan <[email protected]>
---
 drivers/gpio/gpio-rc5t583.c | 12 ------------
 1 file changed, 12 deletions(-)
drivers/gpio/gpio-rc5t583.c +0 -12
index 1d6100fa312a..3b4dc1a9a68d 100644
@@ -23,7 +23,6 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
-#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/device.h>
 #include <linux/gpio.h>
@@ -152,14 +151,3 @@ static int __init rc5t583_gpio_init(void)
 	return platform_driver_register(&rc5t583_gpio_driver);
 }
 subsys_initcall(rc5t583_gpio_init);
-
-static void __exit rc5t583_gpio_exit(void)
-{
-	platform_driver_unregister(&rc5t583_gpio_driver);
-}
-module_exit(rc5t583_gpio_exit);
-
-MODULE_AUTHOR("Laxman Dewangan <[email protected]>");
-MODULE_DESCRIPTION("GPIO interface for RC5T583");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("platform:rc5t583-gpio");
Signature · 1 line
2.6.1
#2 lore raw

Re: [PATCH 1/6] drivers/gpio: make gpio-rc5t583.c explicitly non-modular

Quoted 13 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/gpio/Kconfig:config GPIO_RC5T583
drivers/gpio/Kconfig: bool "RICOH RC5T583 GPIO"

...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 was not in use by this code, the init ordering remains unchanged with this commit.

Quoted 8 lines

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 Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
Cc Laxman Dewangan <[email protected]>

Patch applied.

Yours,
Linus Walleij

#3 lore raw

PATCH 2/6 drivers/gpio: make gpio-tc3589x.c explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/gpio/Kconfig:config GPIO_TC3589X
drivers/gpio/Kconfig: bool "TC3589X GPIOs"

...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 was not in use by this code, 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.

Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
Cc Rabin Vincent <[email protected]>
Cc Hanumath Prasad <[email protected]>
---
 drivers/gpio/gpio-tc3589x.c | 11 -----------
 1 file changed, 11 deletions(-)
drivers/gpio/gpio-tc3589x.c +0 -11
index 4f566e6b81f1..a29dec137373 100644
@@ -6,7 +6,6 @@
  * Author: Rabin Vincent <[email protected]> for ST-Ericsson
  */
 
-#include <linux/module.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
@@ -311,13 +310,3 @@ static int __init tc3589x_gpio_init(void)
 	return platform_driver_register(&tc3589x_gpio_driver);
 }
 subsys_initcall(tc3589x_gpio_init);
-
-static void __exit tc3589x_gpio_exit(void)
-{
-	platform_driver_unregister(&tc3589x_gpio_driver);
-}
-module_exit(tc3589x_gpio_exit);
-
-MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("TC3589x GPIO driver");
-MODULE_AUTHOR("Hanumath Prasad, Rabin Vincent");
Signature · 1 line
2.6.1
#4 lore raw

Re: [PATCH 2/6] drivers/gpio: make gpio-tc3589x.c explicitly non-modular

Quoted 16 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/gpio/Kconfig:config GPIO_TC3589X
drivers/gpio/Kconfig: bool "TC3589X GPIOs"

...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 was not in use by this code, 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.

Quoted 6 lines
Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
Cc Rabin Vincent <[email protected]>
Cc Hanumath Prasad <[email protected]>

Patch applied.

Yours,
Linus Walleij

#5 lore raw

PATCH 3/6 drivers/gpio: make gpio-sx150x.c explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/gpio/Kconfig:config GPIO_SX150X
drivers/gpio/Kconfig: bool "Semtech SX150x I2C GPIO expander"

...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 was not in use by this code, the init ordering remains unchanged with this commit.

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 Gregory Bean <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
---
 drivers/gpio/gpio-sx150x.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/gpio/gpio-sx150x.c +4 -11
index d387eb524bf3..d57e8ad0bfd2 100644
@@ -1,5 +1,9 @@
 /* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
  *
+ * Driver for Semtech SX150X I2C GPIO Expanders
+ *
+ * Author: Gregory Bean <[email protected]>
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
  * only version 2 as published by the Free Software Foundation.
@@ -19,7 +23,6 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/slab.h>
 #include <linux/i2c/sx150x.h>
@@ -718,13 +721,3 @@ static int __init sx150x_init(void)
 	return i2c_add_driver(&sx150x_driver);
 }
 subsys_initcall(sx150x_init);
-
-static void __exit sx150x_exit(void)
-{
-	return i2c_del_driver(&sx150x_driver);
-}
-module_exit(sx150x_exit);
-
-MODULE_AUTHOR("Gregory Bean <[email protected]>");
-MODULE_DESCRIPTION("Driver for Semtech SX150X I2C GPIO Expanders");
-MODULE_LICENSE("GPL v2");
Signature · 1 line
2.6.1
#6 lore raw

Re: [PATCH 3/6] drivers/gpio: make gpio-sx150x.c explicitly non-modular

Quoted 13 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/gpio/Kconfig:config GPIO_SX150X
drivers/gpio/Kconfig: bool "Semtech SX150x I2C GPIO expander"

...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 was not in use by this code, the init ordering remains unchanged with this commit.

Quoted 8 lines

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 Gregory Bean <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>

Patch applied.

Yours,
Linus Walleij

#7 lore raw

PATCH 4/6 drivers/gpio: make gpio-palmas.c explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/gpio/Kconfig:config GPIO_PALMAS
drivers/gpio/Kconfig: bool "TI PALMAS series PMICs GPIO"

...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 was not in use by this code, 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.

Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
Cc Laxman Dewangan <[email protected]>
---
 drivers/gpio/gpio-palmas.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/gpio/gpio-palmas.c +1 -12
index 6f27b3d94d53..e248707ca39e 100644
@@ -20,7 +20,7 @@
 
 #include <linux/gpio.h>
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/mfd/palmas.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -218,14 +218,3 @@ static int __init palmas_gpio_init(void)
 	return platform_driver_register(&palmas_gpio_driver);
 }
 subsys_initcall(palmas_gpio_init);
-
-static void __exit palmas_gpio_exit(void)
-{
-	platform_driver_unregister(&palmas_gpio_driver);
-}
-module_exit(palmas_gpio_exit);
-
-MODULE_ALIAS("platform:palmas-gpio");
-MODULE_AUTHOR("Laxman Dewangan <[email protected]>");
-MODULE_DESCRIPTION("GPIO driver for TI Palmas series PMICs");
-MODULE_LICENSE("GPL v2");
Signature · 1 line
2.6.1
#8 lore raw

Re: [PATCH 4/6] drivers/gpio: make gpio-palmas.c explicitly non-modular

Quoted 13 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/gpio/Kconfig:config GPIO_PALMAS
drivers/gpio/Kconfig: bool "TI PALMAS series PMICs GPIO"

...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 was not in use by this code, the init ordering remains unchanged with this commit.

Quoted 8 lines

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 Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
Cc Laxman Dewangan <[email protected]>

Patch applied.

Yours,
Linus Walleij

#9 lore raw

PATCH 5/6 drivers/gpio: make gpio-tps65910.c explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/gpio/Kconfig:config GPIO_TPS65910
drivers/gpio/Kconfig: bool "TPS65910 GPIO"

...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 was not in use by this code, 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.

Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
Cc Graeme Gregory <[email protected]>
Cc Jorge Eduardo Candelaria <[email protected]>
---
 drivers/gpio/gpio-tps65910.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/gpio/gpio-tps65910.c +2 -14
index cdbd7c740043..0ae6a5a54ea8 100644
@@ -4,7 +4,7 @@
  * Copyright 2010 Texas Instruments Inc.
  *
  * Author: Graeme Gregory <[email protected]>
- * Author: Jorge Eduardo Candelaria [email protected]>
+ * Author: Jorge Eduardo Candelaria <[email protected]>
  *
  *  This program is free software; you can redistribute it and/or modify it
  *  under  the terms of the GNU General  Public License as published by the
@@ -14,7 +14,7 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/gpio.h>
 #include <linux/i2c.h>
@@ -193,15 +193,3 @@ static int __init tps65910_gpio_init(void)
 	return platform_driver_register(&tps65910_gpio_driver);
 }
 subsys_initcall(tps65910_gpio_init);
-
-static void __exit tps65910_gpio_exit(void)
-{
-	platform_driver_unregister(&tps65910_gpio_driver);
-}
-module_exit(tps65910_gpio_exit);
-
-MODULE_AUTHOR("Graeme Gregory <[email protected]>");
-MODULE_AUTHOR("Jorge Eduardo Candelaria [email protected]>");
-MODULE_DESCRIPTION("GPIO interface for TPS65910/TPS6511 PMICs");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("platform:tps65910-gpio");
Signature · 1 line
2.6.1
#10 lore raw

Re: [PATCH 5/6] drivers/gpio: make gpio-tps65910.c explicitly non-modular

Quoted 16 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/gpio/Kconfig:config GPIO_TPS65910
drivers/gpio/Kconfig: bool "TPS65910 GPIO"

...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 was not in use by this code, 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.

Quoted 6 lines
Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
Cc Graeme Gregory <[email protected]>
Cc Jorge Eduardo Candelaria <[email protected]>

Patch applied.

Yours,
Linus Walleij

#11 lore raw

PATCH 6/6 drivers/gpio: make gpio-tps6586x.c explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/gpio/Kconfig:config GPIO_TPS6586X
drivers/gpio/Kconfig: bool "TPS6586X GPIO"

...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 was not in use by this code, 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.

Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
Cc Laxman Dewangan <[email protected]>
---
 drivers/gpio/gpio-tps6586x.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/gpio/gpio-tps6586x.c +1 -12
index c88bdc8ee2c9..6b15e68a314f 100644
@@ -24,7 +24,7 @@
 #include <linux/errno.h>
 #include <linux/gpio.h>
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/mfd/tps6586x.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
@@ -140,14 +140,3 @@ static int __init tps6586x_gpio_init(void)
 	return platform_driver_register(&tps6586x_gpio_driver);
 }
 subsys_initcall(tps6586x_gpio_init);
-
-static void __exit tps6586x_gpio_exit(void)
-{
-	platform_driver_unregister(&tps6586x_gpio_driver);
-}
-module_exit(tps6586x_gpio_exit);
-
-MODULE_ALIAS("platform:tps6586x-gpio");
-MODULE_DESCRIPTION("GPIO interface for TPS6586X PMIC");
-MODULE_AUTHOR("Laxman Dewangan <[email protected]>");
-MODULE_LICENSE("GPL");
Signature · 1 line
2.6.1
#12 lore raw

Re: [PATCH 6/6] drivers/gpio: make gpio-tps6586x.c explicitly non-modular

Quoted 13 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/gpio/Kconfig:config GPIO_TPS6586X
drivers/gpio/Kconfig: bool "TPS6586X GPIO"

...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 was not in use by this code, the init ordering remains unchanged with this commit.

Quoted 8 lines

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 Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
Cc Laxman Dewangan <[email protected]>

Patch applied.

Yours,
Linus Walleij