aboutsummaryrefslogtreecommitdiffstats
path: root/arch/tile/kernel
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2013-04-29 19:17:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 21:28:13 -0400
commitd0380e6c3c0f6edb986d8798a23acfaf33d5df23 (patch)
tree454ea23060995d2e1326962cedfd6e86a335629d /arch/tile/kernel
parent07c65f4d1aa74f7cf1c46d7f96e05cfa3e628ba1 (diff)
early_printk: consolidate random copies of identical code
The early console implementations are the same all over the place. Move the print function to kernel/printk and get rid of the copies. [akpm@linux-foundation.org: arch/mips/kernel/early_printk.c needs kernel.h for va_list] [paul.gortmaker@windriver.com: sh4: make the bios early console support depend on EARLY_PRINTK] Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> 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> Tested-by: Paul Gortmaker <paul.gortmaker@windriver.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/tile/kernel')
-rw-r--r--arch/tile/kernel/early_printk.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/arch/tile/kernel/early_printk.c b/arch/tile/kernel/early_printk.c
index afb9c9a0d887..34d72a151bf3 100644
--- a/arch/tile/kernel/early_printk.c
+++ b/arch/tile/kernel/early_printk.c
@@ -17,6 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/irqflags.h> 19#include <linux/irqflags.h>
20#include <linux/printk.h>
20#include <asm/setup.h> 21#include <asm/setup.h>
21#include <hv/hypervisor.h> 22#include <hv/hypervisor.h>
22 23
@@ -33,25 +34,8 @@ static struct console early_hv_console = {
33}; 34};
34 35
35/* Direct interface for emergencies */ 36/* Direct interface for emergencies */
36static struct console *early_console = &early_hv_console;
37static int early_console_initialized;
38static int early_console_complete; 37static int early_console_complete;
39 38
40static void early_vprintk(const char *fmt, va_list ap)
41{
42 char buf[512];
43 int n = vscnprintf(buf, sizeof(buf), fmt, ap);
44 early_console->write(early_console, buf, n);
45}
46
47void early_printk(const char *fmt, ...)
48{
49 va_list ap;
50 va_start(ap, fmt);
51 early_vprintk(fmt, ap);
52 va_end(ap);
53}
54
55void early_panic(const char *fmt, ...) 39void early_panic(const char *fmt, ...)
56{ 40{
57 va_list ap; 41 va_list ap;
@@ -69,14 +53,13 @@ static int __initdata keep_early;
69 53
70static int __init setup_early_printk(char *str) 54static int __init setup_early_printk(char *str)
71{ 55{
72 if (early_console_initialized) 56 if (early_console)
73 return 1; 57 return 1;
74 58
75 if (str != NULL && strncmp(str, "keep", 4) == 0) 59 if (str != NULL && strncmp(str, "keep", 4) == 0)
76 keep_early = 1; 60 keep_early = 1;
77 61
78 early_console = &early_hv_console; 62 early_console = &early_hv_console;
79 early_console_initialized = 1;
80 register_console(early_console); 63 register_console(early_console);
81 64
82 return 0; 65 return 0;
@@ -85,12 +68,12 @@ static int __init setup_early_printk(char *str)
85void __init disable_early_printk(void) 68void __init disable_early_printk(void)
86{ 69{
87 early_console_complete = 1; 70 early_console_complete = 1;
88 if (!early_console_initialized || !early_console) 71 if (!early_console)
89 return; 72 return;
90 if (!keep_early) { 73 if (!keep_early) {
91 early_printk("disabling early console\n"); 74 early_printk("disabling early console\n");
92 unregister_console(early_console); 75 unregister_console(early_console);
93 early_console_initialized = 0; 76 early_console = NULL;
94 } else { 77 } else {
95 early_printk("keeping early console\n"); 78 early_printk("keeping early console\n");
96 } 79 }
@@ -98,7 +81,7 @@ void __init disable_early_printk(void)
98 81
99void warn_early_printk(void) 82void warn_early_printk(void)
100{ 83{
101 if (early_console_complete || early_console_initialized) 84 if (early_console_complete || early_console)
102 return; 85 return;
103 early_printk("\ 86 early_printk("\
104Machine shutting down before console output is fully initialized.\n\ 87Machine shutting down before console output is fully initialized.\n\