Merge branch 'perfcounters-fixes-for-linus' of git://git.kernel.org/pub/scm/linux...
[linux-block.git] / kernel / power / console.c
CommitLineData
1da177e4
LT
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>
b6f448e9 10#include <linux/module.h>
1da177e4
LT
11#include "power.h"
12
46cd2f32
RW
13#if defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
14#define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)
15
1da177e4 16static int orig_fgconsole, orig_kmsg;
1da177e4
LT
17
18int pm_prepare_console(void)
19{
8d233558
AC
20 orig_fgconsole = vt_move_to_console(SUSPEND_CONSOLE, 1);
21 if (orig_fgconsole < 0)
1da177e4 22 return 1;
1da177e4 23
1da177e4
LT
24 orig_kmsg = kmsg_redirect;
25 kmsg_redirect = SUSPEND_CONSOLE;
1da177e4
LT
26 return 0;
27}
28
29void pm_restore_console(void)
30{
8d233558
AC
31 if (orig_fgconsole >= 0) {
32 vt_move_to_console(orig_fgconsole, 0);
33 kmsg_redirect = orig_kmsg;
b090f9fa 34 }
1da177e4 35}
f7b8988f 36#endif