Skip to contentSkip to conversation

mips: demodularize non-modular drivers.

PATCH New Paul Gortmaker 1 participant 5 messages Aug 15, 2016

Subsystems (4)
lore
Share & tools
lore
#3 lore raw

PATCH 3/4 mips: lantiq: make vmmc explicitly non-modular

In reply to Paul Gortmaker

The Makefile entry controlling compilation of this code is:

arch/mips/lantiq/xway/vmmc.o
---> arch/mips/lantiq/xway/Makefile:obj-y += vmmc.o

...meaning that it currently is not being built as a module by anyone.

Since module_platform_driver() uses the same init level priority as builtin_platform_driver() the init ordering remains unchanged with this commit.

Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

We replace module.h with export.h since the file does actually use EXPORT_SYMBOL.

---
 arch/mips/lantiq/xway/vmmc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/mips/lantiq/xway/vmmc.c +2 -4
index 4625495f9230..577ec81b557d 100644
@@ -6,7 +6,7 @@
  *  Copyright (C) 2012 John Crispin <[email protected]>
  */
 
-#include <linux/module.h>
+#include <linux/export.h>
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
 #include <linux/dma-mapping.h>
@@ -55,7 +55,6 @@ static const struct of_device_id vmmc_match[] = {
 	{ .compatible = "lantiq,vmmc-xway" },
 	{},
 };
-MODULE_DEVICE_TABLE(of, vmmc_match);
 
 static struct platform_driver vmmc_driver = {
 	.probe = vmmc_probe,
@@ -64,5 +63,4 @@ static struct platform_driver vmmc_driver = {
 		.of_match_table = vmmc_match,
 	},
 };
-
-module_platform_driver(vmmc_driver);
+builtin_platform_driver(vmmc_driver);
Signature · 1 line
2.8.4
#2 lore raw

PATCH 2/4 mips: ralink: make timer explicitly non-modular

In reply to Paul Gortmaker

The Makefile entry controlling compilation of this code is "obj-y" 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_platform_driver() uses the same init level priority as builtin_platform_driver() the init ordering remains unchanged with this commit.

Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

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.

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

---
 arch/mips/ralink/timer.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)
arch/mips/ralink/timer.c +7 -21
index b0343ff336c5..8077ff39bdea 100644
@@ -1,4 +1,7 @@
 /*
+ * Ralink RT2880 timer
+ * Author: John Crispin
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 as published
  * by the Free Software Foundation.
@@ -6,7 +9,6 @@
  * Copyright (C) 2013 John Crispin <[email protected]>
 */
 
-#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/timer.h>
@@ -152,33 +154,17 @@ static int rt_timer_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int rt_timer_remove(struct platform_device *pdev)
-{
-	struct rt_timer *rt = platform_get_drvdata(pdev);
-
-	rt_timer_disable(rt);
-	rt_timer_free(rt);
-
-	return 0;
-}
-
 static const struct of_device_id rt_timer_match[] = {
 	{ .compatible = "ralink,rt2880-timer" },
 	{},
 };
-MODULE_DEVICE_TABLE(of, rt_timer_match);
 
 static struct platform_driver rt_timer_driver = {
 	.probe = rt_timer_probe,
-	.remove = rt_timer_remove,
 	.driver = {
-		.name		= "rt-timer",
-		.of_match_table	= rt_timer_match
+		.name			= "rt-timer",
+		.of_match_table		= rt_timer_match,
+		.suppress_bind_attrs	= true,
 	},
 };
-
-module_platform_driver(rt_timer_driver);
-
-MODULE_DESCRIPTION("Ralink RT2880 timer");
-MODULE_AUTHOR("John Crispin <[email protected]");
-MODULE_LICENSE("GPL");
+builtin_platform_driver(rt_timer_driver);
Signature · 1 line
2.8.4
#4 lore raw

PATCH 4/4 mips: lantiq: make xrx200_phy_fw explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

arch/mips/lantiq/Kconfig:config XRX200_PHY_FW
arch/mips/lantiq/Kconfig: bool "XRX200 PHY firmware loader"

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

Since module_platform_driver() uses the same init level priority as builtin_platform_driver() the init ordering remains unchanged with this commit.

Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

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.

We don't replace module.h with init.h since the file doesn't need that.

---
 arch/mips/lantiq/xway/xrx200_phy_fw.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
