USB: cp210x: add support for Corsair usb dongle
[pandora-kernel.git] / drivers / tty / tty_io.c
index 05085be..446df6b 100644 (file)
@@ -940,6 +940,14 @@ void start_tty(struct tty_struct *tty)
 
 EXPORT_SYMBOL(start_tty);
 
+/* We limit tty time update visibility to every 8 seconds or so. */
+static void tty_update_time(struct timespec *time)
+{
+       unsigned long sec = get_seconds() & ~7;
+       if ((long)(sec - time->tv_sec) > 0)
+               time->tv_sec = sec;
+}
+
 /**
  *     tty_read        -       read method for tty device files
  *     @file: pointer to tty file
@@ -976,8 +984,10 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
        else
                i = -EIO;
        tty_ldisc_deref(ld);
+
        if (i > 0)
-               inode->i_atime = current_fs_time(inode->i_sb);
+               tty_update_time(&inode->i_atime);
+
        return i;
 }
 
@@ -1079,8 +1089,8 @@ static inline ssize_t do_tty_write(
                cond_resched();
        }
        if (written) {
-               struct inode *inode = file->f_path.dentry->d_inode;
-               inode->i_mtime = current_fs_time(inode->i_sb);
+               struct inode *inode = file->f_path.dentry->d_inode;
+               tty_update_time(&inode->i_mtime);
                ret = written;
        }
 out:
@@ -1212,9 +1222,9 @@ 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)
 {
-       sprintf(p, "%s%d", driver->name, index + driver->name_base);
+       return sprintf(p, "%s%d", driver->name, index + driver->name_base);
 }
 
 /**
@@ -3311,9 +3321,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;