Merge remote-tracking branch 'lsk/v3.10/topic/gator' into linux-linaro-lsk
[firefly-linux-kernel-4.4.55.git] / drivers / tty / tty_io.c
index 59d26ef538d864e4396e8f76bd560b68908e8b13..3723c0ebb3161b6ae03560c44742a259de4f31eb 100644 (file)
@@ -1267,12 +1267,13 @@ static void pty_line_name(struct tty_driver *driver, int index, char *p)
  *
  *     Locking: None
  */
-static void tty_line_name(struct tty_driver *driver, int index, char *p)
+static ssize_t tty_line_name(struct tty_driver *driver, int index, char *p)
 {
        if (driver->flags & TTY_DRIVER_UNNUMBERED_NODE)
-               strcpy(p, driver->name);
+               return sprintf(p, "%s", driver->name);
        else
-               sprintf(p, "%s%d", driver->name, index + driver->name_base);
+               return sprintf(p, "%s%d", driver->name,
+                              index + driver->name_base);
 }
 
 /**
@@ -3538,9 +3539,19 @@ static ssize_t show_cons_active(struct device *dev,
                if (i >= ARRAY_SIZE(cs))
                        break;
        }
-       while (i--)
-               count += sprintf(buf + count, "%s%d%c",
-                                cs[i]->name, cs[i]->index, i ? ' ':'\n');
+       while (i--) {
+               int index = cs[i]->index;
+               struct tty_driver *drv = cs[i]->device(cs[i], &index);
+
+               /* don't resolve tty0 as some programs depend on it */
+               if (drv && (cs[i]->index > 0 || drv->major != TTY_MAJOR))
+                       count += tty_line_name(drv, index, buf + count);
+               else
+                       count += sprintf(buf + count, "%s%d",
+                                        cs[i]->name, cs[i]->index);
+
+               count += sprintf(buf + count, "%c", i ? ' ':'\n');
+       }
        console_unlock();
 
        return count;