s390: remove modular usage from non-modular code
Subsystems (5)
cover s390: remove modular usage from non-modular code
My ongoing audit looking for non-modular code that needlessly uses modular macros (vs. built-in equivalents) and/or has dead code relating to module unloading that can never be executed led to the creation of these s390 related commits.
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.
Build tested on current linux-next (allyes/allno/allmod) to ensure no silly typos or implicit include issues that would break compilation crept in.
---
Paul Gortmaker (9):
s390: cio: make it explicitly non-modular
s390: char: make zcore explicitly non-modular
s390: char: make con3215 explicitly non-modular
s390: char: make sclp_tty explicitly non-modular
s390: char: make slcp_quiesce explicitly non-modular
s390: hotplug: make pci_hpc explicitly non-modular
s390: hypfs: make inode explicitly non-modular
s390: kernel: make lgr explicitly non-modular
s390: virtio: make ccw explicitly non-modular
arch/s390/hypfs/inode.c | 24 ++++-------------------- arch/s390/kernel/lgr.c | 5 +++-- drivers/pci/hotplug/s390_pci_hpc.c | 7 ++----- drivers/s390/char/con3215.c | 12 +----------- drivers/s390/char/sclp_quiesce.c | 4 +--- drivers/s390/char/sclp_tty.c | 3 +-- drivers/s390/char/zcore.c | 20 +------------------- drivers/s390/cio/cmf.c | 10 ++-------- drivers/s390/cio/css.c | 6 +++--- drivers/s390/cio/device.c | 6 +++--- drivers/s390/cio/device_ops.c | 5 +++-- drivers/s390/virtio/virtio_ccw.c | 25 ++----------------------- 12 files changed, 26 insertions(+), 101 deletions(-)
Signature · 1 line
2.10.1
PATCH 1/9 s390: cio: make it explicitly non-modular
The Makefile currently controlling compilation of this code is:
obj-y += airq.o blacklist.o chsc.o cio.o css.o chp.o idset.o isc.o \
fcx.o itcw.o crw.o ccwreq.o trace.o ioasm.o
ccw_device-objs += device.o device_fsm.o device_ops.o
ccw_device-objs += device_id.o device_pgid.o device_status.o
obj-y += ccw_device.o cmf.o...meaning that the files here are not being built as modular.
Lets remove the couple traces of modular infrastructure use, so that when reading the code 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.
Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.
We 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 replace module.h with export.h where the file does export some symbols.
--- drivers/s390/cio/cmf.c | 10 ++-------- drivers/s390/cio/css.c | 6 +++--- drivers/s390/cio/device.c | 6 +++--- drivers/s390/cio/device_ops.c | 5 +++-- 4 files changed, 11 insertions(+), 16 deletions(-)
drivers/s390/cio/cmf.c +2 -8
@@ -30,7 +30,7 @@#include <linux/device.h> #include <linux/init.h> #include <linux/list.h> -#include <linux/module.h> +#include <linux/export.h> #include <linux/moduleparam.h> #include <linux/slab.h> #include <linux/timex.h> /* get_tod_clock() */
@@ -1389,13 +1389,7 @@ static int __init init_cmf(void) "%s (mode %s)\n", format_string, detect_string);return 0 ; } -module_init (init_cmf); - - -MODULE_AUTHOR ("Arnd Bergmann <[email protected]>" ); -MODULE_LICENSE ("GPL" ); -MODULE_DESCRIPTION ("channel measurement facility base driver\n" -"Copyright IBM Corp. 2003\n" ); +device_initcall (init_cmf);EXPORT_SYMBOL_GPL (enable_cmf);EXPORT_SYMBOL_GPL (disable_cmf);
drivers/s390/cio/css.c +3 -3
@@ -5,12 +5,14 @@* * Author(s): Arnd Bergmann ([email protected]) * Cornelia Huck ([email protected]) +* +* License: GPL */ #define KMSG_COMPONENT "cio"#define pr_fmt (fmt) KMSG_COMPONENT ": " fmt -#include <linux/module.h> +#include <linux/export.h> #include <linux/init.h> #include <linux/device.h> #include <linux/slab.h>
@@ -1285,5 +1287,3 @@ void css_driver_unregister(struct css_driver *cdrv)driver_unregister (&cdrv->drv); }EXPORT_SYMBOL_GPL (css_driver_unregister); - -MODULE_LICENSE ("GPL" );
drivers/s390/cio/device.c +3 -3
@@ -5,12 +5,14 @@* Author(s): Arnd Bergmann ([email protected]) * Cornelia Huck ([email protected]) * Martin Schwidefsky ([email protected]) +* +* License: GPL */ #define KMSG_COMPONENT "cio"#define pr_fmt (fmt) KMSG_COMPONENT ": " fmt -#include <linux/module.h> +#include <linux/export.h> #include <linux/init.h> #include <linux/spinlock.h> #include <linux/errno.h>
@@ -145,7 +147,6 @@ static struct css_device_id io_subchannel_ids[] = { { .match_flags = 0x1, .type = SUBCHANNEL_TYPE_IO, }, { /* end of list */ }, }; -MODULE_DEVICE_TABLE (css, io_subchannel_ids);static int io_subchannel_prepare (struct subchannel *sch) {
@@ -2150,7 +2151,6 @@ int ccw_device_siosl(struct ccw_device *cdev) }EXPORT_SYMBOL_GPL (ccw_device_siosl); -MODULE_LICENSE ("GPL" );EXPORT_SYMBOL (ccw_device_set_online);EXPORT_SYMBOL (ccw_device_set_offline);EXPORT_SYMBOL (ccw_driver_register);
drivers/s390/cio/device_ops.c +3 -2
@@ -3,8 +3,10 @@* * Author(s): Martin Schwidefsky ([email protected]) * Cornelia Huck ([email protected]) +* +* License: GPL */ -#include <linux/module.h> +#include <linux/export.h> #include <linux/init.h> #include <linux/errno.h> #include <linux/slab.h>
@@ -676,7 +678,6 @@ void ccw_device_get_schid(struct ccw_device *cdev, struct subchannel_id *schid) }EXPORT_SYMBOL_GPL (ccw_device_get_schid); -MODULE_LICENSE ("GPL" );EXPORT_SYMBOL (ccw_device_set_options_mask);EXPORT_SYMBOL (ccw_device_set_options);EXPORT_SYMBOL (ccw_device_clear_options);
Signature · 1 line
2.10.1
PATCH 2/9 s390: char: make zcore explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
arch/s390/Kconfig:config CRASH_DUMParch/s390/Kconfig: bool "kernel crash dumps"
...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 wasn't even being used by this file, 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.
We don't replace module.h with init.h since the file already has that.
--- drivers/s390/char/zcore.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)
drivers/s390/char/zcore.c +1 -19
@@ -7,6 +7,7 @@* * Copyright IBM Corp. 2003, 2008 * Author(s): Michael Holzheu +* License: GPL */ #define KMSG_COMPONENT "zdump"
@@ -16,7 +17,6 @@#include <linux/slab.h> #include <linux/miscdevice.h> #include <linux/debugfs.h> -#include <linux/module.h> #include <linux/memblock.h> #include <asm/asm-offsets.h>
@@ -364,22 +364,4 @@ static int __init zcore_init(void)diag308 (DIAG308_REL_HSA ,NULL );return rc; } - -static void __exit zcore_exit(void) -{ -debug_unregister (zcore_dbf); -sclp_sdias_exit (); -free_page ((unsigned long ) ipl_block); -debugfs_remove (zcore_hsa_file); -debugfs_remove (zcore_reipl_file); -debugfs_remove (zcore_memmap_file); -debugfs_remove (zcore_dir); -diag308 (DIAG308_REL_HSA ,NULL ); -} - -MODULE_AUTHOR ("Copyright IBM Corp. 2003,2008" ); -MODULE_DESCRIPTION ("zcore module for zfcpdump support" ); -MODULE_LICENSE ("GPL" ); -subsys_initcall (zcore_init); -module_exit (zcore_exit);
Signature · 1 line
2.10.1
PATCH 3/9 s390: char: make con3215 explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/s390/char/Kconfig:config TN3215drivers/s390/char/Kconfig: def_bool 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.
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.
--- drivers/s390/char/con3215.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/s390/char/con3215.c +1 -11
@@ -9,7 +9,6 @@* Dan Morrison, IBM Corporation <[email protected]> */ -#include <linux/module.h> #include <linux/types.h> #include <linux/kdev_t.h> #include <linux/tty.h>
@@ -1215,13 +1214,4 @@ static int __init tty3215_init(void) tty3215_driver = driver;return 0 ; } - -static void __exit tty3215_exit(void) -{ -tty_unregister_driver (tty3215_driver); -put_tty_driver (tty3215_driver); -ccw_driver_unregister (&raw3215_ccw_driver); -} - -module_init (tty3215_init); -module_exit (tty3215_exit); +device_initcall (tty3215_init);
Signature · 1 line
2.10.1
PATCH 4/9 s390: char: make sclp_tty explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/s390/char/Kconfig:config SCLP_TTYdrivers/s390/char/Kconfig: def_bool 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 don't replace module.h with init.h since the file already has that.
--- drivers/s390/char/sclp_tty.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/s390/char/sclp_tty.c +1 -2
@@ -7,7 +7,6 @@* Martin Schwidefsky <[email protected]> */ -#include <linux/module.h> #include <linux/kmod.h> #include <linux/tty.h> #include <linux/tty_driver.h>
@@ -573,4 +572,4 @@ sclp_tty_init(void) sclp_tty_driver = driver;return 0 ; } -module_init (sclp_tty_init); +device_initcall (sclp_tty_init);
Signature · 1 line
2.10.1
PATCH 5/9 s390: char: make slcp_quiesce explicitly non-modular
In reply to Paul GortmakerThe Makefile currently 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, 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.
--- drivers/s390/char/sclp_quiesce.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/s390/char/sclp_quiesce.c +1 -3
@@ -6,7 +6,6 @@* Peter Oberparleiter <[email protected]> */ -#include <linux/module.h> #include <linux/types.h> #include <linux/cpumask.h> #include <linux/smp.h>
@@ -80,5 +79,4 @@ static int __init sclp_quiesce_init(void) {return sclp_register (&sclp_quiesce_event); } - -module_init (sclp_quiesce_init); +device_initcall (sclp_quiesce_init);
Signature · 1 line
2.10.1
PATCH 6/9 s390: hotplug: make pci_hpc explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
drivers/pci/hotplug/Kconfig:config HOTPLUG_PCI_S390drivers/pci/hotplug/Kconfig: bool "System z PCI Hotplug Support"
...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.
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 exchange module.h for init.h or export.h since the file does not contain any initcalls or EXPORT of symbols.
--- drivers/pci/hotplug/s390_pci_hpc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/pci/hotplug/s390_pci_hpc.c +2 -5
@@ -5,12 +5,13 @@* * Author(s): * Jan Glauber <[email protected]> +* +* License: GPL */ #define KMSG_COMPONENT "zpci"#define pr_fmt (fmt) KMSG_COMPONENT ": " fmt -#include <linux/module.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/pci.h>
@@ -21,10 +22,6 @@#define SLOT_NAME_SIZE 10static LIST_HEAD (s390_hotplug_slot_list); -MODULE_AUTHOR ("Jan Glauber <[email protected]" ); -MODULE_DESCRIPTION ("Hot Plug PCI Controller for System z" ); -MODULE_LICENSE ("GPL" ); -static int zpci_fn_configured (enum zpci_state state) { return state == ZPCI_FN_STATE_CONFIGURED ||
Signature · 1 line
2.10.1
PATCH 7/9 s390: hypfs: make inode explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
arch/s390/Kconfig:config S390_HYPFS_FSarch/s390/Kconfig: def_bool 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.
Also note that MODULE_ALIAS 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.
Build testing indicated the presence of module.h was masking an implicit include of kobject.h, hence the addition of that.
--- arch/s390/hypfs/inode.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-)
arch/s390/hypfs/inode.c +4 -20
@@ -3,6 +3,7 @@* * Copyright IBM Corp. 2006, 2008 * Author(s): Michael Holzheu <[email protected]> +* License: GPL */ #define KMSG_COMPONENT "hypfs"
@@ -18,7 +19,8 @@#include <linux/time.h> #include <linux/parser.h> #include <linux/sysfs.h> -#include <linux/module.h> +#include <linux/init.h> +#include <linux/kobject.h> #include <linux/seq_file.h> #include <linux/mount.h> #include <linux/uio.h>
@@ -443,7 +445,6 @@ static struct file_system_type hypfs_type = { .mount = hypfs_mount, .kill_sb = hypfs_kill_super }; -MODULE_ALIAS_FS ("s390_hypfs" );static const struct super_operations hypfs_s_ops = { .statfs = simple_statfs,
@@ -497,21 +498,4 @@ static int __init hypfs_init(void)pr_err ("Initialization of hypfs failed with rc=%i\n" , rc);return rc; } - -static void __exit hypfs_exit(void) -{ -unregister_filesystem (&hypfs_type); -sysfs_remove_mount_point (hypervisor_kobj,"s390" ); -hypfs_diag0c_exit (); -hypfs_sprp_exit (); -hypfs_vm_exit (); -hypfs_diag_exit (); -hypfs_dbfs_exit (); -} - -module_init(hypfs_init) -module_exit(hypfs_exit) - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR ("Michael Holzheu <[email protected]>" ); -MODULE_DESCRIPTION ("s390 Hypervisor Filesystem" ); +device_initcall (hypfs_init)
Signature · 1 line
2.10.1
PATCH 8/9 s390: kernel: make lgr explicitly non-modular
In reply to Paul GortmakerThe Makefile currently 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 replace module.h with init.h and export.h since the file does export some symbols.
--- arch/s390/kernel/lgr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/s390/kernel/lgr.c +3 -2
@@ -5,7 +5,8 @@* Author(s): Michael Holzheu <[email protected]> */ -#include <linux/module.h> +#include <linux/init.h> +#include <linux/export.h> #include <linux/timer.h> #include <linux/slab.h> #include <asm/facility.h>
@@ -183,4 +184,4 @@ static int __init lgr_init(void)lgr_timer_set ();return 0 ; } -module_init (lgr_init); +device_initcall (lgr_init);
Signature · 1 line
2.10.1
PATCH 9/9 s390: virtio: make ccw explicitly non-modular
In reply to Paul GortmakerThe Kconfig currently controlling compilation of this code is:
arch/s390/Kconfig:config S390_GUESTarch/s390/Kconfig: def_bool 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.
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 is a no-op for non-modular code.
We replace module.h with moduleparam.h since the file does declare some module_param() and leaving that as-is is currently the easiest way to remain compatible with existing boot arg use cases.
--- drivers/s390/virtio/virtio_ccw.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-)
drivers/s390/virtio/virtio_ccw.c +2 -23
@@ -24,7 +24,7 @@#include <linux/wait.h> #include <linux/list.h> #include <linux/bitops.h> -#include <linux/module.h> +#include <linux/moduleparam.h> #include <linux/io.h> #include <linux/kvm_para.h> #include <linux/notifier.h>
@@ -235,16 +235,6 @@ static struct airq_info *new_airq_info(void)return info; } -static void destroy_airq_info (struct airq_info *info) -{ -if (!info) -return ; - -unregister_adapter_interrupt (&info->airq); -airq_iv_release (info->aiv); -kfree (info); -} -static unsigned long get_airq_indicator (struct virtqueue *vqs[],int nvqs,u64 *first,void **airq_info) {
@@ -1294,7 +1284,6 @@ static struct ccw_device_id virtio_ids[] = { { CCW_DEVICE(0x3832, 0) }, {}, }; -MODULE_DEVICE_TABLE(ccw, virtio_ids); static struct ccw_driver virtio_ccw_driver = { .driver = {
@@ -1406,14 +1395,4 @@ static int __init virtio_ccw_init(void)no_auto_parse ();return ccw_driver_register (&virtio_ccw_driver); } -module_init (virtio_ccw_init); - -static void __exit virtio_ccw_exit(void) -{ -int i; - -ccw_driver_unregister (&virtio_ccw_driver); -for (i =0 ; i <MAX_AIRQ_AREAS ; i++) -destroy_airq_info (airq_areas[i]); -} -module_exit (virtio_ccw_exit); +device_initcall (virtio_ccw_init);
Signature · 1 line
2.10.1
Re: [PATCH 9/9] s390: virtio: make ccw explicitly non-modular
Quoted 25 lines · On Sun, 30 Oct 2016 16:37:32 -0400 Paul Gortmaker…
The
Kconfigcurrently controlling compilation of this code is:arch/s390/Kconfig:config
S390_GUESTarch/s390/Kconfig:def_booly...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_inittranslates todevice_initcallin the non-modular case, the init ordering remains unchanged with this commit.Also note that
MODULE_DEVICE_TABLEis a no-op for non-modular code.We replace
module.hwithmoduleparam.hsince the file does declare somemodule_param()and leaving that as-is is currently the easiest way to remain compatible with existing boot arg use cases.Cc Christian Borntraeger <[email protected]>Cc Cornelia Huck <[email protected]>Cc Martin Schwidefsky <[email protected]>Cc Heiko Carstens <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>
Quoted 3 lines
--- drivers/s390/virtio/virtio_ccw.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-)
There might actually be a case for making this modular, as the virtio-pci transport can be built as a module as well. But I don't think anybody really cares, and your patch is easily reverted should we want to do this later, so
[going through the s390 tree with the other patches is probably easier as taking this through the virtio tree]
Quoted 19 lines · Paul Gortmaker
My ongoing audit looking for non-modular code that needlessly uses modular macros (vs. built-in equivalents) and/or has dead code relating to module unloading that can never be executed led to the creation of these s390 related commits.
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_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 code and spreads like weeds.Build tested on current linux-next (allyes/allno/allmod) to ensure no silly typos or implicit include issues that would break compilation crept in.
Quoted 10 lines
Paul Gortmaker (9):
s390: cio: make it explicitly non-modular
s390: char: make zcore explicitly non-modular
s390: char: make con3215 explicitly non-modular
s390: char: makesclp_ttyexplicitly non-modular
s390: char: makeslcp_quiesceexplicitly non-modular
s390: hotplug: makepci_hpcexplicitly non-modular
s390: hypfs: make inode explicitly non-modular
s390: kernel: make lgr explicitly non-modular
s390: virtio: make ccw explicitly non-modular
Whole series applied. Thanks!