phy: remove needless usage of module header
cover phy: remove needless usage of module header
The most important thing to note here, is these clean-ups make no changes to the final generated run-time. The 1st commit removes an unused function, otherwise the generated objects are also unchanged.
The work here represents a scan over the phy dir, looking for files that have nothing to do with a modular use case, but are using modular infrastructure regardless.
We are trying to make driver code consistent with the Makefiles/Kconfigs that control them. This means not using modular functions/macros for drivers that can never be built as a module. This has been done in quite a lot of other mainline subsystem dirs already.
Using modular infrastructure in non-modules might seem harmless, but some of the downfalls this leads to 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 drivers and spreads quickly.
As a data point for #3 above, an empty C file that just includes the module.h header generates over 750kB of CPP output. Repeating the same experiment with init.h and the result is less than 12kB; with export.h it is only about 1/2kB; with both it still is less than 12kB.
Build tested on x86-64 and ARM-64.
Paul.
---
Paul Gortmaker (3):
phy: make phy-core explicitly non-modular
phy: make phy-mvebu-sata explicitly non-modular
phy: make phy-armada375-usb2 explicitly non-modular
drivers/phy/marvell/phy-armada375-usb2.c | 8 +------- drivers/phy/marvell/phy-mvebu-sata.c | 9 ++------- drivers/phy/phy-core.c | 12 +----------- 3 files changed, 4 insertions(+), 25 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/3 phy: make phy-core explicitly non-modular
The Kconfig currently controlling compilation of this code is:
drivers/phy/Kconfig:config GENERIC_PHYdrivers/phy/Kconfig: bool "PHY Core"
...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 don't remove module.h since the file is using other modular fcns (to load other phy modules) even though the core support itself is non-modular.
We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.
--- drivers/phy/phy-core.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/phy/phy-core.c +1 -11
@@ -1048,14 +1048,4 @@ static int __init phy_core_init(void)return 0 ; } -module_init (phy_core_init); - -static void __exit phy_core_exit(void) -{ -class_destroy (phy_class); -} -module_exit (phy_core_exit); - -MODULE_DESCRIPTION ("Generic PHY Framework" ); -MODULE_AUTHOR ("Kishon Vijay Abraham I <[email protected]>" ); -MODULE_LICENSE ("GPL v2" ); +device_initcall (phy_core_init);
Signature · 1 line
2.7.4
PATCH 2/3 phy: make phy-mvebu-sata explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/phy/Kconfig:config PHY_MVEBU_SATAdrivers/phy/Kconfig: def_bool y
...meaning that it currently is not being built as a module by anyone.
Lets remove the couple of traces of modular infrastructure, 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 is already contained at the top of the file in the comments.
--- drivers/phy/marvell/phy-mvebu-sata.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/phy/marvell/phy-mvebu-sata.c +2 -7
@@ -10,7 +10,7 @@*/ #include <linux/kernel.h> -#include <linux/module.h> +#include <linux/init.h> #include <linux/clk.h> #include <linux/phy/phy.h> #include <linux/io.h>
@@ -122,7 +122,6 @@ static const struct of_device_id phy_mvebu_sata_of_match[] = { { .compatible = "marvell,mvebu-sata-phy" }, { }, }; -MODULE_DEVICE_TABLE (of, phy_mvebu_sata_of_match);static struct platform_driver phy_mvebu_sata_driver = { .probe = phy_mvebu_sata_probe,
@@ -131,8 +130,4 @@ static struct platform_driver phy_mvebu_sata_driver = { .of_match_table = phy_mvebu_sata_of_match, } }; -module_platform_driver (phy_mvebu_sata_driver); - -MODULE_AUTHOR ("Andrew Lunn <[email protected]>" ); -MODULE_DESCRIPTION ("Marvell MVEBU SATA PHY driver" ); -MODULE_LICENSE ("GPL v2" ); +builtin_platform_driver (phy_mvebu_sata_driver);
Signature · 1 line
2.7.4
PATCH 3/3 phy: make phy-armada375-usb2 explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/phy/marvell/Kconfig:config ARMADA375_USBCLUSTER_PHYdrivers/phy/marvell/Kconfig: def_bool y
...meaning that it currently is not being built as a module by anyone.
Lets remove the couple of traces of modular infrastructure, 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 is already contained at the top of the file in the comments.
--- drivers/phy/marvell/phy-armada375-usb2.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/phy/marvell/phy-armada375-usb2.c +1 -7
@@ -18,7 +18,6 @@#include <linux/init.h> #include <linux/io.h> #include <linux/kernel.h> -#include <linux/module.h> #include <linux/of_address.h> #include <linux/phy/phy.h> #include <linux/platform_device.h>
@@ -142,7 +141,6 @@ static const struct of_device_id of_usb_cluster_table[] = { { .compatible = "marvell,armada-375-usb-cluster", }, { /* end of list */ }, }; -MODULE_DEVICE_TABLE (of, of_usb_cluster_table);static struct platform_driver armada375_usb_phy_driver = { .probe = armada375_usb_phy_probe,
@@ -151,8 +149,4 @@ static struct platform_driver armada375_usb_phy_driver = { .name = "armada-375-usb-cluster", } }; -module_platform_driver (armada375_usb_phy_driver); - -MODULE_DESCRIPTION ("Armada 375 USB cluster driver" ); -MODULE_AUTHOR ("Gregory CLEMENT <[email protected]>" ); -MODULE_LICENSE ("GPL" ); +builtin_platform_driver (armada375_usb_phy_driver);
Signature · 1 line
2.7.4
Re: [PATCH 3/3] phy: make phy-armada375-usb2 explicitly non-modular
Hi Paul,
Quoted 14 lines · Paul Gortmaker
The
Kconfigcurrently controlling compilation of this code is:drivers/phy/marvell/Kconfig:config
ARMADA375_USBCLUSTER_PHYdrivers/phy/marvell/Kconfig:def_booly...meaning that it currently is not being built as a module by anyone.
Lets remove the couple of traces of modular infrastructure, so that when reading the driver there is no doubt it is builtin-only.
Since
module_platform_driver()uses the same init level priority asbuiltin_platform_driver()the init ordering remains unchanged with this commit.
Quoted 8 lines
Also note that
MODULE_DEVICE_TABLEis a no-op for non-modular code.We also delete the
MODULE_LICENSEtag etc. since all that information is already contained at the top of the file in the comments.Cc Kishon Vijay Abraham I <[email protected]>Cc Gregory CLEMENT <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>
Thanks,
Gregory
Quoted 37 lines
--- drivers/phy/marvell/phy-armada375-usb2.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)drivers/phy/marvell/phy-armada375-usb2.c +1
-7@@ -18,7 +18,6 @@#include <linux/init.h> #include <linux/io.h> #include <linux/kernel.h> -#include <linux/module.h> #include <linux/of_address.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> @@ -142,7 +141,6 @@ static const struct of_device_id of_usb_cluster_table[] = { { .compatible = "marvell,armada-375-usb-cluster", }, { /* end of list */ }, }; -MODULE_DEVICE_TABLE (of, of_usb_cluster_table);static struct platform_driver armada375_usb_phy_driver = { .probe = armada375_usb_phy_probe,@@ -151,8 +149,4 @@ static struct platform_driver armada375_usb_phy_driver = { .name = "armada-375-usb-cluster", } }; -module_platform_driver (armada375_usb_phy_driver); - -MODULE_DESCRIPTION ("Armada 375 USB cluster driver" ); -MODULE_AUTHOR ("Gregory CLEMENT <[email protected]>" ); -MODULE_LICENSE ("GPL" ); +builtin_platform_driver (armada375_usb_phy_driver);Signature · 1 line
2.7.4
Signature · 3 lines
Gregory Clement, Bootlin Embedded Linux and Kernel engineering http://bootlin.com
Kishon Vijay Abraham I
AppliedQuoted 23 lines · Paul Gortmaker
The most important thing to note here, is these clean-ups make no changes to the final generated run-time. The 1st commit removes an unused function, otherwise the generated objects are also unchanged.
The work here represents a scan over the phy dir, looking for files that have nothing to do with a modular use case, but are using modular infrastructure regardless.
We are trying to make driver code consistent with the Makefiles/Kconfigs that control them. This means not using modular functions/macros for drivers that can never be built as a module. This has been done in quite a lot of other mainline subsystem dirs already.
Using modular infrastructure in non-modules might seem harmless, but some of the downfalls this leads to are:
(1) it is easy to accidentally write unused
module_exitand remove code
(2) it can be misleading when reading the source, thinking it can be modular when theMakefileand/orKconfigprohibit it
(3) it requires the include of themodule.hheader file which in turn includes nearly everything else, thus adding to CPP overhead.
(4) it gets copied/replicated into other drivers and spreads quickly.
Quoted 6 lines
As a data point for #3 above, an empty C file that just includes the
module.hheader generates over 750kB of CPP output. Repeating the same experiment withinit.hand the result is less than 12kB; withexport.hit is only about 1/2kB; with both it still is less than 12kB.Build tested on x86-64 and ARM-64.
merged, thanks!
-Kishon
Quoted 18 lines
Paul.
---Cc Andrew Lunn <[email protected]>Cc Gregory CLEMENT <[email protected]>Cc Kishon Vijay Abraham I <[email protected]>Paul Gortmaker (3):
phy: make phy-core explicitly non-modular
phy: make phy-mvebu-sata explicitly non-modular
phy: make phy-armada375-usb2 explicitly non-modulardrivers/phy/marvell/phy-armada375-usb2.c | 8 +------- drivers/phy/marvell/phy-mvebu-sata.c | 9 ++------- drivers/phy/phy-core.c | 12 +----------- 3 files changed, 4 insertions(+), 25 deletions(-)