diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2013-06-15 10:21:27 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-23 20:11:02 -0400 |
commit | ad0cc7bafe498fb299043582e822fc4e74388edb (patch) | |
tree | 7cf000589f537fef086058e6a70c656dc032231a /drivers/tty/n_tty.c | |
parent | a1dd30e9b4c38a4a177106741b03ac6a55777286 (diff) |
n_tty: Factor tty->closing receive_buf() into separate fn
Convert to modal receive_buf() processing; factor receive char
processing when tty->closing into n_tty_receive_buf_closing().
Note that EXTPROC when ISTRIP or IUCLC is set continues to be
handled by n_tty_receive_char().
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/n_tty.c')
-rw-r--r-- | drivers/tty/n_tty.c | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index e9cfc77a1279..ed6c4e4d960a 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c | |||
@@ -1276,17 +1276,6 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) | |||
1276 | process_echoes(tty); | 1276 | process_echoes(tty); |
1277 | } | 1277 | } |
1278 | 1278 | ||
1279 | if (tty->closing) { | ||
1280 | if (I_IXON(tty)) { | ||
1281 | if (c == START_CHAR(tty)) { | ||
1282 | start_tty(tty); | ||
1283 | process_echoes(tty); | ||
1284 | } else if (c == STOP_CHAR(tty)) | ||
1285 | stop_tty(tty); | ||
1286 | } | ||
1287 | return; | ||
1288 | } | ||
1289 | |||
1290 | /* | 1279 | /* |
1291 | * If the previous character was LNEXT, or we know that this | 1280 | * If the previous character was LNEXT, or we know that this |
1292 | * character is not one of the characters that we'll have to | 1281 | * character is not one of the characters that we'll have to |
@@ -1463,6 +1452,27 @@ handle_newline: | |||
1463 | put_tty_queue(c, ldata); | 1452 | put_tty_queue(c, ldata); |
1464 | } | 1453 | } |
1465 | 1454 | ||
1455 | static inline void | ||
1456 | n_tty_receive_char_closing(struct tty_struct *tty, unsigned char c) | ||
1457 | { | ||
1458 | if (I_ISTRIP(tty)) | ||
1459 | c &= 0x7f; | ||
1460 | if (I_IUCLC(tty) && L_IEXTEN(tty)) | ||
1461 | c = tolower(c); | ||
1462 | |||
1463 | if (I_IXON(tty)) { | ||
1464 | if (c == STOP_CHAR(tty)) | ||
1465 | stop_tty(tty); | ||
1466 | else if (c == START_CHAR(tty) || | ||
1467 | (tty->stopped && !tty->flow_stopped && I_IXANY(tty) && | ||
1468 | c != INTR_CHAR(tty) && c != QUIT_CHAR(tty) && | ||
1469 | c != SUSP_CHAR(tty))) { | ||
1470 | start_tty(tty); | ||
1471 | process_echoes(tty); | ||
1472 | } | ||
1473 | } | ||
1474 | } | ||
1475 | |||
1466 | static void | 1476 | static void |
1467 | n_tty_receive_char_flagged(struct tty_struct *tty, unsigned char c, char flag) | 1477 | n_tty_receive_char_flagged(struct tty_struct *tty, unsigned char c, char flag) |
1468 | { | 1478 | { |
@@ -1542,6 +1552,22 @@ n_tty_receive_buf_raw(struct tty_struct *tty, const unsigned char *cp, | |||
1542 | } | 1552 | } |
1543 | } | 1553 | } |
1544 | 1554 | ||
1555 | static void | ||
1556 | n_tty_receive_buf_closing(struct tty_struct *tty, const unsigned char *cp, | ||
1557 | char *fp, int count) | ||
1558 | { | ||
1559 | char flag = TTY_NORMAL; | ||
1560 | |||
1561 | while (count--) { | ||
1562 | if (fp) | ||
1563 | flag = *fp++; | ||
1564 | if (likely(flag == TTY_NORMAL)) | ||
1565 | n_tty_receive_char_closing(tty, *cp++); | ||
1566 | else | ||
1567 | n_tty_receive_char_flagged(tty, *cp++, flag); | ||
1568 | } | ||
1569 | } | ||
1570 | |||
1545 | static void __receive_buf(struct tty_struct *tty, const unsigned char *cp, | 1571 | static void __receive_buf(struct tty_struct *tty, const unsigned char *cp, |
1546 | char *fp, int count) | 1572 | char *fp, int count) |
1547 | { | 1573 | { |
@@ -1552,6 +1578,8 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp, | |||
1552 | n_tty_receive_buf_real_raw(tty, cp, fp, count); | 1578 | n_tty_receive_buf_real_raw(tty, cp, fp, count); |
1553 | else if (ldata->raw || (L_EXTPROC(tty) && !preops)) | 1579 | else if (ldata->raw || (L_EXTPROC(tty) && !preops)) |
1554 | n_tty_receive_buf_raw(tty, cp, fp, count); | 1580 | n_tty_receive_buf_raw(tty, cp, fp, count); |
1581 | else if (tty->closing && !L_EXTPROC(tty)) | ||
1582 | n_tty_receive_buf_closing(tty, cp, fp, count); | ||
1555 | else { | 1583 | else { |
1556 | char flag = TTY_NORMAL; | 1584 | char flag = TTY_NORMAL; |
1557 | 1585 | ||