n_tty: move lnext handling
Move lnext handling from __receive_buf to n_tty_receive_buf_standard. It simplifies the handling as it needs not fetching 'flag' and decrement 'count' in __receive_buf. Instead, all this is left up to the loop in n_tty_receive_buf_standard which already does that. This way, no need to repeat the action when n_tty_receive_char_special returns true -- ldata->lnext is set there in that case, so the 'if (ldata->lnext)' check is sufficient. The next patch will switch n_tty_receive_char_special to return 'void'. The result is much simplified code flow. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210505091928.22010-7-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
95aafe3278
commit
67a620d58b
@@ -1538,6 +1538,12 @@ static void n_tty_receive_buf_standard(struct tty_struct *tty,
|
|||||||
while (count--) {
|
while (count--) {
|
||||||
if (fp)
|
if (fp)
|
||||||
flag = *fp++;
|
flag = *fp++;
|
||||||
|
|
||||||
|
if (ldata->lnext) {
|
||||||
|
n_tty_receive_char_lnext(tty, *cp++, flag);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (likely(flag == TTY_NORMAL)) {
|
if (likely(flag == TTY_NORMAL)) {
|
||||||
unsigned char c = *cp++;
|
unsigned char c = *cp++;
|
||||||
|
|
||||||
@@ -1551,12 +1557,8 @@ static void n_tty_receive_buf_standard(struct tty_struct *tty,
|
|||||||
}
|
}
|
||||||
if (!test_bit(c, ldata->char_map))
|
if (!test_bit(c, ldata->char_map))
|
||||||
n_tty_receive_char(tty, c);
|
n_tty_receive_char(tty, c);
|
||||||
else if (n_tty_receive_char_special(tty, c) && count) {
|
else
|
||||||
if (fp)
|
n_tty_receive_char_special(tty, c);
|
||||||
flag = *fp++;
|
|
||||||
n_tty_receive_char_lnext(tty, *cp++, flag);
|
|
||||||
count--;
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
n_tty_receive_char_flagged(tty, *cp++, flag);
|
n_tty_receive_char_flagged(tty, *cp++, flag);
|
||||||
}
|
}
|
||||||
@@ -1575,15 +1577,6 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
|
|||||||
else if (tty->closing && !L_EXTPROC(tty))
|
else if (tty->closing && !L_EXTPROC(tty))
|
||||||
n_tty_receive_buf_closing(tty, cp, fp, count);
|
n_tty_receive_buf_closing(tty, cp, fp, count);
|
||||||
else {
|
else {
|
||||||
if (ldata->lnext) {
|
|
||||||
char flag = TTY_NORMAL;
|
|
||||||
|
|
||||||
if (fp)
|
|
||||||
flag = *fp++;
|
|
||||||
n_tty_receive_char_lnext(tty, *cp++, flag);
|
|
||||||
count--;
|
|
||||||
}
|
|
||||||
|
|
||||||
n_tty_receive_buf_standard(tty, cp, fp, count);
|
n_tty_receive_buf_standard(tty, cp, fp, count);
|
||||||
|
|
||||||
flush_echoes(tty);
|
flush_echoes(tty);
|
||||||
|
|||||||
Reference in New Issue
Block a user