linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] s390: remove modular usage from non-modular code
@ 2016-10-30 20:37 Paul Gortmaker
  2016-10-30 20:37 ` [PATCH 1/9] s390: cio: make it explicitly non-modular Paul Gortmaker
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Paul Gortmaker @ 2016-10-30 20:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, Arnd Bergmann, Bjorn Helgaas,
	Christian Borntraeger, Cornelia Huck, Gerald Schaefer,
	Heiko Carstens, linux-s390, Martin Schwidefsky,
	Peter Oberparleiter, Sebastian Ott

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.

---

Cc: Arnd Bergmann <arndb@de.ibm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux-s390@vger.kernel.org
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Cc: Sebastian Ott <sebott@linux.vnet.ibm.com>

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

-- 
2.10.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/9] s390: cio: make it explicitly non-modular
  2016-10-30 20:37 [PATCH 0/9] s390: remove modular usage from non-modular code Paul Gortmaker
@ 2016-10-30 20:37 ` Paul Gortmaker
  2016-10-30 20:37 ` [PATCH 2/9] s390: char: make zcore " Paul Gortmaker
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Paul Gortmaker @ 2016-10-30 20:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, Sebastian Ott, Peter Oberparleiter,
	Martin Schwidefsky, Heiko Carstens, Cornelia Huck, Arnd Bergmann,
	linux-s390

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.

Cc: Sebastian Ott <sebott@linux.vnet.ibm.com>
Cc: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Arnd Bergmann <arndb@de.ibm.com>
Cc: linux-s390@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 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(-)

diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index 268aa23afa01..6b6386e9a500 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -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 <arndb@de.ibm.com>");
-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);
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 3d2b20ee613f..bc099b61394d 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -5,12 +5,14 @@
  *
  * Author(s): Arnd Bergmann (arndb@de.ibm.com)
  *	      Cornelia Huck (cornelia.huck@de.ibm.com)
+ *
+ * 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");
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 6a58bc8f46e2..79823ee9c100 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -5,12 +5,14 @@
  *    Author(s): Arnd Bergmann (arndb@de.ibm.com)
  *		 Cornelia Huck (cornelia.huck@de.ibm.com)
  *		 Martin Schwidefsky (schwidefsky@de.ibm.com)
+ *
+ * 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);
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index 877d9f601e63..cf8c4ac6323a 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -3,8 +3,10 @@
  *
  * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
  *	      Cornelia Huck (cornelia.huck@de.ibm.com)
+ *
+ * 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);
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/9] s390: char: make zcore explicitly non-modular
  2016-10-30 20:37 [PATCH 0/9] s390: remove modular usage from non-modular code Paul Gortmaker
  2016-10-30 20:37 ` [PATCH 1/9] s390: cio: make it explicitly non-modular Paul Gortmaker
@ 2016-10-30 20:37 ` Paul Gortmaker
  2016-10-30 20:37 ` [PATCH 3/9] s390: char: make con3215 " Paul Gortmaker
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Paul Gortmaker @ 2016-10-30 20:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, Martin Schwidefsky, Heiko Carstens, linux-s390

The Kconfig currently controlling compilation of this code is:

arch/s390/Kconfig:config CRASH_DUMP
arch/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.

Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux-s390@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/s390/char/zcore.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/s390/char/zcore.c b/drivers/s390/char/zcore.c
index 16992e2a40ad..5aea89a92ff4 100644
--- a/drivers/s390/char/zcore.c
+++ b/drivers/s390/char/zcore.c
@@ -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);
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/9] s390: char: make con3215 explicitly non-modular
  2016-10-30 20:37 [PATCH 0/9] s390: remove modular usage from non-modular code Paul Gortmaker
  2016-10-30 20:37 ` [PATCH 1/9] s390: cio: make it explicitly non-modular Paul Gortmaker
  2016-10-30 20:37 ` [PATCH 2/9] s390: char: make zcore " Paul Gortmaker
