Skip to content

Commit

Permalink
n_tty: Split n_tty_chars_in_buffer() for reader-only interface
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Hurley authored and Greg Kroah-Hartman committed Jul 23, 2013
1 parent 32f1352 commit a19d0c6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/tty/n_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -2032,15 +2037,15 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
}

/* 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,
* we won't get any more characters.
*/
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;
Expand Down

0 comments on commit a19d0c6

Please sign in to comment.