aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power/console.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /kernel/power/console.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'kernel/power/console.c')
-rw-r--r--kernel/power/console.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/kernel/power/console.c b/kernel/power/console.c
new file mode 100644
index 000000000000..7ff375e7c95f
--- /dev/null
+++ b/kernel/power/console.c
@@ -0,0 +1,58 @@
1/*
2 * drivers/power/process.c - Functions for saving/restoring console.
3 *
4 * Originally from swsusp.
5 */
6
7#include <linux/vt_kern.h>
8#include <linux/kbd_kern.h>
9#include <linux/console.h>
10#include "power.h"
11
12static int new_loglevel = 10;
13static int orig_loglevel;
14#ifdef SUSPEND_CONSOLE
15static int orig_fgconsole, orig_kmsg;
16#endif
17
18int pm_prepare_console(void)
19{
20 orig_loglevel = console_loglevel;
21 console_loglevel = new_loglevel;
22
23#ifdef SUSPEND_CONSOLE
24 acquire_console_sem();
25
26 orig_fgconsole = fg_console;
27
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;
33 }
34
35 set_console(SUSPEND_CONSOLE);
36 release_console_sem();
37
38 if (vt_waitactive(SUSPEND_CONSOLE)) {
39 pr_debug("Suspend: Can't switch VCs.");
40 return 1;
41 }
42 orig_kmsg = kmsg_redirect;
43 kmsg_redirect = SUSPEND_CONSOLE;
44#endif
45 return 0;
46}
47
48void pm_restore_console(void)
49{
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;
58}