@ 2016-10-30 20:37 ` Paul Gortmaker
  2016-10-30 20:37 ` [PATCH 4/9] s390: char: make sclp_tty " Paul Gortmaker
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Paul Gortmaker @ 2016-10-30 20:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, Martin Schwidefsky, Heiko Carstens, linux-s390

The Kconfig currently controlling compilation of this code is:

drivers/s390/char/Kconfig:config TN3215
drivers/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.

Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux-s390@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/s390/char/con3215.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index 931d10e86837..1b8d825623bd 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -9,7 +9,6 @@
  *	      Dan Morrison, IBM Corporation <dmorriso@cse.buffalo.edu>
  */
 
-#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);
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/9] s390: char: make sclp_tty explicitly non-modular
  2016-10-30 20:37 [PATCH 0/9] s390: remove modular usage from non-modular code Paul Gortmaker
                   ` (2 preceding siblings ...)
  2016-10-30 20:37 ` [PATCH 3/9] s390: char: make con3215 " Paul Gortmaker
@ 2016-10-30 20:37 ` Paul Gortmaker
  2016-10-30 20:37 ` [PATCH 5/9] s390: char: make slcp_quiesce " Paul Gortmaker
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Paul Gortmaker @ 2016-10-30 20:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, Martin Schwidefsky, Heiko Carstens,
	Peter Oberparleiter, linux-s390

The Kconfig currently controlling compilation of this code is:

drivers/s390/char/Kconfig:config SCLP_TTY
drivers/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.

Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Cc: linux-s390@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/s390/char/sclp_tty.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
index 3c6e174e19b6..9259017a1295 100644
--- a/drivers/s390/char/sclp_tty.c
+++ b/drivers/s390/char/sclp_tty.c
@@ -7,7 +7,6 @@
  *		 Martin Schwidefsky <schwidefsky@de.ibm.com>
  */
 
-#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);
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/9] s390: char: make slcp_quiesce explicitly non-modular
  2016-10-30 20:37 [PATCH 0/9] s390: remove modular usage from non-modular code Paul Gortmaker
                   ` (3 preceding siblings ...)
  2016-10-30 20:37 ` [PATCH 4/9] s390: char: make sclp_tty " Paul Gortmaker
@ 2016-10-30 20:37 ` Paul Gortmaker
  2016-10-30 20:37 ` [PATCH 6/9] s390: hotplug: make pci_hpc " Paul Gortmaker
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Paul Gortmaker @ 2016-10-30 20:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, Martin Schwidefsky, Heiko Carstens, linux-s390

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

Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux-s390@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/s390/char/sclp_quiesce.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/s390/char/sclp_quiesce.c b/drivers/s390/char/sclp_quiesce.c
index 475e470d9768..e4958511168a 100644
--- a/drivers/s390/char/sclp_quiesce.c
+++ b/drivers/s390/char/sclp_quiesce.c
@@ -6,7 +6,6 @@
  *             Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
  */
 
-#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);
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/9] s390: hotplug: make pci_hpc explicitly non-modular
  2016-10-30 20:37 [PATCH 0/9] s390: remove modular usage from non-modular code Paul Gortmaker
                   ` (4 preceding siblings ...)
  2016-10-30 20:37 ` [PATCH 5/9] s390: char: make slcp_quiesce " Paul Gortmaker
@ 2016-10-30 20:37 ` Paul Gortmaker
  2016-10-30 20:37 ` [PATCH 7/9] s390: hypfs: make inode " Paul Gortmaker
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Paul Gortmaker @ 2016-10-30 20:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, Sebastian Ott, Gerald Schaefer, Bjorn Helgaas,
	linux-s390

The Kconfig currently controlling compilation of this code is:

drivers/pci/hotplug/Kconfig:config HOTPLUG_PCI_S390
drivers/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.

