aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/hvc
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2012-03-14 03:37:04 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2012-03-15 18:28:15 -0400
commit7d3d897a4697e4ff746e5e82f116b2346ed28150 (patch)
tree740b5a83f9d354edf255f44a6072a47ec1ff7ba0 /drivers/tty/hvc
parentba7a4822b48fbc7afd6b567c18e316a03f46684d (diff)
powerpc/hvc_udbg: Don't crash when udbg_putc is NULL
Also while at it, add some help text indicating why you shouldn't enable that driver under normal circumstances Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'drivers/tty/hvc')
-rw-r--r--drivers/tty/hvc/Kconfig4
-rw-r--r--drivers/tty/hvc/hvc_udbg.c8
2 files changed, 11 insertions, 1 deletions
diff --git a/drivers/tty/hvc/Kconfig b/drivers/tty/hvc/Kconfig
index 8ea7f078b233..48cb8d3d1758 100644
--- a/drivers/tty/hvc/Kconfig
+++ b/drivers/tty/hvc/Kconfig
@@ -71,6 +71,10 @@ config HVC_UDBG
71 depends on PPC && EXPERIMENTAL 71 depends on PPC && EXPERIMENTAL
72 select HVC_DRIVER 72 select HVC_DRIVER
73 default n 73 default n
74 help
75 This is meant to be used during HW bring up or debugging when
76 no other console mechanism exist but udbg, to get you a quick
77 console for userspace. Do NOT enable in production kernels.
74 78
75config HVC_DCC 79config HVC_DCC
76 bool "ARM JTAG DCC console" 80 bool "ARM JTAG DCC console"
diff --git a/drivers/tty/hvc/hvc_udbg.c b/drivers/tty/hvc/hvc_udbg.c
index b0957e61a7be..2259c6e72f06 100644
--- a/drivers/tty/hvc/hvc_udbg.c
+++ b/drivers/tty/hvc/hvc_udbg.c
@@ -36,7 +36,7 @@ static int hvc_udbg_put(uint32_t vtermno, const char *buf, int count)
36{ 36{
37 int i; 37 int i;
38 38
39 for (i = 0; i < count; i++) 39 for (i = 0; i < count && udbg_putc; i++)
40 udbg_putc(buf[i]); 40 udbg_putc(buf[i]);
41 41
42 return i; 42 return i;
@@ -67,6 +67,9 @@ static int __init hvc_udbg_init(void)
67{ 67{
68 struct hvc_struct *hp; 68 struct hvc_struct *hp;
69 69
70 if (!udbg_putc)
71 return -ENODEV;
72
70 BUG_ON(hvc_udbg_dev); 73 BUG_ON(hvc_udbg_dev);
71 74
72 hp = hvc_alloc(0, NO_IRQ, &hvc_udbg_ops, 16); 75 hp = hvc_alloc(0, NO_IRQ, &hvc_udbg_ops, 16);
@@ -88,6 +91,9 @@ module_exit(hvc_udbg_exit);
88 91
89static int __init hvc_udbg_console_init(void) 92static int __init hvc_udbg_console_init(void)
90{ 93{
94 if (!udbg_putc)
95 return -ENODEV;
96
91 hvc_instantiate(0, 0, &hvc_udbg_ops); 97 hvc_instantiate(0, 0, &hvc_udbg_ops);
92 add_preferred_console("hvc", 0, NULL); 98 add_preferred_console("hvc", 0, NULL);
93 99