Replace module_init with device_initcall in non modules
Subsystems (14)
cover Replace module_init with device_initcall in non modules
This series of commits converts non-modular code that is using the module_init() call to hook itself into the system to instead use device_initcall().
The conversion is a runtime no-op, since module_init actually becomes __initcall in the non-modular case, and that in turn gets mapped onto device_initcall.
We fix this up now, so that we can relocate module_init from init.h into module.h in a future series.
The files changed here are just limited to those that would otherwise have to add module.h to obviously non-modular code, since we don't want to do that.
This work is factored out from what was a previously larger series[1] so that there is a common theme and lower patch count to ease review.
Paul.
[1] https://marc.info/?l=linux-kernel&m=139033951228828
---
Paul Gortmaker (15):
x86: don't use module_init in non-modular intel_mid_vrtc.c
x86: don't use module_init in non-modular devicetree.c code
powerpc: use device_initcall for registering rtc devices
powerpc: don't use module_init in non-modular 83xx suspend code
arm: don't use module_init in non-modular mach-vexpress/spc.c code
alpha: don't use module_init for non-modular core code
ia64: don't use module_init for non-modular core kernel/mca.c code
ia64: don't use module_init in non-modular sim/simscsi.c code
cris: don't use module_init for non-modular core intmem.c code
parisc: don't use module_init for non-modular core pdc_cons code
parisc64: don't use module_init for non-modular core perf code
mn10300: don't use module_init in non-modular flash.c code
sh: don't use module_init in non-modular psw.c code
xtensa: don't use module_init for non-modular core network.c code drivers/clk: don't use module_init in clk-nomadik.c which is
non-modular
arch/alpha/kernel/srmcons.c | 3 +-- arch/arm/mach-vexpress/spc.c | 2 +- arch/cris/arch-v32/mm/intmem.c | 3 +-- arch/ia64/hp/sim/simscsi.c | 11 +---------- arch/ia64/sn/kernel/mca.c | 3 +-- arch/mn10300/unit-asb2303/flash.c | 3 +-- arch/parisc/kernel/pdc_cons.c | 3 +-- arch/parisc/kernel/perf.c | 3 +-- arch/powerpc/kernel/time.c | 2 +- arch/powerpc/platforms/83xx/suspend.c | 3 +-- arch/powerpc/platforms/ps3/time.c | 3 +-- arch/sh/boards/mach-landisk/psw.c | 2 +- arch/x86/kernel/devicetree.c | 2 +- arch/x86/platform/intel-mid/intel_mid_vrtc.c | 3 +-- arch/xtensa/platforms/iss/network.c | 4 +--- drivers/clk/clk-nomadik.c | 3 +-- 16 files changed, 16 insertions(+), 37 deletions(-)
Signature · 1 line
2.2.1
PATCH 1/15 x86: don't use module_init in non-modular intel_mid_vrtc.c
The X86_INTEL_MID option is bool, and hence this code is either present or absent. It will never be modular, so using module_init as an alias for __initcall is rather misleading.
Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.
Note that direct use of __initcall is discouraged, vs. one of the priority categorized subgroups. As __initcall gets mapped onto device_initcall, our use of device_initcall directly in this change means that the runtime impact is zero -- it will remain at level 6 in initcall ordering.
--- arch/x86/platform/intel-mid/intel_mid_vrtc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/platform/intel-mid/intel_mid_vrtc.c +1 -2
@@ -173,5 +173,4 @@ static int __init intel_mid_device_create(void)return platform_device_register (&vrtc_device); } - -module_init (intel_mid_device_create); +device_initcall (intel_mid_device_create);
Signature · 1 line
2.2.1
PATCH 2/15 x86: don't use module_init in non-modular devicetree.c code
In reply to Paul GortmakerThe devicetree.o is built for "OF" -- which is bool, and hence this code is either present or absent. It will never be modular, so using module_init as an alias for __initcall can be somewhat misleading.
Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.
Note that direct use of __initcall is discouraged, vs. one of the priority categorized subgroups. As __initcall gets mapped onto device_initcall, our use of device_initcall directly in this change means that the runtime impact is zero -- it will remain at level 6 in initcall ordering.
--- arch/x86/kernel/devicetree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/devicetree.c +1 -1
@@ -65,7 +65,7 @@ static int __init add_bus_probe(void)return of_platform_bus_probe (NULL , ce4100_ids,NULL ); } -module_init (add_bus_probe); +device_initcall (add_bus_probe);#ifdef CONFIG_PCI struct device_node *pcibios_get_phb_of_node (struct pci_bus *bus)
Signature · 1 line
2.2.1
PATCH 3/15 powerpc: use device_initcall for registering rtc devices
In reply to Paul GortmakerCurrently these two RTC devices are in core platform code where it is not possible for them to be modular. It will never be modular, so using module_init as an alias for __initcall can be somewhat misleading.
Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.
Note that direct use of __initcall is discouraged, vs. one of the priority categorized subgroups. As __initcall gets mapped onto device_initcall, our use of device_initcall directly in this change means that the runtime impact is zero -- they will remain at level 6 in initcall ordering.
--- arch/powerpc/kernel/time.c | 2 +- arch/powerpc/platforms/ps3/time.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/kernel/time.c +1 -1
@@ -1124,4 +1124,4 @@ static int __init rtc_init(void)return PTR_ERR_OR_ZERO (pdev); } -module_init (rtc_init); +device_initcall (rtc_init);
arch/powerpc/platforms/ps3/time.c +1 -2
@@ -92,5 +92,4 @@ static int __init ps3_rtc_init(void)return PTR_ERR_OR_ZERO (pdev); } - -module_init (ps3_rtc_init); +device_initcall (ps3_rtc_init);
Signature · 1 line
2.2.1
PATCH 4/15 powerpc: don't use module_init in non-modular 83xx suspend code
In reply to Paul GortmakerThe suspend.o is built for SUSPEND -- which is bool, and hence this code is either present or absent. It will never be modular, so using module_init as an alias for __initcall can be somewhat misleading.
Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.
Note that direct use of __initcall is discouraged, vs. one of the priority categorized subgroups. As __initcall gets mapped onto device_initcall, our use of device_initcall directly in this change means that the runtime impact is zero -- it will remain at level 6 in initcall ordering.
--- arch/powerpc/platforms/83xx/suspend.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/powerpc/platforms/83xx/suspend.c +1 -2
@@ -445,5 +445,4 @@ static int pmc_init(void) {return platform_driver_register (&pmc_driver); } - -module_init (pmc_init); +device_initcall (pmc_init);
Signature · 1 line
2.2.1
PATCH 5/15 arm: don't use module_init in non-modular mach-vexpress/spc.c code
In reply to Paul GortmakerThe spc.o is built for ARCH_VEXPRESS_SPC -- which is bool, and hence this code is either present or absent. It will never be modular, so using module_init as an alias for __initcall can be somewhat misleading.
Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.
Note that direct use of __initcall is discouraged, vs. one of the priority categorized subgroups. As __initcall gets mapped onto device_initcall, our use of device_initcall directly in this change means that the runtime impact is zero -- it will remain at level 6 in initcall ordering.
--- arch/arm/mach-vexpress/spc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-vexpress/spc.c +1 -1
@@ -589,4 +589,4 @@ static int __init ve_spc_clk_init(void)platform_device_register_simple ("vexpress-spc-cpufreq" ,-1 ,NULL ,0 );return 0 ; } -module_init (ve_spc_clk_init); +device_initcall (ve_spc_clk_init);
Signature · 1 line
2.2.1
PATCH 6/15 alpha: don't use module_init for non-modular core code
In reply to Paul GortmakerThe srm console is always built in. It will never be modular, so using module_init as an alias for __initcall is rather misleading.
Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.
Direct use of __initcall is discouraged, vs prioritized ones. Use of device_initcall is consistent with what __initcall maps onto, and hence does not change the init order, making the
impact of this change zero. Should someone with real hardware
for boot testing want to change it later to arch_initcall or console_initcall, they can do that at a later date.
--- arch/alpha/kernel/srmcons.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/alpha/kernel/srmcons.c +1 -2
@@ -237,8 +237,7 @@ srmcons_init(void)return -ENODEV ; } - -module_init (srmcons_init); +device_initcall (srmcons_init);/*
Signature · 1 line
2.2.1
Matt Turner
maintainerRe: [PATCH 06/15] alpha: don't use module_init for non-modular core code
Quoted 16 lines · Paul Gortmaker
The srm console is always built in. It will never be modular, so using
module_initas an alias for__initcallis rather misleading.Fix this up now, so that we can relocate
module_initfrominit.hintomodule.hin the future. If we don't do this, we'd have to addmodule.hto obviously non-modular code, and that would be a worse thing.Direct use of
__initcallis discouraged, vs prioritized ones. Use ofdevice_initcallis consistent with what__initcallmaps onto, and hence does not change the init order, making the
impact of this change zero. Should someone with real hardware
for boot testing want to change it later toarch_initcallorconsole_initcall, they can do that at a later date.
Quoted 7 lines
Cc Richard Henderson <[email protected]>Reviewed-by Richard Henderson <[email protected]>Cc Ivan Kokshaysky <[email protected]>Cc Matt Turner <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>---
I included this in my pull request to Linus that went upstream yesterday. Thanks!
Re: [PATCH 06/15] alpha: don't use module_init for non-modular core code
Quoted 26 lines · Matt Turner
Quoted 16 lines · Paul Gortmaker
The srm console is always built in. It will never be modular, so using
module_initas an alias for__initcallis rather misleading.Fix this up now, so that we can relocate
module_initfrominit.hintomodule.hin the future. If we don't do this, we'd have to addmodule.hto obviously non-modular code, and that would be a worse thing.Direct use of
__initcallis discouraged, vs prioritized ones. Use ofdevice_initcallis consistent with what__initcallmaps onto, and hence does not change the init order, making the
impact of this change zero. Should someone with real hardware
for boot testing want to change it later toarch_initcallorconsole_initcall, they can do that at a later date.Quoted 7 lines
Cc Richard Henderson <[email protected]>Reviewed-by Richard Henderson <[email protected]>Cc Ivan Kokshaysky <[email protected]>Cc Matt Turner <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>---
Quoted 2 lines
I included this in my pull request to Linus that went upstream yesterday. Thanks!
OK, thanks - I'll drop it from here if/when I rebase onto the 4.1-rc6 pending on Sunday. If I drop it now I'll risk introducing a bisect failure for alpha, since my current baseline of 4.1-rc5 doesn't have this now-upstream change from the old original series.
Paul.
--
Quoted 1 line
PATCH 7/15 ia64: don't use module_init for non-modular core kernel/mca.c code
In reply to Paul GortmakerThe mca.c code is always built in. It will never be modular, so using module_init as an alias for __initcall is rather misleading.
Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.
Direct use of __initcall is discouraged, vs prioritized ones. Use of device_initcall is consistent with what __initcall maps onto, and hence does not change the init order, making the
impact of this change zero. Should someone with real hardware
for boot testing want to change it later to arch_initcall or something different, they can do that at a later date.
--- arch/ia64/sn/kernel/mca.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/ia64/sn/kernel/mca.c +1 -2
@@ -142,5 +142,4 @@ static int __init sn_salinfo_init(void) salinfo_platform_oemdata = &sn_salinfo_platform_oemdata;return 0 ; } - -module_init (sn_salinfo_init) +device_initcall (sn_salinfo_init);
Signature · 1 line
2.2.1
PATCH 8/15 ia64: don't use module_init in non-modular sim/simscsi.c code
In reply to Paul GortmakerThe simscsi.o is built for HP_SIMSCSI -- which is bool, and hence this code is either present or absent. It will never be modular, so using module_init as an alias for __initcall can be somewhat misleading.
Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.
Note that direct use of __initcall is discouraged, vs. one of the priority categorized subgroups. As __initcall gets mapped onto device_initcall, our use of device_initcall directly in this change means that the runtime impact is zero -- it will remain at level 6 in initcall ordering.
And since it can't be modular, we remove all the __exitcall stuff related to module_exit() -- it is dead code that won't ever be executed.
--- arch/ia64/hp/sim/simscsi.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
arch/ia64/hp/sim/simscsi.c +1 -10
@@ -368,13 +368,4 @@ simscsi_init(void)scsi_host_put (host);return error; } - -static void __exit -simscsi_exit (void ) -{ -scsi_remove_host (host); -scsi_host_put (host); -} - -module_init (simscsi_init); -module_exit (simscsi_exit); +device_initcall (simscsi_init);
Signature · 1 line
2.2.1
PATCH 9/15 cris: don't use module_init for non-modular core intmem.c code
In reply to Paul GortmakerThe intmem.c code is always built in. It will never be modular, so using module_init as an alias for __initcall is rather misleading.
Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.
Direct use of __initcall is discouraged, vs prioritized ones. Use of device_initcall is consistent with what __initcall maps onto, and hence does not change the init order, making the
impact of this change zero. Should someone with real hardware
for boot testing want to change it later to arch_initcall or something different, they can do that at a later date.
--- arch/cris/arch-v32/mm/intmem.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/cris/arch-v32/mm/intmem.c +1 -2
@@ -145,6 +145,5 @@ unsigned long crisv32_intmem_virt_to_phys(void* addr) (unsigned long )intmem_virtual +MEM_INTMEM_START + RESERVED_SIZE); } - -module_init (crisv32_intmem_init); +device_initcall (crisv32_intmem_init);
Signature · 1 line
2.2.1
PATCH 10/15 parisc: don't use module_init for non-modular core pdc_cons code
In reply to Paul GortmakerThe pdc_cons.c code is always built in. It will never be modular, so using module_init as an alias for __initcall is rather misleading.
Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.
Direct use of __initcall is discouraged, vs prioritized ones. Use of device_initcall is consistent with what __initcall maps onto, and hence does not change the init order, making the
impact of this change zero. Should someone with real hardware
for boot testing want to change it later to arch_initcall or something different, they can do that at a later date.
--- arch/parisc/kernel/pdc_cons.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/parisc/kernel/pdc_cons.c +1 -2
@@ -207,8 +207,7 @@ static int __init pdc_console_tty_driver_init(void)return 0 ; } - -module_init (pdc_console_tty_driver_init); +device_initcall (pdc_console_tty_driver_init);static struct tty_driver *pdc_console_device (struct console *c,int *index) {
Signature · 1 line
2.2.1
PATCH 11/15 parisc64: don't use module_init for non-modular core perf code
In reply to Paul GortmakerThe perf.c code depends on CONFIG_64BIT, so it is either built-in or absent. It will never be modular, so using module_init as an alias for __initcall is rather misleading.
Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing. Aside from it not making sense, it also causes a ~10% increase in CPP overhead due to module.h having a large list of headers itself -- for example compare line counts:
device_initcall() and <linux/init.h>
20238 arch/parisc/kernel/perf.i
module_init() and <linux/module.h>
22194 arch/parisc/kernel/perf.i
Direct use of __initcall is discouraged, vs prioritized ones. Use of device_initcall is consistent with what __initcall maps onto, and hence does not change the init order, making the
impact of this change zero. Should someone with real hardware
for boot testing want to change it later to arch_initcall or something different, they can do that at a later date.
--- arch/parisc/kernel/perf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/parisc/kernel/perf.c +1 -2
@@ -543,6 +543,7 @@ static int __init perf_init(void)return 0 ; } +device_initcall (perf_init);/* * perf_start_counters(void)
@@ -847,5 +848,3 @@ printk("perf_rdr_write\n"); }printk ("perf_rdr_write done\n" ); } - -module_init (perf_init);
Signature · 1 line
2.2.1
PATCH 12/15 mn10300: don't use module_init in non-modular flash.c code
In reply to Paul GortmakerThe flash.o is built for obj-y -- and hence this code is always present. It will never be modular, so using module_init as an alias for __initcall can be somewhat misleading.
Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.
Note that direct use of __initcall is discouraged, vs. one of the priority categorized subgroups. As __initcall gets mapped onto device_initcall, our use of device_initcall directly in this change means that the runtime impact is zero -- it will remain at level 6 in initcall ordering.
--- arch/mn10300/unit-asb2303/flash.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/mn10300/unit-asb2303/flash.c +1 -2
@@ -96,5 +96,4 @@ static int __init asb2303_mtd_init(void)platform_device_register (&asb2303_sysflash);return 0 ; } - -module_init (asb2303_mtd_init); +device_initcall (asb2303_mtd_init);
Signature · 1 line
2.2.1
PATCH 13/15 sh: don't use module_init in non-modular psw.c code
In reply to Paul GortmakerThe psw.o is built for obj-y -- and hence this code is always present. It will never be modular, so using module_init as an alias for __initcall can be somewhat misleading.
Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.
Note that direct use of __initcall is discouraged, vs. one of the priority categorized subgroups. As __initcall gets mapped onto device_initcall, our use of device_initcall directly in this change means that the runtime impact is zero -- it will remain at level 6 in initcall ordering.
--- arch/sh/boards/mach-landisk/psw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/boards/mach-landisk/psw.c +1 -1
@@ -140,4 +140,4 @@ static int __init psw_init(void) {return platform_add_devices (psw_devices,ARRAY_SIZE (psw_devices)); } -module_init (psw_init); +device_initcall (psw_init);
Signature · 1 line
2.2.1
PATCH 14/15 xtensa: don't use module_init for non-modular core network.c code
In reply to Paul GortmakerThe network.c code is piggybacking off of the arch independent CONFIG_NET, which is bool. So the code is either built in or absent. It will never be modular, so using module_init as an alias for __initcall is rather misleading.
Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.
Direct use of __initcall is discouraged, vs prioritized ones. Use of device_initcall is consistent with what __initcall maps onto, and hence does not change the init order, making the
impact of this change zero. Should someone with real hardware
for boot testing want to change it later to arch_initcall or something different, they can do that at a later date.
--- arch/xtensa/platforms/iss/network.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/xtensa/platforms/iss/network.c +1 -3
@@ -681,6 +681,4 @@ static int iss_net_init(void)return 1 ; } - -module_init (iss_net_init); - +device_initcall (iss_net_init);
Signature · 1 line
2.2.1
PATCH 15/15 drivers/clk: don't use module_init in clk-nomadik.c which is non-modular
In reply to Paul GortmakerThe clk-nomadik.o is built for ARCH_NOMADIK -- which is bool, and hence this code is either present or absent. It will never be modular, so using module_init as an alias for __initcall can be somewhat misleading.
Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.
Note that direct use of __initcall is discouraged, vs. one of the priority categorized subgroups. As __initcall gets mapped onto device_initcall, our use of device_initcall directly in this change means that the runtime impact is zero -- it will remain at level 6 in initcall ordering.
--- drivers/clk/clk-nomadik.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/clk/clk-nomadik.c +1 -2
@@ -503,8 +503,7 @@ static int __init nomadik_src_clk_init_debugfs(void) NULL, NULL, &nomadik_src_clk_debugfs_ops); return 0; } - -module_init (nomadik_src_clk_init_debugfs); +device_initcall (nomadik_src_clk_init_debugfs);#endif
Signature · 1 line
2.2.1