Skip to contentSkip to conversation

Module rewrite 12/20: Old-style MODULE_PARM() support

PATCH New Rusty Russell 1 participant 1 message Sep 25, 2002 Module support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Module rewrite 12/20: Old-style MODULE_PARM() support

[ I wasn't going to do this, since MODULE_PARM (being un-typechecked)
is so frequently misused. But there are so many modules (compared with code which uses __setup) that it's probably a worthwhile bandaid ]

Name: MODULE_PARM support for older modules
Author: Rusty Russell
Status: Experimental
Depends: Module/param-modules.patch.gz
Depends: Module/param-setup_core.patch.gz

D: This is the backwards compatibility code for MODULE_PARM in case
D: they don't get converted before 2.6.0.

include/linux/module.h +13 -1
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .24314-linux-2.5.38/include/linux/module.h .24314-linux-2.5.38.updated/include/linux/module.h
@@ -14,6 +14,7 @@
 #include <linux/stat.h>
 #include <linux/compiler.h>
 #include <linux/bigref.h>
+#include <linux/stringify.h>
 #include <asm/module.h>
 
 /* Not Yet Implemented */
@@ -241,6 +242,17 @@ static inline int module_put(struct modu
 #define __MOD_DEC_USE_COUNT(mod) module_put(mod)
 #define SET_MODULE_OWNER(dev) ((dev)->owner = THIS_MODULE)
 
+struct obsolete_modparm { char name[64]; char type[64]; void *addr; };
+#ifdef MODULE
+/* DEPRECATED: Do not use. */
+#define MODULE_PARM(var,type)						    \
+struct obsolete_modparm __parm_##var __attribute__((section(".obsparm"))) = \
+{ __stringify(var), type };
+
+#else
+#define MODULE_PARM(var,type)
+#endif
+
 /* People do this inside their init routines, when the module isn't
    "live" yet.  They should no longer be doing that, but
    meanwhile... */
@@ -259,11 +271,11 @@ extern spinlock_t modlist_lock;
 #endif
 #define MOD_DEC_USE_COUNT module_put(THIS_MODULE)
 #define try_inc_mod_count(mod) try_module_get(mod)
-#define MODULE_PARM(parm,string)
 #define EXPORT_NO_SYMBOLS
 extern int module_dummy_usage;
 #define GET_USE_COUNT(module) (module_dummy_usage)
 #define MOD_IN_USE 0
+#define __MODULE_STRING(x) __stringify(x)
 #define __mod_between(a_start, a_len, b_start, b_len)		\
 (((a_start) >= (b_start) && (a_start) <= (b_start)+(b_len))	\
  || ((a_start)+(a_len) >= (b_start)				\
init/Config.help +5 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .24314-linux-2.5.38/init/Config.help .24314-linux-2.5.38.updated/init/Config.help
@@ -96,6 +96,11 @@ CONFIG_MODULE_UNLOAD
   that some modules may not be unloadable anyway).  This makes your
   kernel slightly smaller and simpler.  If unsure, say Y.
 
+CONFIG_OBSOLETE_MODPARM
+  Without this option you will not be able to use module parameters on
+  modules which have not been converted to the new module parameter
+  system yet.  If unsure, say Y.
+
 CONFIG_MODVERSIONS
   Usually, modules have to be recompiled whenever you switch to a new
   kernel.  Saying Y here makes it possible, and safe, to use the
init/Config.in +1 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .24314-linux-2.5.38/init/Config.in .24314-linux-2.5.38.updated/init/Config.in
@@ -16,4 +16,5 @@ comment 'Loadable module support'
 bool 'Enable loadable module support' CONFIG_MODULES
 dep_bool '  Kernel module loader' CONFIG_KMOD $CONFIG_MODULES
 dep_bool '  Module unloading' CONFIG_MODULE_UNLOAD $CONFIG_MODULES
+dep_bool '  Obsolete module parameters' CONFIG_OBSOLETE_MODPARM $CONFIG_MODULES
 endmenu
kernel/module.c +148 -9

193 lines not on this page · raw message

--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.