mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Magnus Damm <damm@opensource.se>
To: linux-kernel@vger.kernel.org
Cc: Magnus Damm <damm@opensource.se>
Subject: [PATCH][RFC] disable built-in modules V2
Date: Wed,  6 Apr 2005 01:29:19 +0200 (CEST)	[thread overview]
Message-ID: <20050405225747.15125.8087.59570@clementine.local> (raw)

Here comes version 2 of the disable built-in patch.

This patch makes it possible to disable built-in code from the kernel
command line. The patch is rather simple - it extends the compiled-in case 
of module_init() to include __setup() with a name based on KBUILD_MODNAME.

As an example, if you want to disable built-in firewire support then you
could pass "force_ohci1394=off" on the kernel command line. The feature added
by this patch comes handy when you want to boot a precompiled kernel from a 
live cd on som exotic hardware that makes built-in drivers crash.

Changes since last release:
- Upgraded and tested with 2.6.12-rc2
- Added "force_"-prefix to cope with namespace pollution

Signed-off-by: Magnus Damm <damm@opensource.se>

diff -urNp linux-2.6.12-rc2/include/linux/init.h linux-2.6.12-rc2-disable_builtin/include/linux/init.h
--- linux-2.6.12-rc2/include/linux/init.h	2005-04-05 16:57:29.000000000 +0200
+++ linux-2.6.12-rc2-disable_builtin/include/linux/init.h	2005-04-06 00:26:07.000000000 +0200
@@ -143,6 +143,16 @@ struct obs_kernel_param {
 
 /* Relies on saved_command_line being set */
 void __init parse_early_param(void);
+
+void __init disable_initcall(void *fn);
+#define __module_init_disable(x)				\
+static int __init x##_disable_module(char *str)			\
+{								\
+	disable_initcall(x);					\
+	return 1;						\
+}								\
+__setup("force_" __stringify(KBUILD_MODNAME) "=off", x##_disable_module)
+
 #endif /* __ASSEMBLY__ */
 
 /**
@@ -153,7 +163,7 @@ void __init parse_early_param(void);
  * builtin) or at module insertion time (if a module).  There can only
  * be one per module.
  */
-#define module_init(x)	__initcall(x);
+#define module_init(x)	__initcall(x); __module_init_disable(x);  
 
 /**
  * module_exit() - driver exit entry point
diff -urNp linux-2.6.12-rc2/init/main.c linux-2.6.12-rc2-disable_builtin/init/main.c
--- linux-2.6.12-rc2/init/main.c	2005-04-05 16:59:55.000000000 +0200
+++ linux-2.6.12-rc2-disable_builtin/init/main.c	2005-04-05 21:07:05.000000000 +0200
@@ -539,6 +539,17 @@ struct task_struct *child_reaper = &init
 
 extern initcall_t __initcall_start[], __initcall_end[];
 
+void __init disable_initcall(void *fn)
+{
+	initcall_t *call;
+
+	for (call = __initcall_start; call < __initcall_end; call++) {
+
+		if (*call == fn)
+			*call = NULL;
+	}
+}
+
 static void __init do_initcalls(void)
 {
 	initcall_t *call;
@@ -553,7 +564,8 @@ static void __init do_initcalls(void)
 			printk("\n");
 		}
 
-		(*call)();
+		if (*call)
+			(*call)();
 
 		msg = NULL;
 		if (preempt_count() != count) {

             reply	other threads:[~2005-04-05 23:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-05 23:29 Magnus Damm [this message]
2005-04-06 10:32 ` Malcolm Rowe
2005-04-06 13:10   ` Magnus Damm
2005-04-06 14:28     ` Malcolm Rowe
2005-04-06 22:14       ` Magnus Damm
2005-04-07  7:47         ` Zwane Mwaikambo
2005-04-07  1:32 ` AsterixTheGaul
2005-04-07  2:23   ` Roland Dreier
2005-04-07  8:23     ` Magnus Damm
2005-04-07 17:01       ` Randy.Dunlap
2005-04-07 17:22         ` Richard B. Johnson
2005-04-07 17:29           ` Randy.Dunlap
2005-04-07 18:53             ` Magnus Damm
2005-04-09  1:42               ` Herbert Xu
2005-04-09  9:43                 ` Magnus Damm
2005-04-09  9:48                   ` Herbert Xu
2005-04-09 10:03                     ` Magnus Damm
2005-04-09 10:07                       ` Herbert Xu
2005-04-09 10:14                         ` Magnus Damm
2005-04-07 17:37           ` Dave Jones
2005-04-07  2:38   ` Horst von Brand
2005-04-07 21:33     ` Magnus Damm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050405225747.15125.8087.59570@clementine.local \
    --to=damm@opensource.se \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®