summaryrefslogtreecommitdiff
path: root/drivers/tty/n_tty.c
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2013-06-15 18:04:27 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-24 04:02:22 +0400
commitbc5b1ec5860a9bf52842be4a3a9d96e19f06c11d (patch)
tree85a134a54a6c82f15ef3124d8ad6adf179ffd88b /drivers/tty/n_tty.c
parentcbfd0340ae1993378fd47179db949e050e16e697 (diff)
downloadlinux-bc5b1ec5860a9bf52842be4a3a9d96e19f06c11d.tar.xz
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: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/n_tty.c')
-rw-r--r--drivers/tty/n_tty.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 20983afb6086..59f3f10f37f3 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -646,14 +646,14 @@ break_out:
* 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;
- int space, nr;
+ int space, old_space;
size_t tail;
unsigned char c;
- space = tty_write_room(tty);
+ old_space = space = tty_write_room(tty);
tail = ldata->echo_tail;
nr = ldata->echo_commit - ldata->echo_tail;
@@ -785,12 +785,13 @@ static void __process_echoes(struct tty_struct *tty)
}
ldata->echo_tail = tail;
+ return old_space - space;
}
static void commit_echoes(struct tty_struct *tty)
{
struct n_tty_data *ldata = tty->disc_data;
- size_t nr, old;
+ size_t nr, old, echoed;
size_t head;
head = ldata->echo_head;
@@ -805,25 +806,26 @@ static void commit_echoes(struct tty_struct *tty)
mutex_lock(&ldata->output_lock);
ldata->echo_commit = head;
- __process_echoes(tty);
+ echoed = __process_echoes(tty);
mutex_unlock(&ldata->output_lock);
- if (tty->ops->flush_chars)
+ if (echoed && tty->ops->flush_chars)
tty->ops->flush_chars(tty);
}
static void process_echoes(struct tty_struct *tty)
{
struct n_tty_data *ldata = tty->disc_data;
+ size_t echoed;
if (!L_ECHO(tty) || ldata->echo_commit == ldata->echo_tail)
return;
mutex_lock(&ldata->output_lock);
- __process_echoes(tty);
+ echoed = __process_echoes(tty);
mutex_unlock(&ldata->output_lock);
- if (tty->ops->flush_chars)
+ if (echoed && tty->ops->flush_chars)
tty->ops->flush_chars(tty);
}