Cc: Sebastian Ott <sebott@linux.vnet.ibm.com>
Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-s390@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/pci/hotplug/s390_pci_hpc.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/hotplug/s390_pci_hpc.c b/drivers/pci/hotplug/s390_pci_hpc.c
index 50b8b7d54416..530d0e49f2ed 100644
--- a/drivers/pci/hotplug/s390_pci_hpc.c
+++ b/drivers/pci/hotplug/s390_pci_hpc.c
@@ -5,12 +5,13 @@
  *
  * Author(s):
  *   Jan Glauber <jang@linux.vnet.ibm.com>
+ *
+ * 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	10
 static LIST_HEAD(s390_hotplug_slot_list);
 
-MODULE_AUTHOR("Jan Glauber <jang@linux.vnet.ibm.com");
-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 ||
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 7/9] s390: hypfs: make inode explicitly non-modular
  2016-10-30 20:37 [PATCH 0/9] s390: remove modular usage from non-modular code Paul Gortmaker
                   ` (5 preceding siblings ...)
  2016-10-30 20:37 ` [PATCH 6/9] s390: hotplug: make pci_hpc " Paul Gortmaker
@ 2016-10-30 20:37 ` Paul Gortmaker
  2016-10-30 20:37 ` [PATCH 8/9] s390: kernel: make lgr " Paul Gortmaker
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Paul Gortmaker @ 2016-10-30 20:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, Martin Schwidefsky, Heiko Carstens, linux-s390

The Kconfig currently controlling compilation of this code is:

arch/s390/Kconfig:config S390_HYPFS_FS
arch/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.

Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux-s390@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 arch/s390/hypfs/inode.c | 24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index 09bccb224d03..cf8a2d92467f 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -3,6 +3,7 @@
  *
  *    Copyright IBM Corp. 2006, 2008
  *    Author(s): Michael Holzheu <holzheu@de.ibm.com>
+ *    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 <holzheu@de.ibm.com>");
-MODULE_DESCRIPTION("s390 Hypervisor Filesystem");
+device_initcall(hypfs_init)
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 8/9] s390: kernel: make lgr explicitly non-modular
  2016-10-30 20:37 [PATCH 0/9] s390: remove modular usage from non-modular code Paul Gortmaker
                   ` (6 preceding siblings ...)
  2016-10-30 20:37 ` [PATCH 7/9] s390: hypfs: make inode " Paul Gortmaker
@ 2016-10-30 20:37 ` Paul Gortmaker
  2016-10-30 20:37 ` [PATCH 9/9] s390: virtio: make ccw " Paul Gortmaker
  2016-10-31  9:24 ` [PATCH 0/9] s390: remove modular usage from non-modular code Heiko Carstens
  9 siblings, 0 replies; 12+ messages in thread
From: Paul Gortmaker @ 2016-10-30 20:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, Martin Schwidefsky, Heiko Carstens, linux-s390

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

Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux-s390@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 arch/s390/kernel/lgr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/s390/kernel/lgr.c b/arch/s390/kernel/lgr.c
index 6ea6d69339b5..ae7dff110054 100644
--- a/arch/s390/kernel/lgr.c
+++ b/arch/s390/kernel/lgr.c
@@ -5,7 +5,8 @@
  * Author(s): Michael Holzheu <holzheu@linux.vnet.ibm.com>
  */
 
-#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);
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 9/9] s390: virtio: make ccw explicitly non-modular
  2016-10-30 20:37 [PATCH 0/9] s390: remove modular usage from non-modular code Paul Gortmaker
                   ` (7 preceding siblings ...)
  2016-10-30 20:37 ` [PATCH 8/9] s390: kernel: make lgr " Paul Gortmaker
@ 2016-10-30 20:37 ` Paul Gortmaker
  2016-10-31 10:56   ` Cornelia Huck
  2016-10-31  9:24 ` [PATCH 0/9] s390: remove modular usage from non-modular code Heiko Carstens
  9 siblings, 1 reply; 12+ messages in thread
