@@ -98,7 +98,6 @@ struct n_tty_data {
98
98
char * read_buf ;
99
99
size_t read_head ;
100
100
size_t read_tail ;
101
- int read_cnt ;
102
101
int minimum_to_wake ;
103
102
104
103
unsigned char * echo_buf ;
@@ -117,7 +116,7 @@ struct n_tty_data {
117
116
118
117
static inline size_t read_cnt (struct n_tty_data * ldata )
119
118
{
120
- return ldata -> read_cnt ;
119
+ return ldata -> read_head - ldata -> read_tail ;
121
120
}
122
121
123
122
static inline unsigned char read_buf (struct n_tty_data * ldata , size_t i )
@@ -198,7 +197,6 @@ static void put_tty_queue_nolock(unsigned char c, struct n_tty_data *ldata)
198
197
if (read_cnt (ldata ) < N_TTY_BUF_SIZE ) {
199
198
* read_buf_addr (ldata , ldata -> read_head ) = c ;
200
199
ldata -> read_head ++ ;
201
- ldata -> read_cnt ++ ;
202
200
}
203
201
}
204
202
@@ -239,7 +237,7 @@ static void reset_buffer_flags(struct n_tty_data *ldata)
239
237
unsigned long flags ;
240
238
241
239
raw_spin_lock_irqsave (& ldata -> read_lock , flags );
242
- ldata -> read_head = ldata -> read_tail = ldata -> read_cnt = 0 ;
240
+ ldata -> read_head = ldata -> read_tail = 0 ;
243
241
raw_spin_unlock_irqrestore (& ldata -> read_lock , flags );
244
242
245
243
mutex_lock (& ldata -> echo_lock );
@@ -942,16 +940,12 @@ static void eraser(unsigned char c, struct tty_struct *tty)
942
940
else {
943
941
if (!L_ECHO (tty )) {
944
942
raw_spin_lock_irqsave (& ldata -> read_lock , flags );
945
- ldata -> read_cnt -= ((ldata -> read_head - ldata -> canon_head ) &
946
- (N_TTY_BUF_SIZE - 1 ));
947
943
ldata -> read_head = ldata -> canon_head ;
948
944
raw_spin_unlock_irqrestore (& ldata -> read_lock , flags );
949
945
return ;
950
946
}
951
947
if (!L_ECHOK (tty ) || !L_ECHOKE (tty ) || !L_ECHOE (tty )) {
952
948
raw_spin_lock_irqsave (& ldata -> read_lock , flags );
953
- ldata -> read_cnt -= ((ldata -> read_head - ldata -> canon_head ) &
954
- (N_TTY_BUF_SIZE - 1 ));
955
949
ldata -> read_head = ldata -> canon_head ;
956
950
raw_spin_unlock_irqrestore (& ldata -> read_lock , flags );
957
951
finish_erasing (ldata );
@@ -989,7 +983,6 @@ static void eraser(unsigned char c, struct tty_struct *tty)
989
983
cnt = ldata -> read_head - head ;
990
984
raw_spin_lock_irqsave (& ldata -> read_lock , flags );
991
985
ldata -> read_head = head ;
992
- ldata -> read_cnt -= cnt ;
993
986
raw_spin_unlock_irqrestore (& ldata -> read_lock , flags );
994
987
if (L_ECHO (tty )) {
995
988
if (L_ECHOPRT (tty )) {
@@ -1448,7 +1441,6 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
1448
1441
i = min (count , i );
1449
1442
memcpy (read_buf_addr (ldata , ldata -> read_head ), cp , i );
1450
1443
ldata -> read_head += i ;
1451
- ldata -> read_cnt += i ;
1452
1444
cp += i ;
1453
1445
count -= i ;
1454
1446
@@ -1457,7 +1449,6 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
1457
1449
i = min (count , i );
1458
1450
memcpy (read_buf_addr (ldata , ldata -> read_head ), cp , i );
1459
1451
ldata -> read_head += i ;
1460
- ldata -> read_cnt += i ;
1461
1452
raw_spin_unlock_irqrestore (& ldata -> read_lock , cpuflags );
1462
1453
} else {
1463
1454
for (i = count , p = cp , f = fp ; i ; i -- , p ++ ) {
@@ -1762,7 +1753,6 @@ static int copy_from_read_buf(struct tty_struct *tty,
1762
1753
ldata -> icanon );
1763
1754
raw_spin_lock_irqsave (& ldata -> read_lock , flags );
1764
1755
ldata -> read_tail += n ;
1765
- ldata -> read_cnt -= n ;
1766
1756
/* Turn single EOF into zero-length read */
1767
1757
if (L_EXTPROC (tty ) && ldata -> icanon && is_eof && !read_cnt (ldata ))
1768
1758
n = 0 ;
@@ -1850,7 +1840,6 @@ static int canon_copy_from_read_buf(struct tty_struct *tty,
1850
1840
1851
1841
raw_spin_lock_irqsave (& ldata -> read_lock , flags );
1852
1842
ldata -> read_tail += c ;
1853
- ldata -> read_cnt -= c ;
1854
1843
if (found ) {
1855
1844
__clear_bit (eol , ldata -> read_flags );
1856
1845
/* this test should be redundant:
0 commit comments