* not active.
*/
-static void put_tty_queue(unsigned char c, struct n_tty_data *ldata)
+static inline void put_tty_queue(unsigned char c, struct n_tty_data *ldata)
{
- if (read_cnt(ldata) < N_TTY_BUF_SIZE) {
- *read_buf_addr(ldata, ldata->read_head) = c;
- ldata->read_head++;
- }
+ *read_buf_addr(ldata, ldata->read_head++) = c;
}
/**
return;
}
if (c == '\n') {
- if (read_cnt(ldata) >= N_TTY_BUF_SIZE) {
- if (L_ECHO(tty))
- process_output('\a', tty);
- return;
- }
if (L_ECHO(tty) || L_ECHONL(tty)) {
echo_char_raw('\n', ldata);
commit_echoes(tty);
goto handle_newline;
}
if (c == EOF_CHAR(tty)) {
- if (read_cnt(ldata) >= N_TTY_BUF_SIZE)
- return;
c = __DISABLED_CHAR;
goto handle_newline;
}
(c == EOL2_CHAR(tty) && L_IEXTEN(tty))) {
parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty))
? 1 : 0;
- if (read_cnt(ldata) >= (N_TTY_BUF_SIZE - parmrk)) {
- if (L_ECHO(tty))
- process_output('\a', tty);
- return;
- }
/*
* XXX are EOL_CHAR and EOL2_CHAR echoed?!?
*/
}
parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0;
- if (read_cnt(ldata) >= (N_TTY_BUF_SIZE - parmrk - 1)) {
- /* beep if no space */
- if (L_ECHO(tty))
- process_output('\a', tty);
- return;
- }
if (L_ECHO(tty)) {
finish_erasing(ldata);
if (c == '\n')
start_tty(tty);
process_echoes(tty);
}
-
- parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0;
- if (read_cnt(ldata) >= (N_TTY_BUF_SIZE - parmrk - 1)) {
- /* beep if no space */
- if (L_ECHO(tty))
- process_output('\a', tty);
- return;
- }
if (L_ECHO(tty)) {
finish_erasing(ldata);
/* Record the column of first canon char. */
echo_char(c, tty);
commit_echoes(tty);
}
+ parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0;
if (parmrk)
put_tty_queue(c, ldata);
put_tty_queue(c, ldata);
start_tty(tty);
process_echoes(tty);
}
-
- if (read_cnt(ldata) >= (N_TTY_BUF_SIZE - 1)) {
- /* beep if no space */
- if (L_ECHO(tty))
- process_output('\a', tty);
- return;
- }
if (L_ECHO(tty)) {
finish_erasing(ldata);
/* Record the column of first canon char. */
static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
char *fp, int count)
{
+ int room, n;
+
down_read(&tty->termios_rwsem);
- __receive_buf(tty, cp, fp, count);
+
+ while (1) {
+ room = receive_room(tty);
+ n = min(count, room);
+ if (!n)
+ break;
+ __receive_buf(tty, cp, fp, n);
+ cp += n;
+ if (fp)
+ fp += n;
+ count -= n;
+ }
+
+ tty->receive_room = room;
n_tty_check_throttle(tty);
up_read(&tty->termios_rwsem);
}
char *fp, int count)
{
struct n_tty_data *ldata = tty->disc_data;
- int room;
+ int room, n, rcvd = 0;
down_read(&tty->termios_rwsem);
- tty->receive_room = room = receive_room(tty);
- if (!room)
- ldata->no_room = 1;
- count = min(count, room);
- if (count) {
- __receive_buf(tty, cp, fp, count);
- n_tty_check_throttle(tty);
+ while (1) {
+ room = receive_room(tty);
+ n = min(count, room);
+ if (!n) {
+ if (!room)
+ ldata->no_room = 1;
+ break;
+ }
+ __receive_buf(tty, cp, fp, n);
+ cp += n;
+ if (fp)
+ fp += n;
+ count -= n;
+ rcvd += n;
}
+ tty->receive_room = room;
+ n_tty_check_throttle(tty);
up_read(&tty->termios_rwsem);
- return count;
+ return rcvd;
}
int is_ignored(int sig)