Skip to contentSkip to conversation

xen: avoid module usage in non-modular code

PATCH In review Paul Gortmaker 2 participants 19 messages Feb 14, 2016 – Feb 15, 2016

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

cover xen: avoid module usage in non-modular code

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.
(4) it gets copied/replicated into other code and spreads like weeds.

For the xen subsystem, there are just five commits:

First, we get rid of "include <linux/module.h>" instances that are completely unnecessary.

Then #2 and #3 and #5 are basically trivial remapping to the appropriate non-modular counterparts, meaning that there is no runtime change here either.

The fourth hypervisor commit is similar, but also has removal of some dead code associated with the module_exit function that will never be called. So the runtime should be the same, but the object file will be different (reduced in size).

Patches created on linux-next and build tested for x86-64 and ARM64 allmodconfig.

---

Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc Russell King <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc xen-devel at lists.xenproject.org

Paul Gortmaker (5):
xen: audit usages of module.h ; remove unnecessary instances drivers/xen: make [xen-]ballon explicitly non-modular drivers/xen: make xenbus_dev_[front/back]end explicitly non-modular drivers/xen: make sys-hypervisor.c explicitly non-modular drivers/xen: make platform-pci.c explicitly non-modular

 arch/arm/include/asm/xen/hypercall.h     |  2 ++
 drivers/xen/balloon.c                    |  4 ----
 drivers/xen/events/events_2l.c           |  1 -
 drivers/xen/events/events_base.c         |  2 +-
 drivers/xen/events/events_fifo.c         |  1 -
 drivers/xen/features.c                   |  2 +-
 drivers/xen/grant-table.c                |  1 -
 drivers/xen/platform-pci.c               | 16 ++++++----------
 drivers/xen/sys-hypervisor.c             | 31 ++++---------------------------
 drivers/xen/xen-balloon.c                | 14 +++-----------
 drivers/xen/xen-pciback/conf_space.c     |  2 +-
 drivers/xen/xen-pciback/pciback_ops.c    |  2 +-
 drivers/xen/xen-pciback/xenbus.c         |  2 +-
 drivers/xen/xen-selfballoon.c            |  1 -
 drivers/xen/xenbus/xenbus_dev_backend.c  | 13 ++-----------
 drivers/xen/xenbus/xenbus_dev_frontend.c | 13 ++-----------
 drivers/xen/xenbus/xenbus_xs.c           |  1 -
 drivers/xen/xenfs/xensyms.c              |  1 -
 18 files changed, 24 insertions(+), 85 deletions(-)
Signature · 1 line
2.6.1
#1 lore raw

PATCH 1/5 xen: audit usages of module.h ; remove unnecessary instances

Code that uses no modular facilities whatsoever should not be sourcing module.h at all, since that header drags in a bunch of other headers with it.

Similarly, code that is not explicitly using modular facilities like module_init() but only is declaring module_param setup variables should be using moduleparam.h and not the larger module.h file for that.

In making this change, we also uncover an implicit use of BUG() in inline fcns within arch/arm/include/asm/xen/hypercall.h so we explicitly source <linux/bug.h> for that file now.

Cc Stefano Stabellini <[email protected]>
Cc Russell King <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
Cc xen-devel at lists.xenproject.org
Cc linux-arm-kernel at lists.infradead.org
---
 arch/arm/include/asm/xen/hypercall.h  | 2 ++
 drivers/xen/events/events_2l.c        | 1 -
 drivers/xen/events/events_base.c      | 2 +-
 drivers/xen/events/events_fifo.c      | 1 -
 drivers/xen/features.c                | 2 +-
 drivers/xen/grant-table.c             | 1 -
 drivers/xen/xen-pciback/conf_space.c  | 2 +-
 drivers/xen/xen-pciback/pciback_ops.c | 2 +-
 drivers/xen/xen-pciback/xenbus.c      | 2 +-
 drivers/xen/xen-selfballoon.c         | 1 -
 drivers/xen/xenbus/xenbus_xs.c        | 1 -
 drivers/xen/xenfs/xensyms.c           | 1 -
 12 files changed, 7 insertions(+), 11 deletions(-)
arch/arm/include/asm/xen/hypercall.h +2 -0
index d769972db8cb..b6b962d70db9 100644
@@ -33,6 +33,8 @@
 #ifndef _ASM_ARM_XEN_HYPERCALL_H
 #define _ASM_ARM_XEN_HYPERCALL_H
 
+#include <linux/bug.h>
+
 #include <xen/interface/xen.h>
 #include <xen/interface/sched.h>
 #include <xen/interface/platform.h>
drivers/xen/events/events_2l.c +0 -1
index 7dd46312c180..51b488f5bfe9 100644
@@ -9,7 +9,6 @@
 #include <linux/linkage.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/module.h>
 
 #include <asm/sync_bitops.h>
 #include <asm/xen/hypercall.h>
drivers/xen/events/events_base.c +1 -1
index 524c22146429..488017a0806a 100644
@@ -26,7 +26,7 @@
 #include <linux/linkage.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/string.h>
 #include <linux/bootmem.h>
 #include <linux/slab.h>
drivers/xen/events/events_fifo.c +0 -1
index eff2b88003d9..9289a17712e2 100644
@@ -36,7 +36,6 @@
 #include <linux/linkage.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/module.h>
 #include <linux/smp.h>
 #include <linux/percpu.h>
 #include <linux/cpu.h>
drivers/xen/features.c +1 -1
index 99eda169c779..d7d34fdfc993 100644
@@ -7,7 +7,7 @@
  */
 #include <linux/types.h>
 #include <linux/cache.h>
-#include <linux/module.h>
+#include <linux/export.h>
 
 #include <asm/xen/hypercall.h>
 
drivers/xen/grant-table.c +0 -1
index effbaf91791f..bb36b1e1dbcc 100644
@@ -33,7 +33,6 @@
 
 #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt
 
-#include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
drivers/xen/xen-pciback/conf_space.c +1 -1
index 9c234209d8b5..8e67336f8ddd 100644
@@ -10,7 +10,7 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/pci.h>
 #include "pciback.h"
 #include "conf_space.h"
drivers/xen/xen-pciback/pciback_ops.c +1 -1
index 73dafdc494aa..5ad01f9c24fc 100644
@@ -6,7 +6,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/wait.h>
 #include <linux/bitops.h>
 #include <xen/events.h>
drivers/xen/xen-pciback/xenbus.c +1 -1
index 4843741e703a..c252eb3f0176 100644
@@ -6,7 +6,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/vmalloc.h>
drivers/xen/xen-selfballoon.c +0 -1
index 3b2bffde534f..53a085fca00c 100644
@@ -71,7 +71,6 @@
 #include <linux/swap.h>
 #include <linux/mm.h>
 #include <linux/mman.h>
-#include <linux/module.h>
 #include <linux/workqueue.h>
 #include <linux/device.h>
 #include <xen/balloon.h>
drivers/xen/xenbus/xenbus_xs.c +0 -1
index ba804f3d8278..374b12af8812 100644
@@ -44,7 +44,6 @@
 #include <linux/fcntl.h>
 #include <linux/kthread.h>
 #include <linux/rwsem.h>
-#include <linux/module.h>
 #include <linux/mutex.h>
 #include <asm/xen/hypervisor.h>
 #include <xen/xenbus.h>
