Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-btrfs-devel.git] / arch / um / drivers / stderr_console.c
blobd07a97f8b9945343791d4fb32c9ad0bf5c7d9df2
1 #include <linux/kernel.h>
2 #include <linux/init.h>
3 #include <linux/console.h>
5 #include "chan_user.h"
7 /* ----------------------------------------------------------------------------- */
8 /* trivial console driver -- simply dump everything to stderr */
11 * Don't register by default -- as this registers very early in the
12 * boot process it becomes the default console.
14 * Initialized at init time.
16 static int use_stderr_console = 0;
18 static void stderr_console_write(struct console *console, const char *string,
19 unsigned len)
21 generic_write(2 /* stderr */, string, len, NULL);
24 static struct console stderr_console = {
25 .name = "stderr",
26 .write = stderr_console_write,
27 .flags = CON_PRINTBUFFER,
30 static int __init stderr_console_init(void)
32 if (use_stderr_console)
33 register_console(&stderr_console);
34 return 0;
36 console_initcall(stderr_console_init);
38 static int stderr_setup(char *str)
40 if (!str)
41 return 0;
42 use_stderr_console = simple_strtoul(str,&str,0);
43 return 1;
45 __setup("stderr=", stderr_setup);
47 /* The previous behavior of not unregistering led to /dev/console being
48 * impossible to open. My FC5 filesystem started having init die, and the
49 * system panicing because of this. Unregistering causes the real
50 * console to become the default console, and /dev/console can then be
51 * opened. Making this an initcall makes this happen late enough that
52 * there is no added value in dumping everything to stderr, and the
53 * normal console is good enough to show you all available output.
55 static int __init unregister_stderr(void)
57 unregister_console(&stderr_console);
59 return 0;
62 __initcall(unregister_stderr);