Merge tag 'upstream-3.13-rc1' of git://git.infradead.org/linux-ubifs
[firefly-linux-kernel-4.4.55.git] / drivers / tty / hvc / hvc_udbg.c
index 4c9b13e7748c4d4263cd08a804e19831ba90896a..72228276fe314b36a1344a1ffef36263a4379c4c 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, 0, &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);