]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
early_printk: consolidate random copies of identical code
authorThomas Gleixner <tglx@linutronix.de>
Wed, 20 Mar 2013 04:07:33 +0000 (15:07 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 20 Mar 2013 04:22:55 +0000 (15:22 +1100)
The early console implementations are the same all over the place.  Move
the print function to kernel/printk and get rid of the copies.

[v3: drop sparc bits as suggested by tglx, redo build tests on sparc
 sparc32, Randy's randconfig, ppc, mips, arm...]

[v2: essentially unchanged since v1, so I've left the acked/reviewed
 tags.  There was a compile fail[1] for a randconfig with EARLY_PRINTK=y
 and PRINTK=n, because the early_console struct and early_printk calls
 were nested within an #ifdef CONFIG_PRINTK -- moving that whole block
 exactly as-is to be outside the #ifdef CONFIG_PRINTK fixes the randconfig
 and still works for everyday sane configs too.]
 [1] http://marc.info/?l=linux-next&m=136219350914998&w=2

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <linux@arm.linux.org.uk>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Richard Weinberger <richard@nod.at>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
arch/sparc/kernel/setup_32.c
arch/sparc/kernel/setup_64.c
kernel/printk.c

index f4fb00e76d0e3abcb9a23f702a1f44a7181aba22..38bf80a22f02396704fbb0f69ccef74fd83d689b 100644 (file)
@@ -309,7 +309,6 @@ void __init setup_arch(char **cmdline_p)
 
        boot_flags_init(*cmdline_p);
 
-       early_console = &prom_early_console;
        register_console(&prom_early_console);
 
        printk("ARCH: ");
index d9c57e9ad454d03d11308bdb6fa9786c776110ad..88a127b9c69e8b1876a94b60db94456eca6fe5ef 100644 (file)
@@ -551,12 +551,6 @@ static void __init init_sparc64_elf_hwcap(void)
                pause_patch();
 }
 
-static inline void register_prom_console(void)
-{
-       early_console = &prom_early_console;
-       register_console(&prom_early_console);
-}
-
 void __init setup_arch(char **cmdline_p)
 {
        /* Initialize PROM console and command line. */
@@ -568,7 +562,7 @@ void __init setup_arch(char **cmdline_p)
 #ifdef CONFIG_EARLYFB
        if (btext_find_display())
 #endif
-               register_prom_console();
+               register_console(&prom_early_console);
 
        if (tlb_type == hypervisor)
                printk("ARCH: SUN4V\n");
index 50388f358f0c6daead43f4e1f46084ce65713c88..922942a2baa64189cf5d0bc015d5aa040d1a71bc 100644 (file)
@@ -758,29 +758,6 @@ module_param(ignore_loglevel, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(ignore_loglevel, "ignore loglevel setting, to"
        "print all kernel messages to the console.");
 
-#ifdef CONFIG_EARLY_PRINTK
-struct console *early_console;
-
-void early_vprintk(const char *fmt, va_list ap)
-{
-       if (early_console) {
-               char buf[512];
-               int n = vscnprintf(buf, sizeof(buf), fmt, ap);
-
-               early_console->write(early_console, buf, n);
-       }
-}
-
-asmlinkage void early_printk(const char *fmt, ...)
-{
-       va_list ap;
-
-       va_start(ap, fmt);
-       early_vprintk(fmt, ap);
-       va_end(ap);
-}
-#endif
-
 #ifdef CONFIG_BOOT_PRINTK_DELAY
 
 static int boot_delay; /* msecs delay after each printk during bootup */
@@ -1743,6 +1720,29 @@ static size_t cont_print_text(char *text, size_t size) { return 0; }
 
 #endif /* CONFIG_PRINTK */
 
+#ifdef CONFIG_EARLY_PRINTK
+struct console *early_console;
+
+void early_vprintk(const char *fmt, va_list ap)
+{
+       if (early_console) {
+               char buf[512];
+               int n = vscnprintf(buf, sizeof(buf), fmt, ap);
+
+               early_console->write(early_console, buf, n);
+       }
+}
+
+asmlinkage void early_printk(const char *fmt, ...)
+{
+       va_list ap;
+
+       va_start(ap, fmt);
+       early_vprintk(fmt, ap);
+       va_end(ap);
+}
+#endif
+
 static int __add_preferred_console(char *name, int idx, char *options,
                                   char *brl_options)
 {