WIP FPC-III support
[linux/fpc-iii.git] / arch / um / drivers / stderr_console.c
blobecc3a58149324db4ec7dd02fa5a8eab0e3952a98
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/kernel.h>
3 #include <linux/init.h>
4 #include <linux/console.h>
6 #include "chan_user.h"
8 /* ----------------------------------------------------------------------------- */
9 /* trivial console driver -- simply dump everything to stderr */
12 * Don't register by default -- as this registers very early in the
13 * boot process it becomes the default console.
15 * Initialized at init time.
17 static int use_stderr_console = 0;
19 static void stderr_console_write(struct console *console, const char *string,
20 unsigned len)
22 generic_write(2 /* stderr */, string, len, NULL);
25 static struct console stderr_console = {
26 .name = "stderr",
27 .write = stderr_console_write,
28 .flags = CON_PRINTBUFFER,
31 static int __init stderr_console_init(void)
33 if (use_stderr_console)
34 register_console(&stderr_console);
35 return 0;
37 console_initcall(stderr_console_init);
39 static int stderr_setup(char *str)
41 if (!str)
42 return 0;
43 use_stderr_console = simple_strtoul(str,&str,0);
44 return 1;
46 __setup("stderr=", stderr_setup);
48 /* The previous behavior of not unregistering led to /dev/console being
49 * impossible to open. My FC5 filesystem started having init die, and the
50 * system panicing because of this. Unregistering causes the real
51 * console to become the default console, and /dev/console can then be
52 * opened. Making this an initcall makes this happen late enough that
53 * there is no added value in dumping everything to stderr, and the
54 * normal console is good enough to show you all available output.
56 static int __init unregister_stderr(void)
58 unregister_console(&stderr_console);
60 return 0;
63 __initcall(unregister_stderr);