@@ -115,6 +115,11 @@ struct n_tty_data {
115
115
raw_spinlock_t read_lock ;
116
116
};
117
117
118
+ static inline size_t read_cnt (struct n_tty_data * ldata )
119
+ {
120
+ return ldata -> read_cnt ;
121
+ }
122
+
118
123
static inline int tty_put_user (struct tty_struct * tty , unsigned char x ,
119
124
unsigned char __user * ptr )
120
125
{
@@ -133,9 +138,9 @@ static int receive_room(struct tty_struct *tty)
133
138
/* Multiply read_cnt by 3, since each byte might take up to
134
139
* three times as many spaces when PARMRK is set (depending on
135
140
* its flags, e.g. parity error). */
136
- left = N_TTY_BUF_SIZE - ldata -> read_cnt * 3 - 1 ;
141
+ left = N_TTY_BUF_SIZE - read_cnt ( ldata ) * 3 - 1 ;
137
142
} else
138
- left = N_TTY_BUF_SIZE - ldata -> read_cnt - 1 ;
143
+ left = N_TTY_BUF_SIZE - read_cnt ( ldata ) - 1 ;
139
144
140
145
/*
141
146
* If we are doing input canonicalization, and there are no
@@ -180,7 +185,7 @@ static void n_tty_set_room(struct tty_struct *tty)
180
185
181
186
static void put_tty_queue_nolock (unsigned char c , struct n_tty_data * ldata )
182
187
{
183
- if (ldata -> read_cnt < N_TTY_BUF_SIZE ) {
188
+ if (read_cnt ( ldata ) < N_TTY_BUF_SIZE ) {
184
189
ldata -> read_buf [ldata -> read_head ] = c ;
185
190
ldata -> read_head = (ldata -> read_head + 1 ) & (N_TTY_BUF_SIZE - 1 );
186
191
ldata -> read_cnt ++ ;
@@ -285,7 +290,7 @@ static ssize_t chars_in_buffer(struct tty_struct *tty)
285
290
286
291
raw_spin_lock_irqsave (& ldata -> read_lock , flags );
287
292
if (!ldata -> icanon ) {
288
- n = ldata -> read_cnt ;
293
+ n = read_cnt ( ldata ) ;
289
294
} else if (ldata -> canon_data ) {
290
295
n = (ldata -> canon_head > ldata -> read_tail ) ?
291
296
ldata -> canon_head - ldata -> read_tail :
@@ -1204,7 +1209,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
1204
1209
if (!test_bit (c , ldata -> process_char_map ) || ldata -> lnext ) {
1205
1210
ldata -> lnext = 0 ;
1206
1211
parmrk = (c == (unsigned char ) '\377' && I_PARMRK (tty )) ? 1 : 0 ;
1207
- if (ldata -> read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1 )) {
1212
+ if (read_cnt ( ldata ) >= (N_TTY_BUF_SIZE - parmrk - 1 )) {
1208
1213
/* beep if no space */
1209
1214
if (L_ECHO (tty ))
1210
1215
process_output ('\a' , tty );
@@ -1304,7 +1309,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
1304
1309
return ;
1305
1310
}
1306
1311
if (c == '\n' ) {
1307
- if (ldata -> read_cnt >= N_TTY_BUF_SIZE ) {
1312
+ if (read_cnt ( ldata ) >= N_TTY_BUF_SIZE ) {
1308
1313
if (L_ECHO (tty ))
1309
1314
process_output ('\a' , tty );
1310
1315
return ;
@@ -1316,7 +1321,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
1316
1321
goto handle_newline ;
1317
1322
}
1318
1323
if (c == EOF_CHAR (tty )) {
1319
- if (ldata -> read_cnt >= N_TTY_BUF_SIZE )
1324
+ if (read_cnt ( ldata ) >= N_TTY_BUF_SIZE )
1320
1325
return ;
1321
1326
if (ldata -> canon_head != ldata -> read_head )
1322
1327
set_bit (TTY_PUSH , & tty -> flags );
@@ -1327,7 +1332,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
1327
1332
(c == EOL2_CHAR (tty ) && L_IEXTEN (tty ))) {
1328
1333
parmrk = (c == (unsigned char ) '\377' && I_PARMRK (tty ))
1329
1334
? 1 : 0 ;
1330
- if (ldata -> read_cnt >= (N_TTY_BUF_SIZE - parmrk )) {
1335
+ if (read_cnt ( ldata ) >= (N_TTY_BUF_SIZE - parmrk )) {
1331
1336
if (L_ECHO (tty ))
1332
1337
process_output ('\a' , tty );
1333
1338
return ;
@@ -1364,7 +1369,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
1364
1369
}
1365
1370
1366
1371
parmrk = (c == (unsigned char ) '\377' && I_PARMRK (tty )) ? 1 : 0 ;
1367
- if (ldata -> read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1 )) {
1372
+ if (read_cnt ( ldata ) >= (N_TTY_BUF_SIZE - parmrk - 1 )) {
1368
1373
/* beep if no space */
1369
1374
if (L_ECHO (tty ))
1370
1375
process_output ('\a' , tty );
@@ -1430,7 +1435,7 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
1430
1435
1431
1436
if (ldata -> real_raw ) {
1432
1437
raw_spin_lock_irqsave (& ldata -> read_lock , cpuflags );
1433
- i = min (N_TTY_BUF_SIZE - ldata -> read_cnt ,
1438
+ i = min (N_TTY_BUF_SIZE - read_cnt ( ldata ) ,
1434
1439
N_TTY_BUF_SIZE - ldata -> read_head );
1435
1440
i = min (count , i );
1436
1441
memcpy (ldata -> read_buf + ldata -> read_head , cp , i );
@@ -1439,7 +1444,7 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
1439
1444
cp += i ;
1440
1445
count -= i ;
1441
1446
1442
- i = min (N_TTY_BUF_SIZE - ldata -> read_cnt ,
1447
+ i = min (N_TTY_BUF_SIZE - read_cnt ( ldata ) ,
1443
1448
N_TTY_BUF_SIZE - ldata -> read_head );
1444
1449
i = min (count , i );
1445
1450
memcpy (ldata -> read_buf + ldata -> read_head , cp , i );
@@ -1474,7 +1479,7 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
1474
1479
tty -> ops -> flush_chars (tty );
1475
1480
}
1476
1481
1477
- if ((!ldata -> icanon && (ldata -> read_cnt >= ldata -> minimum_to_wake )) ||
1482
+ if ((!ldata -> icanon && (read_cnt ( ldata ) >= ldata -> minimum_to_wake )) ||
1478
1483
L_EXTPROC (tty )) {
1479
1484
kill_fasync (& tty -> fasync , SIGIO , POLL_IN );
1480
1485
if (waitqueue_active (& tty -> read_wait ))
@@ -1552,7 +1557,7 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
1552
1557
ldata -> erasing = 0 ;
1553
1558
}
1554
1559
1555
- if (canon_change && !L_ICANON (tty ) && ldata -> read_cnt )
1560
+ if (canon_change && !L_ICANON (tty ) && read_cnt ( ldata ) )
1556
1561
wake_up_interruptible (& tty -> read_wait );
1557
1562
1558
1563
ldata -> icanon = (L_ICANON (tty ) != 0 );
@@ -1701,7 +1706,7 @@ static inline int input_available_p(struct tty_struct *tty, int amt)
1701
1706
if (ldata -> icanon && !L_EXTPROC (tty )) {
1702
1707
if (ldata -> canon_data )
1703
1708
return 1 ;
1704
- } else if (ldata -> read_cnt >= (amt ? amt : 1 ))
1709
+ } else if (read_cnt ( ldata ) >= (amt ? amt : 1 ))
1705
1710
return 1 ;
1706
1711
1707
1712
return 0 ;
@@ -1737,7 +1742,7 @@ static int copy_from_read_buf(struct tty_struct *tty,
1737
1742
1738
1743
retval = 0 ;
1739
1744
raw_spin_lock_irqsave (& ldata -> read_lock , flags );
1740
- n = min (ldata -> read_cnt , N_TTY_BUF_SIZE - ldata -> read_tail );
1745
+ n = min (read_cnt ( ldata ) , N_TTY_BUF_SIZE - ldata -> read_tail );
1741
1746
n = min (* nr , n );
1742
1747
raw_spin_unlock_irqrestore (& ldata -> read_lock , flags );
1743
1748
if (n ) {
@@ -1751,7 +1756,7 @@ static int copy_from_read_buf(struct tty_struct *tty,
1751
1756
ldata -> read_tail = (ldata -> read_tail + n ) & (N_TTY_BUF_SIZE - 1 );
1752
1757
ldata -> read_cnt -= n ;
1753
1758
/* Turn single EOF into zero-length read */
1754
- if (L_EXTPROC (tty ) && ldata -> icanon && is_eof && !ldata -> read_cnt )
1759
+ if (L_EXTPROC (tty ) && ldata -> icanon && is_eof && !read_cnt ( ldata ) )
1755
1760
n = 0 ;
1756
1761
raw_spin_unlock_irqrestore (& ldata -> read_lock , flags );
1757
1762
* b += n ;
@@ -1787,7 +1792,7 @@ static int canon_copy_from_read_buf(struct tty_struct *tty,
1787
1792
1788
1793
raw_spin_lock_irqsave (& ldata -> read_lock , flags );
1789
1794
1790
- n = min_t ( size_t , * nr , ldata -> read_cnt );
1795
+ n = min ( * nr , read_cnt ( ldata ) );
1791
1796
if (!n ) {
1792
1797
raw_spin_unlock_irqrestore (& ldata -> read_lock , flags );
1793
1798
return 0 ;
@@ -2253,7 +2258,7 @@ static int n_tty_ioctl(struct tty_struct *tty, struct file *file,
2253
2258
return put_user (tty_chars_in_buffer (tty ), (int __user * ) arg );
2254
2259
case TIOCINQ :
2255
2260
/* FIXME: Locking */
2256
- retval = ldata -> read_cnt ;
2261
+ retval = read_cnt ( ldata ) ;
2257
2262
if (L_ICANON (tty ))
2258
2263
retval = inq_canon (ldata );
2259
2264
return put_user (retval , (unsigned int __user * ) arg );
0 commit comments