Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[sfrench/cifs-2.6.git] / kernel / printk.c
index 4b47e59248df00375ce5fda81e760f89e14f9a22..0bbdeac2810cb53c4960cb303f4b396d29cbb341 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/mm.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
-#include <linux/smp_lock.h>
 #include <linux/console.h>
 #include <linux/init.h>
 #include <linux/module.h>
@@ -931,8 +930,16 @@ void register_console(struct console *console)
 {
        int i;
        unsigned long flags;
+       struct console *bootconsole = NULL;
 
-       if (preferred_console < 0)
+       if (console_drivers) {
+               if (console->flags & CON_BOOT)
+                       return;
+               if (console_drivers->flags & CON_BOOT)
+                       bootconsole = console_drivers;
+       }
+
+       if (preferred_console < 0 || bootconsole || !console_drivers)
                preferred_console = selected_console;
 
        /*
@@ -978,8 +985,11 @@ void register_console(struct console *console)
        if (!(console->flags & CON_ENABLED))
                return;
 
-       if (console_drivers && (console_drivers->flags & CON_BOOT)) {
-               unregister_console(console_drivers);
+       if (bootconsole) {
+               printk(KERN_INFO "console handover: boot [%s%d] -> real [%s%d]\n",
+                      bootconsole->name, bootconsole->index,
+                      console->name, console->index);
+               unregister_console(bootconsole);
                console->flags &= ~CON_PRINTBUFFER;
        }
 
@@ -1030,16 +1040,11 @@ int unregister_console(struct console *console)
                }
        }
 
-       /* If last console is removed, we re-enable picking the first
-        * one that gets registered. Without that, pmac early boot console
-        * would prevent fbcon from taking over.
-        *
+       /*
         * If this isn't the last console and it has CON_CONSDEV set, we
         * need to set it on the next preferred console.
         */
-       if (console_drivers == NULL)
-               preferred_console = selected_console;
-       else if (console->flags & CON_CONSDEV)
+       if (console_drivers != NULL && console->flags & CON_CONSDEV)
                console_drivers->flags |= CON_CONSDEV;
 
        release_console_sem();