LCOV - code coverage report
Current view: top level - arch/um/drivers - stderr_console.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 6 14 42.9 %
Date: 2023-03-27 20:00:47 Functions: 2 4 50.0 %

          Line data    Source code
       1             : // SPDX-License-Identifier: GPL-2.0
       2             : #include <linux/kernel.h>
       3             : #include <linux/init.h>
       4             : #include <linux/console.h>
       5             : 
       6             : #include "chan_user.h"
       7             : 
       8             : /* ----------------------------------------------------------------------------- */
       9             : /* trivial console driver -- simply dump everything to stderr                    */
      10             : 
      11             : /*
      12             :  * Don't register by default -- as this registers very early in the
      13             :  * boot process it becomes the default console.
      14             :  *
      15             :  * Initialized at init time.
      16             :  */
      17             : static int use_stderr_console = 0;
      18             : 
      19           0 : static void stderr_console_write(struct console *console, const char *string,
      20             :                                  unsigned len)
      21             : {
      22           0 :         generic_write(2 /* stderr */, string, len, NULL);
      23           0 : }
      24             : 
      25             : static struct console stderr_console = {
      26             :         .name           = "stderr",
      27             :         .write          = stderr_console_write,
      28             :         .flags          = CON_PRINTBUFFER,
      29             : };
      30             : 
      31           1 : static int __init stderr_console_init(void)
      32             : {
      33           1 :         if (use_stderr_console)
      34           0 :                 register_console(&stderr_console);
      35           1 :         return 0;
      36             : }
      37             : console_initcall(stderr_console_init);
      38             : 
      39           0 : static int stderr_setup(char *str)
      40             : {
      41           0 :         if (!str)
      42             :                 return 0;
      43           0 :         use_stderr_console = simple_strtoul(str,&str,0);
      44           0 :         return 1;
      45             : }
      46             : __setup("stderr=", stderr_setup);
      47             : 
      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.
      55             :  */
      56           1 : static int __init unregister_stderr(void)
      57             : {
      58           1 :         unregister_console(&stderr_console);
      59             : 
      60           1 :         return 0;
      61             : }
      62             : 
      63             : __initcall(unregister_stderr);

Generated by: LCOV version 1.14