aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/n_tty.c
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2013-06-15 10:04:27 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-23 20:02:22 -0400
commitbc5b1ec5860a9bf52842be4a3a9d96e19f06c11d (patch)
tree85a134a54a6c82f15ef3124d8ad6adf179ffd88b /drivers/tty/n_tty.c
parentcbfd0340ae1993378fd47179db949e050e16e697 (diff)
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:
646 * Locking: callers must hold output_lock 646 * Locking: callers must hold output_lock
647 */ 647 */
648 648
649static void __process_echoes(struct tty_struct *tty) 649static size_t __process_echoes(struct tty_struct *tty)
650{ 650{
651 struct n_tty_data *ldata = tty->disc_data; 651 struct n_tty_data *ldata = tty->disc_data;
652 int space, nr; 652 int space, old_space;
653 size_t tail; 653 size_t tail;
654 unsigned char c; 654 unsigned char c;
655 655
656 space = tty_write_room(tty); 656 old_space = space = tty_write_room(tty);
657 657
658 tail = ldata->echo_tail; 658 tail = ldata->echo_tail;
659 nr = ldata->echo_commit - ldata->echo_tail; 659 nr = ldata->echo_commit - ldata->echo_tail;
@@ -785,12 +785,13 @@ static void __process_echoes(struct tty_struct *tty)
785 } 785 }
786 786
787 ldata->echo_tail = tail; 787 ldata->echo_tail = tail;
788 return old_space - space;
788} 789}
789 790
790static void commit_echoes(struct tty_struct *tty) 791static void commit_echoes(struct tty_struct *tty)
791{ 792{
792 struct n_tty_data *ldata = tty->disc_data; 793 struct n_tty_data *ldata = tty->disc_data;
793 size_t nr, old; 794 size_t nr, old, echoed;
794 size_t head; 795 size_t head;
795 796
796 head = ldata->echo_head; 797 head = ldata->echo_head;
@@ -805,25 +806,26 @@ static void commit_echoes(struct tty_struct *tty)
805 806
806 mutex_lock(&ldata->output_lock); 807 mutex_lock(&ldata->output_lock);
807 ldata->echo_commit = head; 808 ldata->echo_commit = head;
808 __process_echoes(tty); 809 echoed = __process_echoes(tty);
809 mutex_unlock(&ldata->output_lock); 810 mutex_unlock(&ldata->output_lock);
810 811
811 if (tty->ops->flush_chars) 812 if (echoed && tty->ops->flush_chars)
812 tty->ops->flush_chars(tty); 813 tty->ops->flush_chars(tty);
813} 814}
814 815
815static void process_echoes(struct tty_struct *tty) 816static void process_echoes(struct tty_struct *tty)
816{ 817{
817 struct n_tty_data *ldata = tty->disc_data; 818 struct n_tty_data *ldata = tty->disc_data;
819 size_t echoed;
818 820
819 if (!L_ECHO(tty) || ldata->echo_commit == ldata->echo_tail) 821 if (!L_ECHO(tty) || ldata->echo_commit == ldata->echo_tail)
820 return; 822 return;
821 823
822 mutex_lock(&ldata->output_lock); 824 mutex_lock(&ldata->output_lock);
823 __process_echoes(tty); 825 echoed = __process_echoes(tty);
824 mutex_unlock(&ldata->output_lock); 826 mutex_unlock(&ldata->output_lock);
825 827
826 if (tty->ops->flush_chars) 828 if (echoed && tty->ops->flush_chars)
827 tty->ops->flush_chars(tty); 829 tty->ops->flush_chars(tty);
828} 830}
829 831