[PATCH] swsusp: fix suspend when console is in VT_AUTO+KD_GRAPHICS mode
[powerpc.git] / kernel / power / console.c
index 579d239..89bcf49 100644 (file)
@@ -9,7 +9,9 @@
 #include <linux/console.h>
 #include "power.h"
 
-#ifdef SUSPEND_CONSOLE
+#if defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
+#define SUSPEND_CONSOLE        (MAX_NR_CONSOLES-1)
+
 static int orig_fgconsole, orig_kmsg;
 
 int pm_prepare_console(void)
@@ -25,7 +27,15 @@ int pm_prepare_console(void)
                return 1;
        }
 
-       set_console(SUSPEND_CONSOLE);
+       if (set_console(SUSPEND_CONSOLE)) {
+               /*
+                * We're unable to switch to the SUSPEND_CONSOLE.
+                * Let the calling function know so it can decide
+                * what to do.
+                */
+               release_console_sem();
+               return 1;
+       }
        release_console_sem();
 
        if (vt_waitactive(SUSPEND_CONSOLE)) {