Commit bc5b1ec5 authored by Peter Hurley's avatar Peter Hurley Committed by Greg Kroah-Hartman

n_tty: Only flush echo output if actually output

Don't have the driver flush received echoes if no echoes were
actually output.
Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cbfd0340
...@@ -646,14 +646,14 @@ static ssize_t process_output_block(struct tty_struct *tty, ...@@ -646,14 +646,14 @@ static ssize_t process_output_block(struct tty_struct *tty,
* Locking: callers must hold output_lock * Locking: callers must hold output_lock
*/ */
static void __process_echoes(struct tty_struct *tty) static size_t __process_echoes(struct tty_struct *tty)
{ {
struct n_tty_data *ldata = tty->disc_data; struct n_tty_data *ldata = tty->disc_data;
int space, nr; int space, old_space;
size_t tail; size_t tail;
unsigned char c; unsigned char c;
space = tty_write_room(tty); old_space = space = tty_write_room(tty);
tail = ldata->echo_tail; tail = ldata->echo_tail;
nr = ldata->echo_commit - ldata->echo_tail; nr = ldata->echo_commit - ldata->echo_tail;
...@@ -785,12 +785,13 @@ static void __process_echoes(struct tty_struct *tty) ...@@ -785,12 +785,13 @@ static void __process_echoes(struct tty_struct *tty)
} }
ldata->echo_tail = tail; ldata->echo_tail = tail;
return old_space - space;
} }
static void commit_echoes(struct tty_struct *tty) static void commit_echoes(struct tty_struct *tty)
{ {
struct n_tty_data *ldata = tty->disc_data; struct n_tty_data *ldata = tty->disc_data;
size_t nr, old; size_t nr, old, echoed;
size_t head; size_t head;
head = ldata->echo_head; head = ldata->echo_head;
...@@ -805,25 +806,26 @@ static void commit_echoes(struct tty_struct *tty) ...@@ -805,25 +806,26 @@ static void commit_echoes(struct tty_struct *tty)
mutex_lock(&ldata->output_lock); mutex_lock(&ldata->output_lock);
ldata->echo_commit = head; ldata->echo_commit = head;
__process_echoes(tty); echoed = __process_echoes(tty);
mutex_unlock(&ldata->output_lock); mutex_unlock(&ldata->output_lock);
if (tty->ops->flush_chars) if (echoed && tty->ops->flush_chars)
tty->ops->flush_chars(tty); tty->ops->flush_chars(tty);
} }
static void process_echoes(struct tty_struct *tty) static void process_echoes(struct tty_struct *tty)
{ {
struct n_tty_data *ldata = tty->disc_data; struct n_tty_data *ldata = tty->disc_data;
size_t echoed;
if (!L_ECHO(tty) || ldata->echo_commit == ldata->echo_tail) if (!L_ECHO(tty) || ldata->echo_commit == ldata->echo_tail)
return; return;
mutex_lock(&ldata->output_lock); mutex_lock(&ldata->output_lock);
__process_echoes(tty); echoed = __process_echoes(tty);
mutex_unlock(&ldata->output_lock); mutex_unlock(&ldata->output_lock);
if (tty->ops->flush_chars) if (echoed && tty->ops->flush_chars)
tty->ops->flush_chars(tty); tty->ops->flush_chars(tty);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment