aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/n_tty.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-10-18 16:26:40 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-10-22 19:53:00 -0400
commit3fe780b379fac2e1eeb5907ee7c864756ce7ec83 (patch)
treef525c6df0333c94117bdec4a2ac41d9094d4e7eb /drivers/tty/n_tty.c
parent53c5ee2cfb4dadc4f5c24fe671e2fbfc034c875e (diff)
TTY: move ldisc data from tty_struct: bitmaps
Here we move bitmaps and use DECLARE_BITMAP to declare them in the new structure. And instead of memset, we use bitmap_zero as it is more appropriate. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Alan Cox <alan@linux.intel.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.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index bd775a7c0629..702dd4adbdc9 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -80,6 +80,9 @@ struct n_tty_data {
80 80
81 unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1; 81 unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1;
82 unsigned char echo_overrun:1; 82 unsigned char echo_overrun:1;
83
84 DECLARE_BITMAP(process_char_map, 256);
85 DECLARE_BITMAP(read_flags, N_TTY_BUF_SIZE);
83}; 86};
84 87
85static inline int tty_put_user(struct tty_struct *tty, unsigned char x, 88static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
@@ -203,7 +206,7 @@ static void reset_buffer_flags(struct tty_struct *tty)
203 mutex_unlock(&tty->echo_lock); 206 mutex_unlock(&tty->echo_lock);
204 207
205 tty->canon_head = tty->canon_data = ldata->erasing = 0; 208 tty->canon_head = tty->canon_data = ldata->erasing = 0;
206 memset(&tty->read_flags, 0, sizeof tty->read_flags); 209 bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE);
207 n_tty_set_room(tty); 210 n_tty_set_room(tty);
208} 211}
209 212
@@ -1165,7 +1168,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
1165 * handle specially, do shortcut processing to speed things 1168 * handle specially, do shortcut processing to speed things
1166 * up. 1169 * up.
1167 */ 1170 */
1168 if (!test_bit(c, tty->process_char_map) || ldata->lnext) { 1171 if (!test_bit(c, ldata->process_char_map) || ldata->lnext) {
1169 ldata->lnext = 0; 1172 ldata->lnext = 0;
1170 parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0; 1173 parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0;
1171 if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) { 1174 if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) {
@@ -1321,7 +1324,7 @@ send_signal:
1321 1324
1322handle_newline: 1325handle_newline:
1323 spin_lock_irqsave(&tty->read_lock, flags); 1326 spin_lock_irqsave(&tty->read_lock, flags);
1324 set_bit(tty->read_head, tty->read_flags); 1327 set_bit(tty->read_head, ldata->read_flags);
1325 put_tty_queue_nolock(c, tty); 1328 put_tty_queue_nolock(c, tty);
1326 tty->canon_head = tty->read_head; 1329 tty->canon_head = tty->read_head;
1327 tty->canon_data++; 1330 tty->canon_data++;
@@ -1496,7 +1499,7 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
1496 if (old) 1499 if (old)
1497 canon_change = (old->c_lflag ^ tty->termios.c_lflag) & ICANON; 1500 canon_change = (old->c_lflag ^ tty->termios.c_lflag) & ICANON;
1498 if (canon_change) { 1501 if (canon_change) {
1499 memset(&tty->read_flags, 0, sizeof tty->read_flags); 1502 bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE);
1500 tty->canon_head = tty->read_tail; 1503 tty->canon_head = tty->read_tail;
1501 tty->canon_data = 0; 1504 tty->canon_data = 0;
1502 ldata->erasing = 0; 1505 ldata->erasing = 0;
@@ -1516,41 +1519,41 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
1516 I_ICRNL(tty) || I_INLCR(tty) || L_ICANON(tty) || 1519 I_ICRNL(tty) || I_INLCR(tty) || L_ICANON(tty) ||
1517 I_IXON(tty) || L_ISIG(tty) || L_ECHO(tty) || 1520 I_IXON(tty) || L_ISIG(tty) || L_ECHO(tty) ||
1518 I_PARMRK(tty)) { 1521 I_PARMRK(tty)) {
1519 memset(tty->process_char_map, 0, 256/8); 1522 bitmap_zero(ldata->process_char_map, 256);
1520 1523
1521 if (I_IGNCR(tty) || I_ICRNL(tty)) 1524 if (I_IGNCR(tty) || I_ICRNL(tty))
1522 set_bit('\r', tty->process_char_map); 1525 set_bit('\r', ldata->process_char_map);
1523 if (I_INLCR(tty)) 1526 if (I_INLCR(tty))
1524 set_bit('\n', tty->process_char_map); 1527 set_bit('\n', ldata->process_char_map);
1525 1528
1526 if (L_ICANON(tty)) { 1529 if (L_ICANON(tty)) {
1527 set_bit(ERASE_CHAR(tty), tty->process_char_map); 1530 set_bit(ERASE_CHAR(tty), ldata->process_char_map);
1528 set_bit(KILL_CHAR(tty), tty->process_char_map); 1531 set_bit(KILL_CHAR(tty), ldata->process_char_map);
1529 set_bit(EOF_CHAR(tty), tty->process_char_map); 1532 set_bit(EOF_CHAR(tty), ldata->process_char_map);
1530 set_bit('\n', tty->process_char_map); 1533 set_bit('\n', ldata->process_char_map);
1531 set_bit(EOL_CHAR(tty), tty->process_char_map); 1534 set_bit(EOL_CHAR(tty), ldata->process_char_map);
1532 if (L_IEXTEN(tty)) { 1535 if (L_IEXTEN(tty)) {
1533 set_bit(WERASE_CHAR(tty), 1536 set_bit(WERASE_CHAR(tty),
1534 tty->process_char_map); 1537 ldata->process_char_map);
1535 set_bit(LNEXT_CHAR(tty), 1538 set_bit(LNEXT_CHAR(tty),
1536 tty->process_char_map); 1539 ldata->process_char_map);
1537 set_bit(EOL2_CHAR(tty), 1540 set_bit(EOL2_CHAR(tty),
1538 tty->process_char_map); 1541 ldata->process_char_map);
1539 if (L_ECHO(tty)) 1542 if (L_ECHO(tty))
1540 set_bit(REPRINT_CHAR(tty), 1543 set_bit(REPRINT_CHAR(tty),
1541 tty->process_char_map); 1544 ldata->process_char_map);
1542 } 1545 }
1543 } 1546 }
1544 if (I_IXON(tty)) { 1547 if (I_IXON(tty)) {
1545 set_bit(START_CHAR(tty), tty->process_char_map); 1548 set_bit(START_CHAR(tty), ldata->process_char_map);
1546 set_bit(STOP_CHAR(tty), tty->process_char_map); 1549 set_bit(STOP_CHAR(tty), ldata->process_char_map);
1547 } 1550 }
1548 if (L_ISIG(tty)) { 1551 if (L_ISIG(tty)) {
1549 set_bit(INTR_CHAR(tty), tty->process_char_map); 1552 set_bit(INTR_CHAR(tty), ldata->process_char_map);
1550 set_bit(QUIT_CHAR(tty), tty->process_char_map); 1553 set_bit(QUIT_CHAR(tty), ldata->process_char_map);
1551 set_bit(SUSP_CHAR(tty), tty->process_char_map); 1554 set_bit(SUSP_CHAR(tty), ldata->process_char_map);
1552 } 1555 }
1553 clear_bit(__DISABLED_CHAR, tty->process_char_map); 1556 clear_bit(__DISABLED_CHAR, ldata->process_char_map);
1554 ldata->raw = 0; 1557 ldata->raw = 0;
1555 ldata->real_raw = 0; 1558 ldata->real_raw = 0;
1556 } else { 1559 } else {
@@ -1879,7 +1882,7 @@ do_it_again:
1879 int eol; 1882 int eol;
1880 1883
1881 eol = test_and_clear_bit(tty->read_tail, 1884 eol = test_and_clear_bit(tty->read_tail,
1882 tty->read_flags); 1885 ldata->read_flags);
1883 c = tty->read_buf[tty->read_tail]; 1886 c = tty->read_buf[tty->read_tail];
1884 tty->read_tail = ((tty->read_tail+1) & 1887 tty->read_tail = ((tty->read_tail+1) &
1885 (N_TTY_BUF_SIZE-1)); 1888 (N_TTY_BUF_SIZE-1));
@@ -2105,6 +2108,7 @@ static unsigned int n_tty_poll(struct tty_struct *tty, struct file *file,
2105 2108
2106static unsigned long inq_canon(struct tty_struct *tty) 2109static unsigned long inq_canon(struct tty_struct *tty)
2107{ 2110{
2111 struct n_tty_data *ldata = tty->disc_data;
2108 int nr, head, tail; 2112 int nr, head, tail;
2109 2113
2110 if (!tty->canon_data) 2114 if (!tty->canon_data)
@@ -2114,7 +2118,7 @@ static unsigned long inq_canon(struct tty_struct *tty)
2114 nr = (head - tail) & (N_TTY_BUF_SIZE-1); 2118 nr = (head - tail) & (N_TTY_BUF_SIZE-1);
2115 /* Skip EOF-chars.. */ 2119 /* Skip EOF-chars.. */
2116 while (head != tail) { 2120 while (head != tail) {
2117 if (test_bit(tail, tty->read_flags) && 2121 if (test_bit(tail, ldata->read_flags) &&
2118 tty->read_buf[tail] == __DISABLED_CHAR) 2122 tty->read_buf[tail] == __DISABLED_CHAR)
2119 nr--; 2123 nr--;
2120 tail = (tail+1) & (N_TTY_BUF_SIZE-1); 2124 tail = (tail+1) & (N_TTY_BUF_SIZE-1);