USB: gadgetfs race fix
[linux-2.6.22.y-op.git] / arch / um / drivers / stderr_console.c
blob911539293871d271ed306c36fd1b113f6acc9203
1 #include <linux/init.h>
2 #include <linux/console.h>
4 #include "chan_user.h"
6 /* ----------------------------------------------------------------------------- */
7 /* trivial console driver -- simply dump everything to stderr */
9 /*
10 * Don't register by default -- as this registeres very early in the
11 * boot process it becomes the default console.
13 * Initialized at init time.
15 static int use_stderr_console = 0;
17 static void stderr_console_write(struct console *console, const char *string,
18 unsigned len)
20 generic_write(2 /* stderr */, string, len, NULL);
23 static struct console stderr_console = {
24 .name = "stderr",
25 .write = stderr_console_write,
26 .flags = CON_PRINTBUFFER,
29 static int __init stderr_console_init(void)
31 if (use_stderr_console)
32 register_console(&stderr_console);
33 return 0;
35 console_initcall(stderr_console_init);
37 static int stderr_setup(char *str)
39 if (!str)
40 return 0;
41 use_stderr_console = simple_strtoul(str,&str,0);
42 return 1;
44 __setup("stderr=", stderr_setup);
46 /* The previous behavior of not unregistering led to /dev/console being
47 * impossible to open. My FC5 filesystem started having init die, and the
48 * system panicing because of this. Unregistering causes the real
49 * console to become the default console, and /dev/console can then be
50 * opened. Making this an initcall makes this happen late enough that
51 * there is no added value in dumping everything to stderr, and the
52 * normal console is good enough to show you all available output.
54 static int __init unregister_stderr(void)
56 unregister_console(&stderr_console);
58 return 0;
61 __initcall(unregister_stderr);