drivers/xen/xenfs/xensyms.c +0 -1
index a03f261b12d8..c6e2b4a542ea 100644
@@ -1,4 +1,3 @@
-#include <linux/module.h>
 #include <linux/init.h>
 #include <linux/seq_file.h>
 #include <linux/fs.h>
Signature · 1 line
2.6.1
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] xen: audit usages of module.h ; remove unnecessary instances

Quoted 13 lines · Paul Gortmaker

Code that uses no modular facilities whatsoever should not be sourcing module.h at all, since that header drags in a bunch of other headers with it.

Similarly, code that is not explicitly using modular facilities like module_init() but only is declaring module_param setup variables should be using moduleparam.h and not the larger module.h file for that.

In making this change, we also uncover an implicit use of BUG() in inline fcns within arch/arm/include/asm/xen/hypercall.h so we explicitly source <linux/bug.h> for that file now.

Quoted 8 lines
Cc Stefano Stabellini <[email protected]>
Cc Russell King <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
Cc xen-devel at lists.xenproject.org
Cc linux-arm-kernel at lists.infradead.org
Quoted 164 lines
 arch/arm/include/asm/xen/hypercall.h  | 2 ++
 drivers/xen/events/events_2l.c        | 1 -
 drivers/xen/events/events_base.c      | 2 +-
 drivers/xen/events/events_fifo.c      | 1 -
 drivers/xen/features.c                | 2 +-
 drivers/xen/grant-table.c             | 1 -
 drivers/xen/xen-pciback/conf_space.c  | 2 +-
 drivers/xen/xen-pciback/pciback_ops.c | 2 +-
 drivers/xen/xen-pciback/xenbus.c      | 2 +-
 drivers/xen/xen-selfballoon.c         | 1 -
 drivers/xen/xenbus/xenbus_xs.c        | 1 -
 drivers/xen/xenfs/xensyms.c           | 1 -
 12 files changed, 7 insertions(+), 11 deletions(-)
arch/arm/include/asm/xen/hypercall.h +2 -0
index d769972db8cb..b6b962d70db9 100644
@@ -33,6 +33,8 @@
 #ifndef _ASM_ARM_XEN_HYPERCALL_H
 #define _ASM_ARM_XEN_HYPERCALL_H
 
+#include <linux/bug.h>
+
 #include <xen/interface/xen.h>
 #include <xen/interface/sched.h>
 #include <xen/interface/platform.h>
drivers/xen/events/events_2l.c +0 -1
index 7dd46312c180..51b488f5bfe9 100644
@@ -9,7 +9,6 @@
 #include <linux/linkage.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/module.h>
 
 #include <asm/sync_bitops.h>
 #include <asm/xen/hypercall.h>
drivers/xen/events/events_base.c +1 -1
index 524c22146429..488017a0806a 100644
@@ -26,7 +26,7 @@
 #include <linux/linkage.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/string.h>
 #include <linux/bootmem.h>
 #include <linux/slab.h>
drivers/xen/events/events_fifo.c +0 -1
index eff2b88003d9..9289a17712e2 100644
@@ -36,7 +36,6 @@
 #include <linux/linkage.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/module.h>
 #include <linux/smp.h>
 #include <linux/percpu.h>
 #include <linux/cpu.h>
drivers/xen/features.c +1 -1
index 99eda169c779..d7d34fdfc993 100644
@@ -7,7 +7,7 @@
  */
 #include <linux/types.h>
 #include <linux/cache.h>
-#include <linux/module.h>
+#include <linux/export.h>
 
 #include <asm/xen/hypercall.h>
 
drivers/xen/grant-table.c +0 -1
index effbaf91791f..bb36b1e1dbcc 100644
@@ -33,7 +33,6 @@
 
 #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt
 
-#include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
drivers/xen/xen-pciback/conf_space.c +1 -1
index 9c234209d8b5..8e67336f8ddd 100644
@@ -10,7 +10,7 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/pci.h>
 #include "pciback.h"
 #include "conf_space.h"
drivers/xen/xen-pciback/pciback_ops.c +1 -1
index 73dafdc494aa..5ad01f9c24fc 100644
@@ -6,7 +6,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/wait.h>
 #include <linux/bitops.h>
 #include <xen/events.h>
drivers/xen/xen-pciback/xenbus.c +1 -1
index 4843741e703a..c252eb3f0176 100644
@@ -6,7 +6,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/vmalloc.h>
drivers/xen/xen-selfballoon.c +0 -1
index 3b2bffde534f..53a085fca00c 100644
@@ -71,7 +71,6 @@
 #include <linux/swap.h>
 #include <linux/mm.h>
 #include <linux/mman.h>
-#include <linux/module.h>
 #include <linux/workqueue.h>
 #include <linux/device.h>
 #include <xen/balloon.h>
drivers/xen/xenbus/xenbus_xs.c +0 -1
index ba804f3d8278..374b12af8812 100644
@@ -44,7 +44,6 @@
 #include <linux/fcntl.h>
 #include <linux/kthread.h>
 #include <linux/rwsem.h>
-#include <linux/module.h>
 #include <linux/mutex.h>
 #include <asm/xen/hypervisor.h>
 #include <xen/xenbus.h>
drivers/xen/xenfs/xensyms.c +0 -1
index a03f261b12d8..c6e2b4a542ea 100644
@@ -1,4 +1,3 @@
-#include <linux/module.h>
 #include <linux/init.h>
 #include <linux/seq_file.h>
 #include <linux/fs.h>
Signature · 1 line
2.6.1
Reviewed-by on v1 1/5
#3 lore raw

Re: [PATCH 1/5] xen: audit usages of module.h ; remove unnecessary instances

In reply to Paul Gortmaker
Quoted 13 lines · Paul Gortmaker

Code that uses no modular facilities whatsoever should not be sourcing module.h at all, since that header drags in a bunch of other headers with it.

Similarly, code that is not explicitly using modular facilities like module_init() but only is declaring module_param setup variables should be using moduleparam.h and not the larger module.h file for that.

In making this change, we also uncover an implicit use of BUG() in inline fcns within arch/arm/include/asm/xen/hypercall.h so we explicitly source <linux/bug.h> for that file now.

Quoted 8 lines
Cc Stefano Stabellini <[email protected]>
Cc Russell King <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
Quoted 164 lines
 arch/arm/include/asm/xen/hypercall.h  | 2 ++
 drivers/xen/events/events_2l.c        | 1 -
 drivers/xen/events/events_base.c      | 2 +-
 drivers/xen/events/events_fifo.c      | 1 -
 drivers/xen/features.c                | 2 +-
 drivers/xen/grant-table.c             | 1 -
 drivers/xen/xen-pciback/conf_space.c  | 2 +-
 drivers/xen/xen-pciback/pciback_ops.c | 2 +-
 drivers/xen/xen-pciback/xenbus.c      | 2 +-
 drivers/xen/xen-selfballoon.c         | 1 -
 drivers/xen/xenbus/xenbus_xs.c        | 1 -
 drivers/xen/xenfs/xensyms.c           | 1 -
 12 files changed, 7 insertions(+), 11 deletions(-)
arch/arm/include/asm/xen/hypercall.h +2 -0
index d769972db8cb..b6b962d70db9 100644
@@ -33,6 +33,8 @@
 #ifndef _ASM_ARM_XEN_HYPERCALL_H
 #define _ASM_ARM_XEN_HYPERCALL_H
 
