Skip to content

Commit a19d0c6

Browse files
peterhurleygregkh
authored andcommitted
n_tty: Split n_tty_chars_in_buffer() for reader-only interface
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 <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 32f1352 commit a19d0c6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/tty/n_tty.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static void n_tty_flush_buffer(struct tty_struct *tty)
277277
* Locking: read_lock
278278
*/
279279

280-
static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)
280+
static ssize_t chars_in_buffer(struct tty_struct *tty)
281281
{
282282
struct n_tty_data *ldata = tty->disc_data;
283283
unsigned long flags;
@@ -295,6 +295,11 @@ static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)
295295
return n;
296296
}
297297

298+
static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)
299+
{
300+
return chars_in_buffer(tty);
301+
}
302+
298303
/**
299304
* is_utf8_continuation - utf8 multibyte check
300305
* @c: byte to check
@@ -2032,15 +2037,15 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
20322037
}
20332038

20342039
/* If there is enough space in the read buffer now, let the
2035-
* low-level driver know. We use n_tty_chars_in_buffer() to
2040+
* low-level driver know. We use chars_in_buffer() to
20362041
* check the buffer, as it now knows about canonical mode.
20372042
* Otherwise, if the driver is throttled and the line is
20382043
* longer than TTY_THRESHOLD_UNTHROTTLE in canonical mode,
20392044
* we won't get any more characters.
20402045
*/
20412046
while (1) {
20422047
tty_set_flow_change(tty, TTY_UNTHROTTLE_SAFE);
2043-
if (n_tty_chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE)
2048+
if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE)
20442049
break;
20452050
if (!tty->count)
20462051
break;

0 commit comments

Comments
 (0)