Skip to contentSkip to conversation

module_param() primitive (3/3)

PATCH New Rusty Russell 1 participant 1 message Dec 13, 2002 Module support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 module_param() primitive (3/3)

Linus, please apply.

This is the backwards compat wedge for MODULE_PARM() declarations.

It's complicated by the fact that many modules place MODULE_PARM() before the declaration (some do MODULE_PARM() for non-existant variables, too). To avoid breaking them, we have to do the name lookups at load time, rather than just storing a pointer 8(

CONFIG_OBSOLETE_MODPARM is set to y without prompting: it's a useful marker for deprecating in 2.7.

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

Name: MODULE_PARM support for older modules
Author: Rusty Russell
Status: Tested on 2.5.50
Depends: Module/param-modules.patch.gz

D: This is the backwards compatibility code for MODULE_PARM, and moves
D: __MODULE_STRING() down to the graveyard at the bottom of module.h.

include/linux/module.h +16 -5
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .3259-linux-2.5-bk/include/linux/module.h .3259-linux-2.5-bk.updated/include/linux/module.h
@@ -20,10 +21,6 @@
 #include <asm/module.h>
 #include <asm/uaccess.h> /* For struct exception_table_entry */
 
-/* Indirect stringification */
-#define __MODULE_STRING_1(x)	#x
-#define __MODULE_STRING(x)	__MODULE_STRING_1(x)
-
 /* Not Yet Implemented */
 #define MODULE_LICENSE(name)
 #define MODULE_AUTHOR(name)
@@ -291,6 +288,21 @@ extern spinlock_t modlist_lock;
 #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-sizeof(void *)];
+	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... */
@@ -303,11 +315,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/Kconfig +9 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .3259-linux-2.5-bk/init/Kconfig .3259-linux-2.5-bk.updated/init/Kconfig
@@ -135,6 +135,15 @@ config MODULE_FORCE_UNLOAD
 	  rmmod).  This is mainly for kernel developers and desparate users.
 	  If unsure, say N.
 
+config OBSOLETE_MODPARM
+	bool
+	default y
+	depends on MODULES
+	help
+	  You need this option to use module parameters on modules which
+	  have not been converted to the new module parameter system yet.
+	  If unsure, say Y.
+
 config KMOD
 	bool "Kernel module loader"
 	depends on MODULES
kernel/module.c +152 -9

191 lines not on this page · raw message