+#include <linux/bug.h>
+
 #include <xen/interface/xen.h>
 #include <xen/interface/sched.h>
 #include <xen/interface/platform.h>
drivers/xen/events/events_2l.c +0 -1
index 7dd46312c180..51b488f5bfe9 100644
@@ -9,7 +9,6 @@
 #include <linux/linkage.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/module.h>
 
 #include <asm/sync_bitops.h>
 #include <asm/xen/hypercall.h>
drivers/xen/events/events_base.c +1 -1
index 524c22146429..488017a0806a 100644
@@ -26,7 +26,7 @@
 #include <linux/linkage.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/string.h>
 #include <linux/bootmem.h>
 #include <linux/slab.h>
drivers/xen/events/events_fifo.c +0 -1
index eff2b88003d9..9289a17712e2 100644
@@ -36,7 +36,6 @@
 #include <linux/linkage.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/module.h>
 #include <linux/smp.h>
 #include <linux/percpu.h>
 #include <linux/cpu.h>
drivers/xen/features.c +1 -1
index 99eda169c779..d7d34fdfc993 100644
@@ -7,7 +7,7 @@
  */
 #include <linux/types.h>
 #include <linux/cache.h>
-#include <linux/module.h>
+#include <linux/export.h>
 
 #include <asm/xen/hypercall.h>
 
drivers/xen/grant-table.c +0 -1
index effbaf91791f..bb36b1e1dbcc 100644
@@ -33,7 +33,6 @@
 
 #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt
 
-#include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
drivers/xen/xen-pciback/conf_space.c +1 -1
index 9c234209d8b5..8e67336f8ddd 100644
@@ -10,7 +10,7 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/pci.h>
 #include "pciback.h"
 #include "conf_space.h"
drivers/xen/xen-pciback/pciback_ops.c +1 -1
index 73dafdc494aa..5ad01f9c24fc 100644
@@ -6,7 +6,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/wait.h>
 #include <linux/bitops.h>
 #include <xen/events.h>
drivers/xen/xen-pciback/xenbus.c +1 -1
index 4843741e703a..c252eb3f0176 100644
@@ -6,7 +6,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/vmalloc.h>
drivers/xen/xen-selfballoon.c +0 -1
index 3b2bffde534f..53a085fca00c 100644
@@ -71,7 +71,6 @@
 #include <linux/swap.h>
 #include <linux/mm.h>
 #include <linux/mman.h>
-#include <linux/module.h>
 #include <linux/workqueue.h>
 #include <linux/device.h>
 #include <xen/balloon.h>
drivers/xen/xenbus/xenbus_xs.c +0 -1
index ba804f3d8278..374b12af8812 100644
@@ -44,7 +44,6 @@
 #include <linux/fcntl.h>
 #include <linux/kthread.h>
 #include <linux/rwsem.h>
-#include <linux/module.h>
 #include <linux/mutex.h>
 #include <asm/xen/hypervisor.h>
 #include <xen/xenbus.h>
drivers/xen/xenfs/xensyms.c +0 -1
index a03f261b12d8..c6e2b4a542ea 100644
@@ -1,4 +1,3 @@
-#include <linux/module.h>
 #include <linux/init.h>
 #include <linux/seq_file.h>
 #include <linux/fs.h>
Signature · 1 line
2.6.1
#4 lore raw

PATCH 2/5 drivers/xen: make [xen-]ballon explicitly non-modular

In reply to Paul Gortmaker

The Makefile / Kconfig currently controlling compilation here is:

obj-y += grant-table.o features.o balloon.o manage.o preempt.o time.o
[...]
obj-$(CONFIG_XEN_BALLOON) += xen-balloon.o

...with:

drivers/xen/Kconfig:config XEN_BALLOON
drivers/xen/Kconfig: bool "Xen memory balloon driver"

...meaning that they currently are not being built as modules 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.

In doing so we uncover two implict includes that were obtained by module.h having such a wide include scope itself:

In file included from drivers/xen/xen-balloon.c:41:0:
include/xen/balloon.h:26:51: warning: ‘struct page’ declared inside parameter list [enabled by default]

 int alloc_xenballooned_pages(int nr_pages, struct page **pages);
                                                   ^
include/xen/balloon.h: In function ‘register_xen_selfballooning’:
include/xen/balloon.h:35:10: error: ‘ENOSYS’ undeclared (first use in this function)
  return -ENOSYS;
          ^

This is fixed by adding mm-types.h and errno.h to the list.

We also delete the MODULE_LICENSE tags since all that information is already contained at the top of the file in the comments.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
---
 drivers/xen/balloon.c     |  4 ----
 drivers/xen/xen-balloon.c | 14 +++-----------
 2 files changed, 3 insertions(+), 15 deletions(-)
drivers/xen/balloon.c +0 -4
index 7c8a2cf16f58..9781e0dd59d6 100644
@@ -42,7 +42,6 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/errno.h>
-#include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/bootmem.h>
 #include <linux/pagemap.h>
@@ -760,7 +759,4 @@ static int __init balloon_init(void)
 
 	return 0;
 }
-
 subsys_initcall(balloon_init);
-
-MODULE_LICENSE("GPL");
drivers/xen/xen-balloon.c +3 -11
index 39e7ef8d3957..79865b8901ba 100644
@@ -33,7 +33,9 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/mm_types.h>
+#include <linux/init.h>
 #include <linux/capability.h>
 
 #include <xen/xen.h>
@@ -109,14 +111,6 @@ static int __init balloon_init(void)
 }
 subsys_initcall(balloon_init);
 
-static void balloon_exit(void)
-{
-    /* XXX - release balloon here */
-    return;
-}
-
-module_exit(balloon_exit);
-
 #define BALLOON_SHOW(name, format, args...)				\
 	static ssize_t show_##name(struct device *dev,			\
 				   struct device_attribute *attr,	\
@@ -250,5 +244,3 @@ static int register_balloon(struct device *dev)
 
 	return 0;
 }
-
-MODULE_LICENSE("GPL");
Signature · 7 lines
2.6.1


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#5 lore raw

PATCH 2/5 drivers/xen: make [xen-]ballon explicitly non-modular

In reply to Paul Gortmaker

The Makefile / Kconfig currently controlling compilation here is:

obj-y += grant-table.o features.o balloon.o manage.o preempt.o time.o
[...]
obj-$(CONFIG_XEN_BALLOON) += xen-balloon.o

...with:

drivers/xen/Kconfig:config XEN_BALLOON
drivers/xen/Kconfig: bool "Xen memory balloon driver"

...meaning that they currently are not being built as modules 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.

In doing so we uncover two implict includes that were obtained by module.h having such a wide include scope itself:

In file included from drivers/xen/xen-balloon.c:41:0:
include/xen/balloon.h:26:51: warning: ‘struct page’ declared inside parameter list [enabled by default]

 int alloc_xenballooned_pages(int nr_pages, struct page **pages);
                                                   ^
include/xen/balloon.h: In function ‘register_xen_selfballooning’:
include/xen/balloon.h:35:10: error: ‘ENOSYS’ undeclared (first use in this function)
  return -ENOSYS;
          ^

This is fixed by adding mm-types.h and errno.h to the list.

