@@ -646,14 +646,14 @@ static ssize_t process_output_block(struct tty_struct *tty,
646
646
* Locking: callers must hold output_lock
647
647
*/
648
648
649
- static void __process_echoes (struct tty_struct * tty )
649
+ static size_t __process_echoes (struct tty_struct * tty )
650
650
{
651
651
struct n_tty_data * ldata = tty -> disc_data ;
652
- int space , nr ;
652
+ int space , old_space ;
653
653
size_t tail ;
654
654
unsigned char c ;
655
655
656
- space = tty_write_room (tty );
656
+ old_space = space = tty_write_room (tty );
657
657
658
658
tail = ldata -> echo_tail ;
659
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
787
ldata -> echo_tail = tail ;
788
+ return old_space - space ;
788
789
}
789
790
790
791
static void commit_echoes (struct tty_struct * tty )
791
792
{
792
793
struct n_tty_data * ldata = tty -> disc_data ;
793
- size_t nr , old ;
794
+ size_t nr , old , echoed ;
794
795
size_t head ;
795
796
796
797
head = ldata -> echo_head ;
@@ -805,25 +806,26 @@ static void commit_echoes(struct tty_struct *tty)
805
806
806
807
mutex_lock (& ldata -> output_lock );
807
808
ldata -> echo_commit = head ;
808
- __process_echoes (tty );
809
+ echoed = __process_echoes (tty );
809
810
mutex_unlock (& ldata -> output_lock );
810
811
811
- if (tty -> ops -> flush_chars )
812
+ if (echoed && tty -> ops -> flush_chars )
812
813
tty -> ops -> flush_chars (tty );
813
814
}
814
815
815
816
static void process_echoes (struct tty_struct * tty )
816
817
{
817
818
struct n_tty_data * ldata = tty -> disc_data ;
819
+ size_t echoed ;
818
820
819
821
if (!L_ECHO (tty ) || ldata -> echo_commit == ldata -> echo_tail )
820
822
return ;
821
823
822
824
mutex_lock (& ldata -> output_lock );
823
- __process_echoes (tty );
825
+ echoed = __process_echoes (tty );
824
826
mutex_unlock (& ldata -> output_lock );
825
827
826
- if (tty -> ops -> flush_chars )
828
+ if (echoed && tty -> ops -> flush_chars )
827
829
tty -> ops -> flush_chars (tty );
828
830
}
829
831
0 commit comments