Merge git://git.infradead.org/battery-2.6
[pandora-kernel.git] / arch / sh / kernel / early_printk.c
index 6034082..9833493 100644 (file)
@@ -106,12 +106,32 @@ static struct console scif_console = {
 };
 
 #if defined(CONFIG_CPU_SH4) && !defined(CONFIG_SH_STANDARD_BIOS)
+#define DEFAULT_BAUD 115200
 /*
  * Simple SCIF init, primarily aimed at SH7750 and other similar SH-4
  * devices that aren't using sh-ipl+g.
  */
-static void scif_sercon_init(int baud)
+static void scif_sercon_init(char *s)
 {
+       unsigned baud = DEFAULT_BAUD;
+       char *e;
+
+       if (*s == ',')
+               ++s;
+
+       if (*s) {
+               /* ignore ioport/device name */
+               s += strcspn(s, ",");
+               if (*s == ',')
+                       s++;
+       }
+
+       if (*s) {
+               baud = simple_strtoul(s, &e, 0);
+               if (baud == 0 || s == e)
+                       baud = DEFAULT_BAUD;
+       }
+
        ctrl_outw(0, scif_port.mapbase + 8);
        ctrl_outw(0, scif_port.mapbase);
 
@@ -144,16 +164,16 @@ static struct console *early_console =
        ;
 
 static int __initdata keep_early;
+static int early_console_initialized;
 
-int __init setup_early_printk(char *opt)
+int __init setup_early_printk(char *buf)
 {
-       char *space;
-       char buf[256];
+       if (!buf)
+               return 0;
 
-       strlcpy(buf, opt, sizeof(buf));
-       space = strchr(buf, ' ');
-       if (space)
-               *space = 0;
+       if (early_console_initialized)
+               return 0;
+       early_console_initialized = 1;
 
        if (strstr(buf, "keep"))
                keep_early = 1;
@@ -167,23 +187,19 @@ int __init setup_early_printk(char *opt)
                early_console = &scif_console;
 
 #if defined(CONFIG_CPU_SH4) && !defined(CONFIG_SH_STANDARD_BIOS)
-               scif_sercon_init(115200);
+               scif_sercon_init(buf + 6);
 #endif
        }
 #endif
 
-       if (likely(early_console))
+       if (likely(early_console)) {
+               if (keep_early)
+                       early_console->flags &= ~CON_BOOT;
+               else
+                       early_console->flags |= CON_BOOT;
                register_console(early_console);
+       }
 
-       return 1;
-}
-__setup("earlyprintk=", setup_early_printk);
-
-void __init disable_early_printk(void)
-{
-       if (!keep_early) {
-               printk("disabling early console\n");
-               unregister_console(early_console);
-       } else
-               printk("keeping early console\n");
+       return 0;
 }
+early_param("earlyprintk", setup_early_printk);