We also delete the MODULE_LICENSE tags since all that information is already contained at the top of the file in the comments.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
---
 drivers/xen/balloon.c     |  4 ----
 drivers/xen/xen-balloon.c | 14 +++-----------
 2 files changed, 3 insertions(+), 15 deletions(-)
drivers/xen/balloon.c +0 -4
index 7c8a2cf16f58..9781e0dd59d6 100644
@@ -42,7 +42,6 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/errno.h>
-#include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/bootmem.h>
 #include <linux/pagemap.h>
@@ -760,7 +759,4 @@ static int __init balloon_init(void)
 
 	return 0;
 }
-
 subsys_initcall(balloon_init);
-
-MODULE_LICENSE("GPL");
drivers/xen/xen-balloon.c +3 -11
index 39e7ef8d3957..79865b8901ba 100644
@@ -33,7 +33,9 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/mm_types.h>
+#include <linux/init.h>
 #include <linux/capability.h>
 
 #include <xen/xen.h>
@@ -109,14 +111,6 @@ static int __init balloon_init(void)
 }
 subsys_initcall(balloon_init);
 
-static void balloon_exit(void)
-{
-    /* XXX - release balloon here */
-    return;
-}
-
-module_exit(balloon_exit);
-
 #define BALLOON_SHOW(name, format, args...)				\
 	static ssize_t show_##name(struct device *dev,			\
 				   struct device_attribute *attr,	\
@@ -250,5 +244,3 @@ static int register_balloon(struct device *dev)
 
 	return 0;
 }
-
-MODULE_LICENSE("GPL");
Signature · 1 line
2.6.1
Reviewed-by on v1 2/5
#6 lore raw

Re: [PATCH 2/5] drivers/xen: make [xen-]ballon explicitly non-modular

Quoted 30 lines · Paul Gortmaker

The Makefile / Kconfig currently controlling compilation here is:

obj-y += grant-table.o features.o balloon.o manage.o preempt.o time.o
[...]
obj-$(CONFIG_XEN_BALLOON) += xen-balloon.o

...with:

drivers/xen/Kconfig:config XEN_BALLOON
drivers/xen/Kconfig: bool "Xen memory balloon driver"

...meaning that they currently are not being built as modules 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.

In doing so we uncover two implict includes that were obtained by module.h having such a wide include scope itself:

In file included from drivers/xen/xen-balloon.c:41:0:
include/xen/balloon.h:26:51: warning: ‘struct page’ declared inside parameter list [enabled by default]

 int alloc_xenballooned_pages(int nr_pages, struct page **pages);
                                                   ^
include/xen/balloon.h: In function ‘register_xen_selfballooning’:
include/xen/balloon.h:35:10: error: ‘ENOSYS’ undeclared (first use in this function)
  return -ENOSYS;
          ^

This is fixed by adding mm-types.h and errno.h to the list.

Quoted 8 lines

We also delete the MODULE_LICENSE tags since all that information is already contained at the top of the file in the comments.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
Quoted 63 lines
 drivers/xen/balloon.c     |  4 ----
 drivers/xen/xen-balloon.c | 14 +++-----------
 2 files changed, 3 insertions(+), 15 deletions(-)
drivers/xen/balloon.c +0 -4
index 7c8a2cf16f58..9781e0dd59d6 100644
@@ -42,7 +42,6 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/errno.h>
-#include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/bootmem.h>
 #include <linux/pagemap.h>
@@ -760,7 +759,4 @@ static int __init balloon_init(void)
 
 	return 0;
 }
-
 subsys_initcall(balloon_init);
-
-MODULE_LICENSE("GPL");
drivers/xen/xen-balloon.c +3 -11
index 39e7ef8d3957..79865b8901ba 100644
@@ -33,7 +33,9 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/mm_types.h>
+#include <linux/init.h>
 #include <linux/capability.h>
 
 #include <xen/xen.h>
@@ -109,14 +111,6 @@ static int __init balloon_init(void)
 }
 subsys_initcall(balloon_init);
 
-static void balloon_exit(void)
-{
-    /* XXX - release balloon here */
-    return;
-}
-
-module_exit(balloon_exit);
-
 #define BALLOON_SHOW(name, format, args...)				\
 	static ssize_t show_##name(struct device *dev,			\
 				   struct device_attribute *attr,	\
@@ -250,5 +244,3 @@ static int register_balloon(struct device *dev)
 
 	return 0;
 }
-
-MODULE_LICENSE("GPL");
Signature · 1 line
2.6.1
Reviewed-by on v1 2/5
#7 lore raw

Re: [PATCH 2/5] drivers/xen: make [xen-]ballon explicitly non-modular

In reply to Paul Gortmaker
Quoted 30 lines · Paul Gortmaker

The Makefile / Kconfig currently controlling compilation here is:

obj-y += grant-table.o features.o balloon.o manage.o preempt.o time.o
[...]
obj-$(CONFIG_XEN_BALLOON) += xen-balloon.o

...with:

drivers/xen/Kconfig:config XEN_BALLOON
drivers/xen/Kconfig: bool "Xen memory balloon driver"

...meaning that they currently are not being built as modules 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.

In doing so we uncover two implict includes that were obtained by module.h having such a wide include scope itself:

In file included from drivers/xen/xen-balloon.c:41:0:
include/xen/balloon.h:26:51: warning: ‘struct page’ declared inside parameter list [enabled by default]

 int alloc_xenballooned_pages(int nr_pages, struct page **pages);
                                                   ^
include/xen/balloon.h: In function ‘register_xen_selfballooning’:
include/xen/balloon.h:35:10: error: ‘ENOSYS’ undeclared (first use in this function)
  return -ENOSYS;
          ^

This is fixed by adding mm-types.h and errno.h to the list.

Quoted 8 lines

We also delete the MODULE_LICENSE tags since all that information is already contained at the top of the file in the comments.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
Quoted 61 lines
 drivers/xen/balloon.c     |  4 ----
 drivers/xen/xen-balloon.c | 14 +++-----------
 2 files changed, 3 insertions(+), 15 deletions(-)
drivers/xen/balloon.c +0 -4
index 7c8a2cf16f58..9781e0dd59d6 100644
@@ -42,7 +42,6 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/errno.h>
-#include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/bootmem.h>
 #include <linux/pagemap.h>
@@ -760,7 +759,4 @@ static int __init balloon_init(void)
 
 	return 0;
 }
-
 subsys_initcall(balloon_init);
-
-MODULE_LICENSE("GPL");
drivers/xen/xen-balloon.c +3 -12
index 39e7ef8d3957..79865b8901ba 100644
@@ -33,7 +33,9 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/mm_types.h>
+#include <linux/init.h>
 #include <linux/capability.h>
 
 #include <xen/xen.h>
@@ -109,14 +111,6 @@ static int __init balloon_init(void)
 }
 subsys_initcall(balloon_init);
 
-static void balloon_exit(void)
-{
-    /* XXX - release balloon here */
-    return;
-}
-
-module_exit(balloon_exit);
-
 #define BALLOON_SHOW(name, format, args...)				\
 	static ssize_t show_##name(struct device *dev,			\
 				   struct device_attribute *attr,	\
@@ -250,5 +244,3 @@ static int register_balloon(struct device *dev)
 
 	return 0;
 }
-
-MODULE_LICENSE("GPL");
--
Quoted 2 lines

2.6.1

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#8 lore raw

