Merge branch 'fix/cxt-stable' into fix/hda
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / kernel / power / console.c
CommitLineData
1da177e4 1/*
37cce26b 2 * Functions for saving/restoring console.
1da177e4
LT
3 *
4 * Originally from swsusp.
5 */
6
7#include <linux/vt_kern.h>
8#include <linux/kbd_kern.h>
5ada918b 9#include <linux/vt.h>
b6f448e9 10#include <linux/module.h>
1da177e4
LT
11#include "power.h"
12
46cd2f32
RW
13#define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)
14
1da177e4 15static int orig_fgconsole, orig_kmsg;
1da177e4
LT
16
17int pm_prepare_console(void)
18{
8d233558
AC
19 orig_fgconsole = vt_move_to_console(SUSPEND_CONSOLE, 1);
20 if (orig_fgconsole < 0)
1da177e4 21 return 1;
1da177e4 22
5ada918b 23 orig_kmsg = vt_kmsg_redirect(SUSPEND_CONSOLE);
1da177e4
LT
24 return 0;
25}
26
27void pm_restore_console(void)
28{
8d233558
AC
29 if (orig_fgconsole >= 0) {
30 vt_move_to_console(orig_fgconsole, 0);
5ada918b 31 vt_kmsg_redirect(orig_kmsg);
b090f9fa 32 }
1da177e4 33}