]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
powerpc/hvc_udbg: Don't crash when udbg_putc is NULL
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 14 Mar 2012 07:37:04 +0000 (18:37 +1100)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Thu, 15 Mar 2012 22:28:15 +0000 (09:28 +1100)
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>
drivers/tty/hvc/Kconfig
drivers/tty/hvc/hvc_udbg.c

index 8ea7f078b233d7518d331e4a99acd15702a410d5..48cb8d3d175878773b32c6d7cd3f0ef27fa077f0 100644 (file)
@@ -71,6 +71,10 @@ config HVC_UDBG
        depends on PPC && EXPERIMENTAL
        select HVC_DRIVER
        default n
+       help
+         This is meant to be used during HW bring up or debugging when
+        no other console mechanism exist but udbg, to get you a quick
+        console for userspace. Do NOT enable in production kernels. 
 
 config HVC_DCC
        bool "ARM JTAG DCC console"
index b0957e61a7befc015fb05adf587e32d48626edea..2259c6e72f062483fdb5f2e1cd80fd5e24b9744b 100644 (file)
@@ -36,7 +36,7 @@ static int hvc_udbg_put(uint32_t vtermno, const char *buf, int count)
 {
        int i;
 
-       for (i = 0; i < count; i++)
+       for (i = 0; i < count && udbg_putc; i++)
                udbg_putc(buf[i]);
 
        return i;
@@ -67,6 +67,9 @@ static int __init hvc_udbg_init(void)
 {
        struct hvc_struct *hp;
 
+       if (!udbg_putc)
+               return -ENODEV;
+
        BUG_ON(hvc_udbg_dev);
 
        hp = hvc_alloc(0, NO_IRQ, &hvc_udbg_ops, 16);
@@ -88,6 +91,9 @@ module_exit(hvc_udbg_exit);
 
 static int __init hvc_udbg_console_init(void)
 {
+       if (!udbg_putc)
+               return -ENODEV;
+
        hvc_instantiate(0, 0, &hvc_udbg_ops);
        add_preferred_console("hvc", 0, NULL);