PATCH 3/5 drivers/xen: make xenbus_dev_[front/back]end explicitly non-modular

In reply to Paul Gortmaker

The Makefile / Kconfig currently controlling compilation here is:

obj-y += xenbus_dev_frontend.o
[...]
obj-$(CONFIG_XEN_BACKEND) += xenbus_dev_backend.o

...with:

drivers/xen/Kconfig:config XEN_BACKEND
drivers/xen/Kconfig: bool "Backend driver support"

...meaning that they currently are not being built as modules 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 also delete the MODULE_LICENSE tag since all that information is already contained at the top of the file in the comments.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
---
 drivers/xen/xenbus/xenbus_dev_backend.c  | 13 ++-----------
 drivers/xen/xenbus/xenbus_dev_frontend.c | 13 ++-----------
 2 files changed, 4 insertions(+), 22 deletions(-)
drivers/xen/xenbus/xenbus_dev_backend.c +2 -11
index ee6d9efd7b76..4a41ac9af966 100644
@@ -5,7 +5,7 @@
 #include <linux/mm.h>
 #include <linux/fs.h>
 #include <linux/miscdevice.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/capability.h>
 
 #include <xen/xen.h>
@@ -18,8 +18,6 @@
 
 #include "xenbus_comms.h"
 
-MODULE_LICENSE("GPL");
-
 static int xenbus_backend_open(struct inode *inode, struct file *filp)
 {
 	if (!capable(CAP_SYS_ADMIN))
@@ -132,11 +130,4 @@ static int __init xenbus_backend_init(void)
 		pr_err("Could not register xenbus backend device\n");
 	return err;
 }
-
-static void __exit xenbus_backend_exit(void)
-{
-	misc_deregister(&xenbus_backend_dev);
-}
-
-module_init(xenbus_backend_init);
-module_exit(xenbus_backend_exit);
+device_initcall(xenbus_backend_init);
drivers/xen/xenbus/xenbus_dev_frontend.c +2 -11
index 9433e46518c8..8c0a359ab4a8 100644
@@ -55,7 +55,7 @@
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/miscdevice.h>
-#include <linux/module.h>
+#include <linux/init.h>
 
 #include "xenbus_comms.h"
 
@@ -63,8 +63,6 @@
 #include <xen/xen.h>
 #include <asm/xen/hypervisor.h>
 