arch/mips/lantiq/xway/xrx200_phy_fw.c +4 -8
index 71e518c1e7e7..f0a0f2d431b2 100644
@@ -1,4 +1,7 @@
 /*
+ * Lantiq XRX200 PHY Firmware Loader
+ * Author: John Crispin
+ *
  *  This program is free software; you can redistribute it and/or modify it
  *  under the terms of the GNU General Public License version 2 as published
  *  by the Free Software Foundation.
@@ -8,7 +11,6 @@
 
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
-#include <linux/module.h>
 #include <linux/firmware.h>
 #include <linux/of_platform.h>
 
@@ -100,7 +102,6 @@ static const struct of_device_id xway_phy_match[] = {
 	{ .compatible = "lantiq,phy-xrx200" },
 	{},
 };
-MODULE_DEVICE_TABLE(of, xway_phy_match);
 
 static struct platform_driver xway_phy_driver = {
 	.probe = xway_phy_fw_probe,
@@ -109,9 +110,4 @@ static struct platform_driver xway_phy_driver = {
 		.of_match_table = xway_phy_match,
 	},
 };
-
-module_platform_driver(xway_phy_driver);
-
-MODULE_AUTHOR("John Crispin <[email protected]>");
-MODULE_DESCRIPTION("Lantiq XRX200 PHY Firmware Loader");
-MODULE_LICENSE("GPL");
+builtin_platform_driver(xway_phy_driver);
Signature · 1 line
2.8.4
#0 lore raw

cover mips: demodularize non-modular drivers.

This series of commits is a part of a larger project to ensure people don't reference modular support functions in non-modular code. Overall there was roughly 5k lines of dead code in the kernel due to this. So far we've fixed several areas, like tty, x86, net, ... and we continue to work on other areas.

There are several reasons to not use module support for code that can never be built as a module, but the big ones are:

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

This represents the drivers actually using modular functions; there are also drivers/files that include module.h but don't use any of the macros or functions within it. Those MIPS instances will be handled separately.

Paul.

---

Cc Aurelien Jarno <[email protected]>
Cc Hauke Mehrtens <[email protected]>
Cc John Crispin <[email protected]>
Cc "Rafał Miłecki" <[email protected]>
Cc Ralf Baechle <[email protected]>

Paul Gortmaker (4):
mips: bcm47xx: make serial explicitly non-modular
mips: ralink: make timer explicitly non-modular
mips: lantiq: make vmmc explicitly non-modular
mips: lantiq: make xrx200_phy_fw explicitly non-modular

 arch/mips/bcm47xx/serial.c            | 11 ++++-------
 arch/mips/lantiq/xway/vmmc.c          |  6 ++----
 arch/mips/lantiq/xway/xrx200_phy_fw.c | 12 ++++--------
 arch/mips/ralink/timer.c              | 28 +++++++---------------------
 4 files changed, 17 insertions(+), 40 deletions(-)
Signature · 1 line
2.8.4
#1 lore raw

PATCH 1/4 mips: bcm47xx: make serial explicitly non-modular

The Makefile entry controlling compilation of this code is "obj-y" 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.

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 was (or is now) contained at the top of the file in the comments.

Cc Hauke Mehrtens <[email protected]>
Cc "Rafał Miłecki" <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Aurelien Jarno <[email protected]>
---
 arch/mips/bcm47xx/serial.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
arch/mips/bcm47xx/serial.c +4 -7
index df761d38f7fc..e3c9872a4aa5 100644
@@ -1,4 +1,7 @@
 /*
+ * 8250 UART probe driver for the BCM47XX platforms
+ * Author: Aurelien Jarno
+ *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -6,7 +9,6 @@
  * Copyright (C) 2007 Aurelien Jarno <[email protected]>
  */
 
-#include <linux/module.h>
 #include <linux/init.h>
 #include <linux/serial.h>
 #include <linux/serial_8250.h>
@@ -88,9 +90,4 @@ static int __init uart8250_init(void)
 	}
 	return -EINVAL;
 }
-
-module_init(uart8250_init);
-
-MODULE_AUTHOR("Aurelien Jarno <[email protected]>");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("8250 UART probe driver for the BCM47XX platforms");
+device_initcall(uart8250_init);
Signature · 1 line
2.8.4