Merge git://oss.sgi.com:8090/xfs/xfs-2.6
[linux-2.6-block.git] / arch / um / drivers / stderr_console.c
CommitLineData
1da177e4
LT
1#include <linux/init.h>
2#include <linux/console.h>
3
4#include "chan_user.h"
5
6/* ----------------------------------------------------------------------------- */
7/* trivial console driver -- simply dump everything to stderr */
8
9/*
10 * Don't register by default -- as this registeres very early in the
6edb0862 11 * boot process it becomes the default console.
730760e9
JD
12 *
13 * Initialized at init time.
1da177e4
LT
14 */
15static int use_stderr_console = 0;
16
17static void stderr_console_write(struct console *console, const char *string,
18 unsigned len)
19{
20 generic_write(2 /* stderr */, string, len, NULL);
21}
22
23static struct console stderr_console = {
da00d9a5
JD
24 .name = "stderr",
25 .write = stderr_console_write,
26 .flags = CON_PRINTBUFFER,
1da177e4
LT
27};
28
29static int __init stderr_console_init(void)
30{
31 if (use_stderr_console)
32 register_console(&stderr_console);
33 return 0;
34}
35console_initcall(stderr_console_init);
36
37static int stderr_setup(char *str)
38{
39 if (!str)
40 return 0;
41 use_stderr_console = simple_strtoul(str,&str,0);
42 return 1;
43}
44__setup("stderr=", stderr_setup);
6edb0862
JD
45
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.
53 */
54static int __init unregister_stderr(void)
55{
56 unregister_console(&stderr_console);
57
58 return 0;
59}
60
61__initcall(unregister_stderr);