-MODULE_LICENSE("GPL");
-
 /*
  * An element of a list of outstanding transactions, for which we're
  * still waiting a reply.
@@ -624,11 +622,4 @@ static int __init xenbus_init(void)
 		pr_err("Could not register xenbus frontend device\n");
 	return err;
 }
-
-static void __exit xenbus_exit(void)
-{
-	misc_deregister(&xenbus_dev);
-}
-
-module_init(xenbus_init);
-module_exit(xenbus_exit);
+device_initcall(xenbus_init);
Signature · 1 line
2.6.1
#9 lore raw

PATCH 3/5 drivers/xen: make xenbus_dev_[front/back]end explicitly non-modular

In reply to Paul Gortmaker

The Makefile / Kconfig currently controlling compilation here is:

obj-y += xenbus_dev_frontend.o
[...]
obj-$(CONFIG_XEN_BACKEND) += xenbus_dev_backend.o

...with:

drivers/xen/Kconfig:config XEN_BACKEND
drivers/xen/Kconfig: bool "Backend driver support"

...meaning that they currently are not being built as modules 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 also delete the MODULE_LICENSE tag since all that information is already contained at the top of the file in the comments.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
---
 drivers/xen/xenbus/xenbus_dev_backend.c  | 13 ++-----------
 drivers/xen/xenbus/xenbus_dev_frontend.c | 13 ++-----------
 2 files changed, 4 insertions(+), 22 deletions(-)
drivers/xen/xenbus/xenbus_dev_backend.c +2 -11
index ee6d9efd7b76..4a41ac9af966 100644
@@ -5,7 +5,7 @@
 #include <linux/mm.h>
 #include <linux/fs.h>
 #include <linux/miscdevice.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/capability.h>
 
 #include <xen/xen.h>
@@ -18,8 +18,6 @@
 
 #include "xenbus_comms.h"
 
-MODULE_LICENSE("GPL");
-
 static int xenbus_backend_open(struct inode *inode, struct file *filp)
 {
 	if (!capable(CAP_SYS_ADMIN))
@@ -132,11 +130,4 @@ static int __init xenbus_backend_init(void)
 		pr_err("Could not register xenbus backend device\n");
 	return err;
 }
-
-static void __exit xenbus_backend_exit(void)
-{
-	misc_deregister(&xenbus_backend_dev);
-}
-
-module_init(xenbus_backend_init);
-module_exit(xenbus_backend_exit);
+device_initcall(xenbus_backend_init);
drivers/xen/xenbus/xenbus_dev_frontend.c +2 -11
index 9433e46518c8..8c0a359ab4a8 100644
@@ -55,7 +55,7 @@
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/miscdevice.h>
-#include <linux/module.h>
+#include <linux/init.h>
 
 #include "xenbus_comms.h"
 
@@ -63,8 +63,6 @@
 #include <xen/xen.h>
 #include <asm/xen/hypervisor.h>
 
-MODULE_LICENSE("GPL");
-
 /*
  * An element of a list of outstanding transactions, for which we're
  * still waiting a reply.
@@ -624,11 +622,4 @@ static int __init xenbus_init(void)
 		pr_err("Could not register xenbus frontend device\n");
 	return err;
 }
-
-static void __exit xenbus_exit(void)
-{
-	misc_deregister(&xenbus_dev);
-}
-
-module_init(xenbus_init);
-module_exit(xenbus_exit);
+device_initcall(xenbus_init);
Signature · 1 line
2.6.1
Reviewed-by on v1 3/5
#10 lore raw

Re: [Xen-devel] [PATCH 3/5] drivers/xen: make xenbus_dev_[front/back]end explicitly non-modular

Quoted 19 lines · Paul Gortmaker

The Makefile / Kconfig currently controlling compilation here is:

obj-y += xenbus_dev_frontend.o
[...]
obj-$(CONFIG_XEN_BACKEND) += xenbus_dev_backend.o

...with:

drivers/xen/Kconfig:config XEN_BACKEND
drivers/xen/Kconfig: bool "Backend driver support"

...meaning that they currently are not being built as modules 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.

Quoted 8 lines

We also delete the MODULE_LICENSE tag since all that information is already contained at the top of the file in the comments.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
Quoted 83 lines
 drivers/xen/xenbus/xenbus_dev_backend.c  | 13 ++-----------
 drivers/xen/xenbus/xenbus_dev_frontend.c | 13 ++-----------
 2 files changed, 4 insertions(+), 22 deletions(-)
drivers/xen/xenbus/xenbus_dev_backend.c +2 -11
index ee6d9efd7b76..4a41ac9af966 100644
@@ -5,7 +5,7 @@
 #include <linux/mm.h>
 #include <linux/fs.h>
 #include <linux/miscdevice.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/capability.h>
 
 #include <xen/xen.h>
@@ -18,8 +18,6 @@
 
 #include "xenbus_comms.h"
 
-MODULE_LICENSE("GPL");
-
 static int xenbus_backend_open(struct inode *inode, struct file *filp)
 {
 	if (!capable(CAP_SYS_ADMIN))
@@ -132,11 +130,4 @@ static int __init xenbus_backend_init(void)
 		pr_err("Could not register xenbus backend device\n");
 	return err;
 }
-
-static void __exit xenbus_backend_exit(void)
-{
-	misc_deregister(&xenbus_backend_dev);
-}
-
-module_init(xenbus_backend_init);
-module_exit(xenbus_backend_exit);
+device_initcall(xenbus_backend_init);
drivers/xen/xenbus/xenbus_dev_frontend.c +2 -11
index 9433e46518c8..8c0a359ab4a8 100644
@@ -55,7 +55,7 @@
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/miscdevice.h>
-#include <linux/module.h>
+#include <linux/init.h>
 
 #include "xenbus_comms.h"
 
@@ -63,8 +63,6 @@
 #include <xen/xen.h>
 #include <asm/xen/hypervisor.h>
 
-MODULE_LICENSE("GPL");
-
 /*
  * An element of a list of outstanding transactions, for which we're
  * still waiting a reply.
@@ -624,11 +622,4 @@ static int __init xenbus_init(void)
 		pr_err("Could not register xenbus frontend device\n");
 	return err;
 }
-
-static void __exit xenbus_exit(void)
-{
-	misc_deregister(&xenbus_dev);
-}
-
-module_init(xenbus_init);
-module_exit(xenbus_exit);
+device_initcall(xenbus_init);
Signature · 7 lines
2.6.1


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Reviewed-by on v1 3/5
#11 lore raw

Re: [PATCH 3/5] drivers/xen: make xenbus_dev_[front/back]end explicitly non-modular

In reply to Paul Gortmaker
Quoted 19 lines · Paul Gortmaker

The Makefile / Kconfig currently controlling compilation here is:

obj-y += xenbus_dev_frontend.o
[...]
obj-$(CONFIG_XEN_BACKEND) += xenbus_dev_backend.o

...with:

drivers/xen/Kconfig:config XEN_BACKEND
drivers/xen/Kconfig: bool "Backend driver support"

...meaning that they currently are not being built as modules 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.

Quoted 8 lines

We also delete the MODULE_LICENSE tag since all that information is already contained at the top of the file in the comments.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
Quoted 83 lines
 drivers/xen/xenbus/xenbus_dev_backend.c  | 13 ++-----------
 drivers/xen/xenbus/xenbus_dev_frontend.c | 13 ++-----------
 2 files changed, 4 insertions(+), 22 deletions(-)
drivers/xen/xenbus/xenbus_dev_backend.c +2 -11
index ee6d9efd7b76..4a41ac9af966 100644
@@ -5,7 +5,7 @@
 #include <linux/mm.h>
 #include <linux/fs.h>
 #include <linux/miscdevice.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/capability.h>
 
 #include <xen/xen.h>
@@ -18,8 +18,6 @@
 
 #include "xenbus_comms.h"
 
-MODULE_LICENSE("GPL");
-
 static int xenbus_backend_open(struct inode *inode, struct file *filp)
 {
 	if (!capable(CAP_SYS_ADMIN))
@@ -132,11 +130,4 @@ static int __init xenbus_backend_init(void)
 		pr_err("Could not register xenbus backend device\n");
 	return err;
 }
-
-static void __exit xenbus_backend_exit(void)
-{
-	misc_deregister(&xenbus_backend_dev);
-}
-
-module_init(xenbus_backend_init);
-module_exit(xenbus_backend_exit);
+device_initcall(xenbus_backend_init);
drivers/xen/xenbus/xenbus_dev_frontend.c +2 -11
index 9433e46518c8..8c0a359ab4a8 100644
@@ -55,7 +55,7 @@
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/miscdevice.h>
-#include <linux/module.h>
+#include <linux/init.h>
 
 #include "xenbus_comms.h"
 
@@ -63,8 +63,6 @@
 #include <xen/xen.h>
 #include <asm/xen/hypervisor.h>
 
-MODULE_LICENSE("GPL");
-
 /*
  * An element of a list of outstanding transactions, for which we're
  * still waiting a reply.
@@ -624,11 +622,4 @@ static int __init xenbus_init(void)
 		pr_err("Could not register xenbus frontend device\n");
 	return err;
 }
-
-static void __exit xenbus_exit(void)
-{
-	misc_deregister(&xenbus_dev);
-}
-
-module_init(xenbus_init);
-module_exit(xenbus_exit);
+device_initcall(xenbus_init);
Signature · 7 lines
2.6.1


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#12 lore raw

PATCH 4/5 drivers/xen: make sys-hypervisor.c explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config XEN_SYS_HYPERVISOR
bool "Create xen entries under /sys/hypervisor"

...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. However one could argue that fs_initcall() might make more sense here.

This change means that the one line function xen_properties_destroy() has only one user left, and since that is inside an #ifdef, we just manually inline it there vs. adding more ifdeffery around the function to avoid compile warnings about "defined but not used".

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
---
 drivers/xen/sys-hypervisor.c | 31 ++++---------------------------
 1 file changed, 4 insertions(+), 27 deletions(-)
drivers/xen/sys-hypervisor.c +4 -27
index b5a7342e0ba5..ea6e98d60af0 100644
@@ -9,7 +9,7 @@
 
 #include <linux/slab.h>
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/kobject.h>
 #include <linux/err.h>
 
@@ -366,11 +366,6 @@ static int __init xen_properties_init(void)
 	return sysfs_create_group(hypervisor_kobj, &xen_properties_group);
 }
 
-static void xen_properties_destroy(void)
-{
-	sysfs_remove_group(hypervisor_kobj, &xen_properties_group);
-}
-
 #ifdef CONFIG_XEN_HAVE_VPMU
 struct pmu_mode {
 	const char *name;
@@ -484,11 +479,6 @@ static int __init xen_pmu_init(void)
 {
 	return sysfs_create_group(hypervisor_kobj, &xen_pmu_group);
 }
-
-static void xen_pmu_destroy(void)
-{
-	sysfs_remove_group(hypervisor_kobj, &xen_pmu_group);
-}
 #endif
 
 static int __init hyper_sysfs_init(void)
@@ -517,7 +507,8 @@ static int __init hyper_sysfs_init(void)
 	if (xen_initial_domain()) {
 		ret = xen_pmu_init();
 		if (ret) {
-			xen_properties_destroy();
+			sysfs_remove_group(hypervisor_kobj,
+					   &xen_properties_group);
 			goto prop_out;
 		}
 	}
@@ -535,21 +526,7 @@ version_out:
 out:
 	return ret;
 }
-
-static void __exit hyper_sysfs_exit(void)
-{
-#ifdef CONFIG_XEN_HAVE_VPMU
-	xen_pmu_destroy();
-#endif
-	xen_properties_destroy();
-	xen_compilation_destroy();
-	xen_sysfs_uuid_destroy();
-	xen_sysfs_version_destroy();
-	xen_sysfs_type_destroy();
-
-}
-module_init(hyper_sysfs_init);
-module_exit(hyper_sysfs_exit);
+device_initcall(hyper_sysfs_init);
 
 static ssize_t hyp_sysfs_show(struct kobject *kobj,
 			      struct attribute *attr,
Signature · 1 line
2.6.1
#13 lore raw

Re: [PATCH 4/5] drivers/xen: make sys-hypervisor.c explicitly non-modular

Quoted 10 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config XEN_SYS_HYPERVISOR
bool "Create xen entries under /sys/hypervisor"

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

Quoted 8 lines

Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit. However one could argue that fs_initcall() might make more sense here.

This change means that the one line function xen_properties_destroy() has only one user left, and since that is inside an #ifdef, we just manually inline it there vs. adding more ifdeffery around the function to avoid compile warnings about "defined but not used".

Actually xen_sysfs_uuid_destroy, xen_compilation_destroy, xen_sysfs_version_destroy, and xen_sysfs_type_destroy are also one-liners with only one user left.

Quoted 82 lines
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
---
 drivers/xen/sys-hypervisor.c | 31 ++++---------------------------
 1 file changed, 4 insertions(+), 27 deletions(-)
drivers/xen/sys-hypervisor.c +4 -27
index b5a7342e0ba5..ea6e98d60af0 100644
@@ -9,7 +9,7 @@
 
 #include <linux/slab.h>
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/kobject.h>
 #include <linux/err.h>
 
@@ -366,11 +366,6 @@ static int __init xen_properties_init(void)
 	return sysfs_create_group(hypervisor_kobj, &xen_properties_group);
 }
 
-static void xen_properties_destroy(void)
-{
-	sysfs_remove_group(hypervisor_kobj, &xen_properties_group);
-}
-
 #ifdef CONFIG_XEN_HAVE_VPMU
 struct pmu_mode {
 	const char *name;
@@ -484,11 +479,6 @@ static int __init xen_pmu_init(void)
 {
 	return sysfs_create_group(hypervisor_kobj, &xen_pmu_group);
 }
-
-static void xen_pmu_destroy(void)
-{
-	sysfs_remove_group(hypervisor_kobj, &xen_pmu_group);
-}
 #endif
 
 static int __init hyper_sysfs_init(void)
@@ -517,7 +507,8 @@ static int __init hyper_sysfs_init(void)
 	if (xen_initial_domain()) {
 		ret = xen_pmu_init();
 		if (ret) {
-			xen_properties_destroy();
+			sysfs_remove_group(hypervisor_kobj,
+					   &xen_properties_group);
 			goto prop_out;
 		}
 	}
@@ -535,21 +526,7 @@ version_out:
 out:
 	return ret;
 }
-
-static void __exit hyper_sysfs_exit(void)
-{
-#ifdef CONFIG_XEN_HAVE_VPMU
-	xen_pmu_destroy();
-#endif
-	xen_properties_destroy();
-	xen_compilation_destroy();
-	xen_sysfs_uuid_destroy();
-	xen_sysfs_version_destroy();
-	xen_sysfs_type_destroy();
-
-}
-module_init(hyper_sysfs_init);
-module_exit(hyper_sysfs_exit);
+device_initcall(hyper_sysfs_init);
 
 static ssize_t hyp_sysfs_show(struct kobject *kobj,
 			      struct attribute *attr,
Signature · 1 line
2.6.1
#14 lore raw

Re: [PATCH 4/5] drivers/xen: make sys-hypervisor.c explicitly non-modular

In reply to Paul Gortmaker
Quoted 10 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

config XEN_SYS_HYPERVISOR
bool "Create xen entries under /sys/hypervisor"

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

Quoted 8 lines

Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit. However one could argue that fs_initcall() might make more sense here.

This change means that the one line function xen_properties_destroy() has only one user left, and since that is inside an #ifdef, we just manually inline it there vs. adding more ifdeffery around the function to avoid compile warnings about "defined but not used".

Actually xen_sysfs_uuid_destroy, xen_compilation_destroy, xen_sysfs_version_destroy, and xen_sysfs_type_destroy are also one-liners with only one user left.

Quoted 82 lines
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
---
 drivers/xen/sys-hypervisor.c | 31 ++++---------------------------
 1 file changed, 4 insertions(+), 27 deletions(-)
drivers/xen/sys-hypervisor.c +4 -27
index b5a7342e0ba5..ea6e98d60af0 100644
@@ -9,7 +9,7 @@
 
 #include <linux/slab.h>
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/kobject.h>
 #include <linux/err.h>
 
@@ -366,11 +366,6 @@ static int __init xen_properties_init(void)
 	return sysfs_create_group(hypervisor_kobj, &xen_properties_group);
 }
 
-static void xen_properties_destroy(void)
-{
-	sysfs_remove_group(hypervisor_kobj, &xen_properties_group);
-}
-
 #ifdef CONFIG_XEN_HAVE_VPMU
 struct pmu_mode {
 	const char *name;
@@ -484,11 +479,6 @@ static int __init xen_pmu_init(void)
 {
 	return sysfs_create_group(hypervisor_kobj, &xen_pmu_group);
 }
-
-static void xen_pmu_destroy(void)
-{
-	sysfs_remove_group(hypervisor_kobj, &xen_pmu_group);
-}
 #endif
 
 static int __init hyper_sysfs_init(void)
@@ -517,7 +507,8 @@ static int __init hyper_sysfs_init(void)
 	if (xen_initial_domain()) {
 		ret = xen_pmu_init();
 		if (ret) {
-			xen_properties_destroy();
+			sysfs_remove_group(hypervisor_kobj,
+					   &xen_properties_group);
 			goto prop_out;
 		}
 	}
@@ -535,21 +526,7 @@ version_out:
 out:
 	return ret;
 }
-
-static void __exit hyper_sysfs_exit(void)
-{
-#ifdef CONFIG_XEN_HAVE_VPMU
-	xen_pmu_destroy();
-#endif
-	xen_properties_destroy();
-	xen_compilation_destroy();
-	xen_sysfs_uuid_destroy();
-	xen_sysfs_version_destroy();
-	xen_sysfs_type_destroy();
-
-}
-module_init(hyper_sysfs_init);
-module_exit(hyper_sysfs_exit);
+device_initcall(hyper_sysfs_init);
 
 static ssize_t hyp_sysfs_show(struct kobject *kobj,
 			      struct attribute *attr,
Signature · 1 line
2.6.1
#15 lore raw

PATCH 5/5 drivers/xen: make platform-pci.c explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

arch/x86/xen/Kconfig:config XEN_PVHVM
arch/x86/xen/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 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 Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
---
 drivers/xen/platform-pci.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/xen/platform-pci.c +6 -10
index 3454973dc3bb..302232518c98 100644
@@ -2,6 +2,9 @@
  * platform-pci.c
  *
  * Xen platform PCI device driver
+ *
+ * Authors: [email protected] and [email protected]
+ *
  * Copyright (c) 2005, Intel Corporation.
  * Copyright (c) 2007, XenSource Inc.
  * Copyright (c) 2010, Citrix
@@ -24,7 +27,7 @@
 
 #include <linux/interrupt.h>
 #include <linux/io.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/pci.h>
 
 #include <xen/platform_pci.h>
@@ -36,10 +39,6 @@
 
 #define DRV_NAME    "xen-platform-pci"
 
-MODULE_AUTHOR("[email protected] and [email protected]");
-MODULE_DESCRIPTION("Xen platform PCI device");
-MODULE_LICENSE("GPL");
-
 static unsigned long platform_mmio;
 static unsigned long platform_mmio_alloc;
 static unsigned long platform_mmiolen;
@@ -181,8 +180,6 @@ static struct pci_device_id platform_pci_tbl[] = {
 	{0,}
 };
 
-MODULE_DEVICE_TABLE(pci, platform_pci_tbl);
-
 static struct pci_driver platform_driver = {
 	.name =           DRV_NAME,
 	.probe =          platform_pci_init,
@@ -192,9 +189,8 @@ static struct pci_driver platform_driver = {
 #endif
 };
 
-static int __init platform_pci_module_init(void)
+static int __init platform_pci_xen_init(void)
 {
 	return pci_register_driver(&platform_driver);
 }
-
-module_init(platform_pci_module_init);
+device_initcall(platform_pci_xen_init);
Signature · 1 line
2.6.1
#16 lore raw

PATCH 5/5 drivers/xen: make platform-pci.c explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

arch/x86/xen/Kconfig:config XEN_PVHVM
arch/x86/xen/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 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 Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
---
 drivers/xen/platform-pci.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/xen/platform-pci.c +6 -10
index 3454973dc3bb..302232518c98 100644
@@ -2,6 +2,9 @@
  * platform-pci.c
  *
  * Xen platform PCI device driver
+ *
+ * Authors: [email protected] and [email protected]
+ *
  * Copyright (c) 2005, Intel Corporation.
  * Copyright (c) 2007, XenSource Inc.
  * Copyright (c) 2010, Citrix
@@ -24,7 +27,7 @@
 
 #include <linux/interrupt.h>
 #include <linux/io.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/pci.h>
 
 #include <xen/platform_pci.h>
@@ -36,10 +39,6 @@
 
 #define DRV_NAME    "xen-platform-pci"
 
-MODULE_AUTHOR("[email protected] and [email protected]");
-MODULE_DESCRIPTION("Xen platform PCI device");
-MODULE_LICENSE("GPL");
-
 static unsigned long platform_mmio;
 static unsigned long platform_mmio_alloc;
 static unsigned long platform_mmiolen;
@@ -181,8 +180,6 @@ static struct pci_device_id platform_pci_tbl[] = {
 	{0,}
 };
 
-MODULE_DEVICE_TABLE(pci, platform_pci_tbl);
-
 static struct pci_driver platform_driver = {
 	.name =           DRV_NAME,
 	.probe =          platform_pci_init,
@@ -192,9 +189,8 @@ static struct pci_driver platform_driver = {
 #endif
 };
 
-static int __init platform_pci_module_init(void)
+static int __init platform_pci_xen_init(void)
 {
 	return pci_register_driver(&platform_driver);
 }
-
-module_init(platform_pci_module_init);
+device_initcall(platform_pci_xen_init);
Signature · 1 line
2.6.1
#17 lore raw

Re: [PATCH 5/5] drivers/xen: make platform-pci.c explicitly non-modular

Quoted 71 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

arch/x86/xen/Kconfig:config XEN_PVHVM
arch/x86/xen/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 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 Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
---
 drivers/xen/platform-pci.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/xen/platform-pci.c +4 -7
index 3454973dc3bb..302232518c98 100644
@@ -2,6 +2,9 @@
  * platform-pci.c
  *
  * Xen platform PCI device driver
+ *
+ * Authors: [email protected] and [email protected]
+ *
  * Copyright (c) 2005, Intel Corporation.
  * Copyright (c) 2007, XenSource Inc.
  * Copyright (c) 2010, Citrix
@@ -24,7 +27,7 @@
 
 #include <linux/interrupt.h>
 #include <linux/io.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/pci.h>
 
 #include <xen/platform_pci.h>
@@ -36,10 +39,6 @@
 
 #define DRV_NAME    "xen-platform-pci"
 
-MODULE_AUTHOR("[email protected] and [email protected]");
-MODULE_DESCRIPTION("Xen platform PCI device");
-MODULE_LICENSE("GPL");
-
 static unsigned long platform_mmio;
 static unsigned long platform_mmio_alloc;
 static unsigned long platform_mmiolen;
@@ -181,8 +180,6 @@ static struct pci_device_id platform_pci_tbl[] = {
 	{0,}
 };
 
-MODULE_DEVICE_TABLE(pci, platform_pci_tbl);
-
 static struct pci_driver platform_driver = {
 	.name =           DRV_NAME,
 	.probe =          platform_pci_init,

drivers/xen/platform-pci.c static struct pci_driver platform_driver = { · line 192

Quoted 5 lines
drivers/xen/platform-pci.c +1 -1
@@ -192,9 +189,8 @@ static struct pci_driver platform_driver = {
 #endif
 };
 
-static int __init platform_pci_module_init(void)
+static int __init platform_pci_xen_init(void)

Maybe platform_pci_register? Or rename platform_pci_init to platform_pci_probe and this to platform_pci_init.

Quoted 9 lines
drivers/xen/platform-pci.c +1 -2
 {
 	return pci_register_driver(&platform_driver);
 }
-
-module_init(platform_pci_module_init);
+device_initcall(platform_pci_xen_init);
Signature · 1 line
2.6.1
#18 lore raw

Re: [PATCH 5/5] drivers/xen: make platform-pci.c explicitly non-modular

In reply to Paul Gortmaker
Quoted 71 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

arch/x86/xen/Kconfig:config XEN_PVHVM
arch/x86/xen/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 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 Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
---
 drivers/xen/platform-pci.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/xen/platform-pci.c +4 -7
index 3454973dc3bb..302232518c98 100644
@@ -2,6 +2,9 @@
  * platform-pci.c
  *
  * Xen platform PCI device driver
+ *
+ * Authors: [email protected] and [email protected]
+ *
  * Copyright (c) 2005, Intel Corporation.
  * Copyright (c) 2007, XenSource Inc.
  * Copyright (c) 2010, Citrix
@@ -24,7 +27,7 @@
 
 #include <linux/interrupt.h>
 #include <linux/io.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/pci.h>
 
 #include <xen/platform_pci.h>
@@ -36,10 +39,6 @@
 
 #define DRV_NAME    "xen-platform-pci"
 
-MODULE_AUTHOR("[email protected] and [email protected]");
-MODULE_DESCRIPTION("Xen platform PCI device");
-MODULE_LICENSE("GPL");
-
 static unsigned long platform_mmio;
 static unsigned long platform_mmio_alloc;
 static unsigned long platform_mmiolen;
@@ -181,8 +180,6 @@ static struct pci_device_id platform_pci_tbl[] = {
 	{0,}
 };
 
-MODULE_DEVICE_TABLE(pci, platform_pci_tbl);
-
 static struct pci_driver platform_driver = {
 	.name =           DRV_NAME,
 	.probe =          platform_pci_init,

drivers/xen/platform-pci.c static struct pci_driver platform_driver = { · line 192

Quoted 5 lines
drivers/xen/platform-pci.c +1 -1
@@ -192,9 +189,8 @@ static struct pci_driver platform_driver = {
 #endif
 };
 
-static int __init platform_pci_module_init(void)
+static int __init platform_pci_xen_init(void)

Maybe platform_pci_register? Or rename platform_pci_init to platform_pci_probe and this to platform_pci_init.

Quoted 9 lines
drivers/xen/platform-pci.c +1 -2
 {
 	return pci_register_driver(&platform_driver);
 }
-
-module_init(platform_pci_module_init);
+device_initcall(platform_pci_xen_init);
Signature · 1 line
2.6.1