char *read_buf;
size_t read_head;
size_t read_tail;
- int read_cnt;
int minimum_to_wake;
unsigned char *echo_buf;
static inline size_t read_cnt(struct n_tty_data *ldata)
{
- return ldata->read_cnt;
+ return ldata->read_head - ldata->read_tail;
}
static inline unsigned char read_buf(struct n_tty_data *ldata, size_t i)
if (read_cnt(ldata) < N_TTY_BUF_SIZE) {
*read_buf_addr(ldata, ldata->read_head) = c;
ldata->read_head++;
- ldata->read_cnt++;
}
}
unsigned long flags;
raw_spin_lock_irqsave(&ldata->read_lock, flags);
- ldata->read_head = ldata->read_tail = ldata->read_cnt = 0;
+ ldata->read_head = ldata->read_tail = 0;
raw_spin_unlock_irqrestore(&ldata->read_lock, flags);
mutex_lock(&ldata->echo_lock);
else {
if (!L_ECHO(tty)) {
raw_spin_lock_irqsave(&ldata->read_lock, flags);
- ldata->read_cnt -= ((ldata->read_head - ldata->canon_head) &
- (N_TTY_BUF_SIZE - 1));
ldata->read_head = ldata->canon_head;
raw_spin_unlock_irqrestore(&ldata->read_lock, flags);
return;
}
if (!L_ECHOK(tty) || !L_ECHOKE(tty) || !L_ECHOE(tty)) {
raw_spin_lock_irqsave(&ldata->read_lock, flags);
- ldata->read_cnt -= ((ldata->read_head - ldata->canon_head) &
- (N_TTY_BUF_SIZE - 1));
ldata->read_head = ldata->canon_head;
raw_spin_unlock_irqrestore(&ldata->read_lock, flags);
finish_erasing(ldata);
cnt = ldata->read_head - head;
raw_spin_lock_irqsave(&ldata->read_lock, flags);
ldata->read_head = head;
- ldata->read_cnt -= cnt;
raw_spin_unlock_irqrestore(&ldata->read_lock, flags);
if (L_ECHO(tty)) {
if (L_ECHOPRT(tty)) {
i = min(count, i);
memcpy(read_buf_addr(ldata, ldata->read_head), cp, i);
ldata->read_head += i;
- ldata->read_cnt += i;
cp += i;
count -= i;
i = min(count, i);
memcpy(read_buf_addr(ldata, ldata->read_head), cp, i);
ldata->read_head += i;
- ldata->read_cnt += i;
raw_spin_unlock_irqrestore(&ldata->read_lock, cpuflags);
} else {
for (i = count, p = cp, f = fp; i; i--, p++) {
ldata->icanon);
raw_spin_lock_irqsave(&ldata->read_lock, flags);
ldata->read_tail += n;
- ldata->read_cnt -= n;
/* Turn single EOF into zero-length read */
if (L_EXTPROC(tty) && ldata->icanon && is_eof && !read_cnt(ldata))
n = 0;
raw_spin_lock_irqsave(&ldata->read_lock, flags);
ldata->read_tail += c;
- ldata->read_cnt -= c;
if (found) {
__clear_bit(eol, ldata->read_flags);
/* this test should be redundant: