[PATCH] Compile error for vt.c and Warnings for kernel/power/console.c

From: Mahendra M
Date: Fri Dec 26 2003 - 02:32:27 EST


Hi all,

While compiling the kernel ( 2.6.0 ), I noticed this piece of code that
lead to a compile time error.

For the following config : ( make bzImage )

CONFIG_VT=y
# CONFIG_VT_CONSOLE is not set

Problem 1
---------
kernel/power/console.c:13: warning: `orig_fgconsole' defined but not used
kernel/power/console.c:13: warning: `orig_kmsg' defined but not used

Issue : orig_fgconsole and orig_kmsg are used only if SUSPEND_CONSOLE is
defined. SUSPEND_CONSOLE is defined only for
#if defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)

To fix this, the change can be made as follows :
#ifdef SUSPEND_CONSOLE
static int orig_fgconsole, orig_kmsg;
#endif

Problem 2 ( This is the same as my earlier problem )
----------------------------------------------------
drivers/char/vt.c: In function `vty_init':
drivers/char/vt.c:2542: `console_driver' undeclared (first use in this
function)drivers/char/vt.c:2542: (Each undeclared identifier is reported
only once
drivers/char/vt.c:2542: for each function it appears in.)
make[2]: *** [drivers/char/vt.o] Error 1

This is because of the following -

# ifdef drivers/char/vt.c 2188
2089 #ifdef CONFIG_VT_CONSOLE
2188 |struct tty_driver *console_driver;

# ifdef drivers/char/vt.c 2540
2540 int __init vty_init(void)

A fix for this would be to have the declaration of console_driver out of
the scope of #ifdef CONFIG_VT_CONSOLE

Note : The problems don't appear if CONFIG_VT_CONSOLE=y.

Please find attached a patch for the same. I have compiled it for an
x86 and the problem disappears.

Regards,
Mahendra

--
-------------------------------------------------------------------------------
Mahendra M - Mahendra_M AT infosys DOT com / mm94 AT india DOT ascend DOT com
Infosys Technologies Ltd, Bangalore.
-------------------------------------------------------------------------------

diff -urN -X /root/dontdiff linux-2.6.0/drivers/char/vt.c linux-2.6.0-my/drivers/char/vt.c
--- linux-2.6.0/drivers/char/vt.c 2003-12-24 09:50:55.000000000 +0530
+++ linux-2.6.0-my/drivers/char/vt.c 2003-12-24 09:52:01.000000000 +0530
@@ -2086,6 +2086,8 @@
schedule_console_callback();
}

+struct tty_driver *console_driver;
+
#ifdef CONFIG_VT_CONSOLE

/*
@@ -2185,8 +2187,6 @@
clear_bit(0, &printing);
}

-struct tty_driver *console_driver;
-
static struct tty_driver *vt_console_device(struct console *c, int *index)
{
*index = c->index ? c->index-1 : fg_console;
diff -urN -X /root/dontdiff linux-2.6.0/kernel/power/console.c linux-2.6.0-my/kernel/power/console.c
--- linux-2.6.0/kernel/power/console.c 2003-12-24 09:43:46.000000000 +0530
+++ linux-2.6.0-my/kernel/power/console.c 2003-12-24 09:52:13.000000000 +0530
@@ -10,7 +10,10 @@

static int new_loglevel = 10;
static int orig_loglevel;
+
+#ifdef SUSPEND_CONSOLE
static int orig_fgconsole, orig_kmsg;
+#endif

int pm_prepare_console(void)
{