From: Paul Gortmaker @ 2016-10-30 20:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul Gortmaker, Christian Borntraeger, Cornelia Huck,
	Martin Schwidefsky, Heiko Carstens, linux-s390

The Kconfig currently controlling compilation of this code is:

arch/s390/Kconfig:config S390_GUEST
arch/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.

Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux-s390@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 drivers/s390/virtio/virtio_ccw.c | 25 ++-----------------------
 1 file changed, 2 insertions(+), 23 deletions(-)

diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c
index 8688ad4c825f..639ed4e6afd1 100644
--- a/drivers/s390/virtio/virtio_ccw.c
+++ b/drivers/s390/virtio/virtio_ccw.c
@@ -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);
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/9] s390: remove modular usage from non-modular code
  2016-10-30 20:37 [PATCH 0/9] s390: remove modular usage from non-modular code Paul Gortmaker
                   ` (8 preceding siblings ...)
  2016-10-30 20:37 ` [PATCH 9/9] s390: virtio: make ccw " Paul Gortmaker
@ 2016-10-31  9:24 ` Heiko Carstens
  9 siblings, 0 replies; 12+ messages in thread
From: Heiko Carstens @ 2016-10-31  9:24 UTC (permalink / raw)
  To: Paul Gortmaker
  Cc: linux-kernel, Arnd Bergmann, Bjorn Helgaas,
	Christian Borntraeger, Cornelia Huck, Gerald Schaefer,
	linux-s390, Martin Schwidefsky, Peter Oberparleiter,
	Sebastian Ott

On Sun, Oct 30, 2016 at 04:37:23PM -0400, Paul Gortmaker wrote:
> 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

Whole series applied. Thanks!

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 9/9] s390: virtio: make ccw explicitly non-modular
  2016-10-30 20:37 ` [PATCH 9/9] s390: virtio: make ccw " Paul Gortmaker
@ 2016-10-31 10:56   ` Cornelia Huck
  0 siblings, 0 replies; 12+ messages in thread
From: Cornelia Huck @ 2016-10-31 10:56 UTC (permalink / raw)
  To: Paul Gortmaker
  Cc: linux-kernel, Christian Borntraeger, Martin Schwidefsky,
	Heiko Carstens, linux-s390

On Sun, 30 Oct 2016 16:37:32 -0400
Paul Gortmaker <paul.gortmaker@windriver.com> wrote:

> The Kconfig currently controlling compilation of this code is:
> 
> arch/s390/Kconfig:config S390_GUEST
> arch/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.
> 
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> Cc: linux-s390@vger.kernel.org
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
> ---
>  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

Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>

[going through the s390 tree with the other patches is probably easier
as taking this through the virtio tree]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-10-31 10:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-30 20:37 [PATCH 0/9] s390: remove modular usage from non-modular code Paul Gortmaker
2016-10-30 20:37 ` [PATCH 1/9] s390: cio: make it explicitly non-modular Paul Gortmaker
2016-10-30 20:37 ` [PATCH 2/9] s390: char: make zcore " Paul Gortmaker
2016-10-30 20:37 ` [PATCH 3/9] s390: char: make con3215 " Paul Gortmaker
2016-10-30 20:37 ` [PATCH 4/9] s390: char: make sclp_tty " Paul Gortmaker
2016-10-30 20:37 ` [PATCH 5/9] s390: char: make slcp_quiesce " Paul Gortmaker
2016-10-30 20:37 ` [PATCH 6/9] s390: hotplug: make pci_hpc " Paul Gortmaker
2016-10-30 20:37 ` [PATCH 7/9] s390: hypfs: make inode " Paul Gortmaker
2016-10-30 20:37 ` [PATCH 8/9] s390: kernel: make lgr " Paul Gortmaker
2016-10-30 20:37 ` [PATCH 9/9] s390: virtio: make ccw " Paul Gortmaker
2016-10-31 10:56   ` Cornelia Huck
2016-10-31  9:24 ` [PATCH 0/9] s390: remove modular usage from non-modular code Heiko Carstens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).