Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / kernel / power / console.c
blob7ff375e7c95f3cf24ab52adf62a688849684e05f
1 /*
2 * drivers/power/process.c - Functions for saving/restoring console.
4 * Originally from swsusp.
5 */
7 #include <linux/vt_kern.h>
8 #include <linux/kbd_kern.h>
9 #include <linux/console.h>
10 #include "power.h"
12 static int new_loglevel = 10;
13 static int orig_loglevel;
14 #ifdef SUSPEND_CONSOLE
15 static int orig_fgconsole, orig_kmsg;
16 #endif
18 int pm_prepare_console(void)
20 orig_loglevel = console_loglevel;
21 console_loglevel = new_loglevel;
23 #ifdef SUSPEND_CONSOLE
24 acquire_console_sem();
26 orig_fgconsole = fg_console;
28 if (vc_allocate(SUSPEND_CONSOLE)) {
29 /* we can't have a free VC for now. Too bad,
30 * we don't want to mess the screen for now. */
31 release_console_sem();
32 return 1;
35 set_console(SUSPEND_CONSOLE);
36 release_console_sem();
38 if (vt_waitactive(SUSPEND_CONSOLE)) {
39 pr_debug("Suspend: Can't switch VCs.");
40 return 1;
42 orig_kmsg = kmsg_redirect;
43 kmsg_redirect = SUSPEND_CONSOLE;
44 #endif
45 return 0;
48 void pm_restore_console(void)
50 console_loglevel = orig_loglevel;
51 #ifdef SUSPEND_CONSOLE
52 acquire_console_sem();
53 set_console(orig_fgconsole);
54 release_console_sem();
55 kmsg_redirect = orig_kmsg;
56 #endif
57 return;