n_tty: Split n_tty_chars_in_buffer() for reader-only interface
authorPeter Hurley <peter@hurleysoftware.com>
Sat, 15 Jun 2013 13:14:18 +0000 (09:14 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Jul 2013 23:43:00 +0000 (16:43 -0700)
N_TTY .chars_in_buffer() method requires serialized access if
the current thread is not the single-consumer, n_tty_read().

Separate the internal interface; prepare for lockless read-side.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/n_tty.c

index 74dcedd06a8b5af0c7d00f699b2366fc9939a52b..594a3c19882b1d2b7af33092111b26b35dfe9b2f 100644 (file)
@@ -277,7 +277,7 @@ static void n_tty_flush_buffer(struct tty_struct *tty)
  *     Locking: read_lock
  */
 
-static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)
+static ssize_t chars_in_buffer(struct tty_struct *tty)
 {
        struct n_tty_data *ldata = tty->disc_data;
        unsigned long flags;
@@ -295,6 +295,11 @@ static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)
        return n;
 }
 
+static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)
+{
+       return chars_in_buffer(tty);
+}
+
 /**
  *     is_utf8_continuation    -       utf8 multibyte check
  *     @c: byte to check
@@ -2032,7 +2037,7 @@ do_it_again:
                }
 
                /* If there is enough space in the read buffer now, let the
-                * low-level driver know. We use n_tty_chars_in_buffer() to
+                * low-level driver know. We use chars_in_buffer() to
                 * check the buffer, as it now knows about canonical mode.
                 * Otherwise, if the driver is throttled and the line is
                 * longer than TTY_THRESHOLD_UNTHROTTLE in canonical mode,
@@ -2040,7 +2045,7 @@ do_it_again:
                 */
                while (1) {
                        tty_set_flow_change(tty, TTY_UNTHROTTLE_SAFE);
-                       if (n_tty_chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE)
+                       if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE)
                                break;
                        if (!tty->count)
                                break;