diff options
| author | Jiri Slaby <jslaby@suse.cz> | 2012-10-18 16:26:39 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-10-22 19:53:00 -0400 |
| commit | 53c5ee2cfb4dadc4f5c24fe671e2fbfc034c875e (patch) | |
| tree | eb5813a4cc186299b3be5bda0fd06617d7940403 | |
| parent | 70ece7a731598ac760c2a34421fcb2de18d2713f (diff) | |
TTY: move ldisc data from tty_struct: simple members
Here we start moving all the n_tty related bits from tty_struct to
the newly defined n_tty_data struct in n_tty proper.
In this patch primitive members and bits are moved. The rest will be
done per-partes in the next patches.
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>
| -rw-r--r-- | drivers/tty/n_tty.c | 160 | ||||
| -rw-r--r-- | drivers/tty/tty_io.c | 1 | ||||
| -rw-r--r-- | include/linux/tty.h | 5 |
3 files changed, 93 insertions, 73 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 3d1594e10d00..bd775a7c0629 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c | |||
| @@ -74,13 +74,20 @@ | |||
| 74 | #define ECHO_OP_ERASE_TAB 0x82 | 74 | #define ECHO_OP_ERASE_TAB 0x82 |
| 75 | 75 | ||
| 76 | struct n_tty_data { | 76 | struct n_tty_data { |
| 77 | char dummy; | 77 | unsigned int column; |
| 78 | unsigned long overrun_time; | ||
| 79 | int num_overrun; | ||
| 80 | |||
| 81 | unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1; | ||
| 82 | unsigned char echo_overrun:1; | ||
| 78 | }; | 83 | }; |
| 79 | 84 | ||
| 80 | static inline int tty_put_user(struct tty_struct *tty, unsigned char x, | 85 | static inline int tty_put_user(struct tty_struct *tty, unsigned char x, |
| 81 | unsigned char __user *ptr) | 86 | unsigned char __user *ptr) |
| 82 | { | 87 | { |
| 83 | tty_audit_add_data(tty, &x, 1, tty->icanon); | 88 | struct n_tty_data *ldata = tty->disc_data; |
| 89 | |||
| 90 | tty_audit_add_data(tty, &x, 1, ldata->icanon); | ||
| 84 | return put_user(x, ptr); | 91 | return put_user(x, ptr); |
| 85 | } | 92 | } |
| 86 | 93 | ||
| @@ -96,6 +103,7 @@ static inline int tty_put_user(struct tty_struct *tty, unsigned char x, | |||
| 96 | 103 | ||
| 97 | static void n_tty_set_room(struct tty_struct *tty) | 104 | static void n_tty_set_room(struct tty_struct *tty) |
| 98 | { | 105 | { |
| 106 | struct n_tty_data *ldata = tty->disc_data; | ||
| 99 | int left; | 107 | int left; |
| 100 | int old_left; | 108 | int old_left; |
| 101 | 109 | ||
| @@ -115,7 +123,7 @@ static void n_tty_set_room(struct tty_struct *tty) | |||
| 115 | * characters will be beeped. | 123 | * characters will be beeped. |
| 116 | */ | 124 | */ |
| 117 | if (left <= 0) | 125 | if (left <= 0) |
| 118 | left = tty->icanon && !tty->canon_data; | 126 | left = ldata->icanon && !tty->canon_data; |
| 119 | old_left = tty->receive_room; | 127 | old_left = tty->receive_room; |
| 120 | tty->receive_room = left; | 128 | tty->receive_room = left; |
| 121 | 129 | ||
| @@ -183,6 +191,7 @@ static void check_unthrottle(struct tty_struct *tty) | |||
| 183 | 191 | ||
| 184 | static void reset_buffer_flags(struct tty_struct *tty) | 192 | static void reset_buffer_flags(struct tty_struct *tty) |
| 185 | { | 193 | { |
| 194 | struct n_tty_data *ldata = tty->disc_data; | ||
| 186 | unsigned long flags; | 195 | unsigned long flags; |
| 187 | 196 | ||
| 188 | spin_lock_irqsave(&tty->read_lock, flags); | 197 | spin_lock_irqsave(&tty->read_lock, flags); |
| @@ -190,10 +199,10 @@ static void reset_buffer_flags(struct tty_struct *tty) | |||
| 190 | spin_unlock_irqrestore(&tty->read_lock, flags); | 199 | spin_unlock_irqrestore(&tty->read_lock, flags); |
| 191 | 200 | ||
| 192 | mutex_lock(&tty->echo_lock); | 201 | mutex_lock(&tty->echo_lock); |
| 193 | tty->echo_pos = tty->echo_cnt = tty->echo_overrun = 0; | 202 | tty->echo_pos = tty->echo_cnt = ldata->echo_overrun = 0; |
| 194 | mutex_unlock(&tty->echo_lock); | 203 | mutex_unlock(&tty->echo_lock); |
| 195 | 204 | ||
| 196 | tty->canon_head = tty->canon_data = tty->erasing = 0; | 205 | tty->canon_head = tty->canon_data = ldata->erasing = 0; |
| 197 | memset(&tty->read_flags, 0, sizeof tty->read_flags); | 206 | memset(&tty->read_flags, 0, sizeof tty->read_flags); |
| 198 | n_tty_set_room(tty); | 207 | n_tty_set_room(tty); |
| 199 | } | 208 | } |
| @@ -239,11 +248,12 @@ static void n_tty_flush_buffer(struct tty_struct *tty) | |||
| 239 | 248 | ||
| 240 | static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty) | 249 | static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty) |
| 241 | { | 250 | { |
| 251 | struct n_tty_data *ldata = tty->disc_data; | ||
| 242 | unsigned long flags; | 252 | unsigned long flags; |
| 243 | ssize_t n = 0; | 253 | ssize_t n = 0; |
| 244 | 254 | ||
| 245 | spin_lock_irqsave(&tty->read_lock, flags); | 255 | spin_lock_irqsave(&tty->read_lock, flags); |
| 246 | if (!tty->icanon) { | 256 | if (!ldata->icanon) { |
| 247 | n = tty->read_cnt; | 257 | n = tty->read_cnt; |
| 248 | } else if (tty->canon_data) { | 258 | } else if (tty->canon_data) { |
| 249 | n = (tty->canon_head > tty->read_tail) ? | 259 | n = (tty->canon_head > tty->read_tail) ? |
| @@ -305,6 +315,7 @@ static inline int is_continuation(unsigned char c, struct tty_struct *tty) | |||
| 305 | 315 | ||
| 306 | static int do_output_char(unsigned char c, struct tty_struct *tty, int space) | 316 | static int do_output_char(unsigned char c, struct tty_struct *tty, int space) |
| 307 | { | 317 | { |
| 318 | struct n_tty_data *ldata = tty->disc_data; | ||
| 308 | int spaces; | 319 | int spaces; |
| 309 | 320 | ||
| 310 | if (!space) | 321 | if (!space) |
| @@ -313,48 +324,48 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space) | |||
| 313 | switch (c) { | 324 | switch (c) { |
| 314 | case '\n': | 325 | case '\n': |
| 315 | if (O_ONLRET(tty)) | 326 | if (O_ONLRET(tty)) |
| 316 | tty->column = 0; | 327 | ldata->column = 0; |
| 317 | if (O_ONLCR(tty)) { | 328 | if (O_ONLCR(tty)) { |
| 318 | if (space < 2) | 329 | if (space < 2) |
| 319 | return -1; | 330 | return -1; |
| 320 | tty->canon_column = tty->column = 0; | 331 | tty->canon_column = ldata->column = 0; |
| 321 | tty->ops->write(tty, "\r\n", 2); | 332 | tty->ops->write(tty, "\r\n", 2); |
| 322 | return 2; | 333 | return 2; |
| 323 | } | 334 | } |
| 324 | tty->canon_column = tty->column; | 335 | tty->canon_column = ldata->column; |
| 325 | break; | 336 | break; |
| 326 | case '\r': | 337 | case '\r': |
| 327 | if (O_ONOCR(tty) && tty->column == 0) | 338 | if (O_ONOCR(tty) && ldata->column == 0) |
| 328 | return 0; | 339 | return 0; |
| 329 | if (O_OCRNL(tty)) { | 340 | if (O_OCRNL(tty)) { |
| 330 | c = '\n'; | 341 | c = '\n'; |
| 331 | if (O_ONLRET(tty)) | 342 | if (O_ONLRET(tty)) |
| 332 | tty->canon_column = tty->column = 0; | 343 | tty->canon_column = ldata->column = 0; |
| 333 | break; | 344 | break; |
| 334 | } | 345 | } |
| 335 | tty->canon_column = tty->column = 0; | 346 | tty->canon_column = ldata->column = 0; |
| 336 | break; | 347 | break; |
| 337 | case '\t': | 348 | case '\t': |
| 338 | spaces = 8 - (tty->column & 7); | 349 | spaces = 8 - (ldata->column & 7); |
| 339 | if (O_TABDLY(tty) == XTABS) { | 350 | if (O_TABDLY(tty) == XTABS) { |
| 340 | if (space < spaces) | 351 | if (space < spaces) |
| 341 | return -1; | 352 | return -1; |
| 342 | tty->column += spaces; | 353 | ldata->column += spaces; |
| 343 | tty->ops->write(tty, " ", spaces); | 354 | tty->ops->write(tty, " ", spaces); |
| 344 | return spaces; | 355 | return spaces; |
| 345 | } | 356 | } |
| 346 | tty->column += spaces; | 357 | ldata->column += spaces; |
| 347 | break; | 358 | break; |
| 348 | case '\b': | 359 | case '\b': |
| 349 | if (tty->column > 0) | 360 | if (ldata->column > 0) |
| 350 | tty->column--; | 361 | ldata->column--; |
| 351 | break; | 362 | break; |
| 352 | default: | 363 | default: |
| 353 | if (!iscntrl(c)) { | 364 | if (!iscntrl(c)) { |
| 354 | if (O_OLCUC(tty)) | 365 | if (O_OLCUC(tty)) |
| 355 | c = toupper(c); | 366 | c = toupper(c); |
| 356 | if (!is_continuation(c, tty)) | 367 | if (!is_continuation(c, tty)) |
| 357 | tty->column++; | 368 | ldata->column++; |
| 358 | } | 369 | } |
| 359 | break; | 370 | break; |
| 360 | } | 371 | } |
| @@ -415,6 +426,7 @@ static int process_output(unsigned char c, struct tty_struct *tty) | |||
| 415 | static ssize_t process_output_block(struct tty_struct *tty, | 426 | static ssize_t process_output_block(struct tty_struct *tty, |
| 416 | const unsigned char *buf, unsigned int nr) | 427 | const unsigned char *buf, unsigned int nr) |
| 417 | { | 428 | { |
| 429 | struct n_tty_data *ldata = tty->disc_data; | ||
| 418 | int space; | 430 | int space; |
| 419 | int i; | 431 | int i; |
| 420 | const unsigned char *cp; | 432 | const unsigned char *cp; |
| @@ -435,30 +447,30 @@ static ssize_t process_output_block(struct tty_struct *tty, | |||
| 435 | switch (c) { | 447 | switch (c) { |
| 436 | case '\n': | 448 | case '\n': |
| 437 | if (O_ONLRET(tty)) | 449 | if (O_ONLRET(tty)) |
| 438 | tty->column = 0; | 450 | ldata->column = 0; |
| 439 | if (O_ONLCR(tty)) | 451 | if (O_ONLCR(tty)) |
| 440 | goto break_out; | 452 | goto break_out; |
| 441 | tty->canon_column = tty->column; | 453 | tty->canon_column = ldata->column; |
| 442 | break; | 454 | break; |
| 443 | case '\r': | 455 | case '\r': |
| 444 | if (O_ONOCR(tty) && tty->column == 0) | 456 | if (O_ONOCR(tty) && ldata->column == 0) |
| 445 | goto break_out; | 457 | goto break_out; |
| 446 | if (O_OCRNL(tty)) | 458 | if (O_OCRNL(tty)) |
| 447 | goto break_out; | 459 | goto break_out; |
| 448 | tty->canon_column = tty->column = 0; | 460 | tty->canon_column = ldata->column = 0; |
| 449 | break; | 461 | break; |
| 450 | case '\t': | 462 | case '\t': |
| 451 | goto break_out; | 463 | goto break_out; |
| 452 | case '\b': | 464 | case '\b': |
| 453 | if (tty->column > 0) | 465 | if (ldata->column > 0) |
| 454 | tty->column--; | 466 | ldata->column--; |
| 455 | break; | 467 | break; |
| 456 | default: | 468 | default: |
| 457 | if (!iscntrl(c)) { | 469 | if (!iscntrl(c)) { |
| 458 | if (O_OLCUC(tty)) | 470 | if (O_OLCUC(tty)) |
| 459 | goto break_out; | 471 | goto break_out; |
| 460 | if (!is_continuation(c, tty)) | 472 | if (!is_continuation(c, tty)) |
| 461 | tty->column++; | 473 | ldata->column++; |
| 462 | } | 474 | } |
| 463 | break; | 475 | break; |
| 464 | } | 476 | } |
| @@ -498,6 +510,7 @@ break_out: | |||
| 498 | 510 | ||
| 499 | static void process_echoes(struct tty_struct *tty) | 511 | static void process_echoes(struct tty_struct *tty) |
| 500 | { | 512 | { |
| 513 | struct n_tty_data *ldata = tty->disc_data; | ||
| 501 | int space, nr; | 514 | int space, nr; |
| 502 | unsigned char c; | 515 | unsigned char c; |
| 503 | unsigned char *cp, *buf_end; | 516 | unsigned char *cp, *buf_end; |
| @@ -559,22 +572,22 @@ static void process_echoes(struct tty_struct *tty) | |||
| 559 | space -= num_bs; | 572 | space -= num_bs; |
| 560 | while (num_bs--) { | 573 | while (num_bs--) { |
| 561 | tty_put_char(tty, '\b'); | 574 | tty_put_char(tty, '\b'); |
| 562 | if (tty->column > 0) | 575 | if (ldata->column > 0) |
| 563 | tty->column--; | 576 | ldata->column--; |
| 564 | } | 577 | } |
| 565 | cp += 3; | 578 | cp += 3; |
| 566 | nr -= 3; | 579 | nr -= 3; |
| 567 | break; | 580 | break; |
| 568 | 581 | ||
| 569 | case ECHO_OP_SET_CANON_COL: | 582 | case ECHO_OP_SET_CANON_COL: |
| 570 | tty->canon_column = tty->column; | 583 | tty->canon_column = ldata->column; |
| 571 | cp += 2; | 584 | cp += 2; |
| 572 | nr -= 2; | 585 | nr -= 2; |
| 573 | break; | 586 | break; |
| 574 | 587 | ||
| 575 | case ECHO_OP_MOVE_BACK_COL: | 588 | case ECHO_OP_MOVE_BACK_COL: |
| 576 | if (tty->column > 0) | 589 | if (ldata->column > 0) |
| 577 | tty->column--; | 590 | ldata->column--; |
| 578 | cp += 2; | 591 | cp += 2; |
| 579 | nr -= 2; | 592 | nr -= 2; |
| 580 | break; | 593 | break; |
| @@ -586,7 +599,7 @@ static void process_echoes(struct tty_struct *tty) | |||
| 586 | break; | 599 | break; |
| 587 | } | 600 | } |
| 588 | tty_put_char(tty, ECHO_OP_START); | 601 | tty_put_char(tty, ECHO_OP_START); |
| 589 | tty->column++; | 602 | ldata->column++; |
| 590 | space--; | 603 | space--; |
| 591 | cp += 2; | 604 | cp += 2; |
| 592 | nr -= 2; | 605 | nr -= 2; |
| @@ -608,7 +621,7 @@ static void process_echoes(struct tty_struct *tty) | |||
| 608 | } | 621 | } |
| 609 | tty_put_char(tty, '^'); | 622 | tty_put_char(tty, '^'); |
| 610 | tty_put_char(tty, op ^ 0100); | 623 | tty_put_char(tty, op ^ 0100); |
| 611 | tty->column += 2; | 624 | ldata->column += 2; |
| 612 | space -= 2; | 625 | space -= 2; |
| 613 | cp += 2; | 626 | cp += 2; |
| 614 | nr -= 2; | 627 | nr -= 2; |
| @@ -641,14 +654,14 @@ static void process_echoes(struct tty_struct *tty) | |||
| 641 | if (nr == 0) { | 654 | if (nr == 0) { |
| 642 | tty->echo_pos = 0; | 655 | tty->echo_pos = 0; |
| 643 | tty->echo_cnt = 0; | 656 | tty->echo_cnt = 0; |
| 644 | tty->echo_overrun = 0; | 657 | ldata->echo_overrun = 0; |
| 645 | } else { | 658 | } else { |
| 646 | int num_processed = tty->echo_cnt - nr; | 659 | int num_processed = tty->echo_cnt - nr; |
| 647 | tty->echo_pos += num_processed; | 660 | tty->echo_pos += num_processed; |
| 648 | tty->echo_pos &= N_TTY_BUF_SIZE - 1; | 661 | tty->echo_pos &= N_TTY_BUF_SIZE - 1; |
| 649 | tty->echo_cnt = nr; | 662 | tty->echo_cnt = nr; |
| 650 | if (num_processed > 0) | 663 | if (num_processed > 0) |
| 651 | tty->echo_overrun = 0; | 664 | ldata->echo_overrun = 0; |
| 652 | } | 665 | } |
| 653 | 666 | ||
| 654 | mutex_unlock(&tty->echo_lock); | 667 | mutex_unlock(&tty->echo_lock); |
| @@ -670,6 +683,7 @@ static void process_echoes(struct tty_struct *tty) | |||
| 670 | 683 | ||
| 671 | static void add_echo_byte(unsigned char c, struct tty_struct *tty) | 684 | static void add_echo_byte(unsigned char c, struct tty_struct *tty) |
| 672 | { | 685 | { |
| 686 | struct n_tty_data *ldata = tty->disc_data; | ||
| 673 | int new_byte_pos; | 687 | int new_byte_pos; |
| 674 | 688 | ||
| 675 | if (tty->echo_cnt == N_TTY_BUF_SIZE) { | 689 | if (tty->echo_cnt == N_TTY_BUF_SIZE) { |
| @@ -695,7 +709,7 @@ static void add_echo_byte(unsigned char c, struct tty_struct *tty) | |||
| 695 | } | 709 | } |
| 696 | tty->echo_pos &= N_TTY_BUF_SIZE - 1; | 710 | tty->echo_pos &= N_TTY_BUF_SIZE - 1; |
| 697 | 711 | ||
| 698 | tty->echo_overrun = 1; | 712 | ldata->echo_overrun = 1; |
| 699 | } else { | 713 | } else { |
| 700 | new_byte_pos = tty->echo_pos + tty->echo_cnt; | 714 | new_byte_pos = tty->echo_pos + tty->echo_cnt; |
| 701 | new_byte_pos &= N_TTY_BUF_SIZE - 1; | 715 | new_byte_pos &= N_TTY_BUF_SIZE - 1; |
| @@ -845,9 +859,10 @@ static void echo_char(unsigned char c, struct tty_struct *tty) | |||
| 845 | 859 | ||
| 846 | static inline void finish_erasing(struct tty_struct *tty) | 860 | static inline void finish_erasing(struct tty_struct *tty) |
| 847 | { | 861 | { |
| 848 | if (tty->erasing) { | 862 | struct n_tty_data *ldata = tty->disc_data; |
| 863 | if (ldata->erasing) { | ||
| 849 | echo_char_raw('/', tty); | 864 | echo_char_raw('/', tty); |
| 850 | tty->erasing = 0; | 865 | ldata->erasing = 0; |
| 851 | } | 866 | } |
| 852 | } | 867 | } |
| 853 | 868 | ||
| @@ -865,6 +880,7 @@ static inline void finish_erasing(struct tty_struct *tty) | |||
| 865 | 880 | ||
| 866 | static void eraser(unsigned char c, struct tty_struct *tty) | 881 | static void eraser(unsigned char c, struct tty_struct *tty) |
| 867 | { | 882 | { |
| 883 | struct n_tty_data *ldata = tty->disc_data; | ||
| 868 | enum { ERASE, WERASE, KILL } kill_type; | 884 | enum { ERASE, WERASE, KILL } kill_type; |
| 869 | int head, seen_alnums, cnt; | 885 | int head, seen_alnums, cnt; |
| 870 | unsigned long flags; | 886 | unsigned long flags; |
| @@ -932,9 +948,9 @@ static void eraser(unsigned char c, struct tty_struct *tty) | |||
| 932 | spin_unlock_irqrestore(&tty->read_lock, flags); | 948 | spin_unlock_irqrestore(&tty->read_lock, flags); |
| 933 | if (L_ECHO(tty)) { | 949 | if (L_ECHO(tty)) { |
| 934 | if (L_ECHOPRT(tty)) { | 950 | if (L_ECHOPRT(tty)) { |
| 935 | if (!tty->erasing) { | 951 | if (!ldata->erasing) { |
| 936 | echo_char_raw('\\', tty); | 952 | echo_char_raw('\\', tty); |
| 937 | tty->erasing = 1; | 953 | ldata->erasing = 1; |
| 938 | } | 954 | } |
| 939 | /* if cnt > 1, output a multi-byte character */ | 955 | /* if cnt > 1, output a multi-byte character */ |
| 940 | echo_char(c, tty); | 956 | echo_char(c, tty); |
| @@ -1056,16 +1072,17 @@ static inline void n_tty_receive_break(struct tty_struct *tty) | |||
| 1056 | 1072 | ||
| 1057 | static inline void n_tty_receive_overrun(struct tty_struct *tty) | 1073 | static inline void n_tty_receive_overrun(struct tty_struct *tty) |
| 1058 | { | 1074 | { |
| 1075 | struct n_tty_data *ldata = tty->disc_data; | ||
| 1059 | char buf[64]; | 1076 | char buf[64]; |
| 1060 | 1077 | ||
| 1061 | tty->num_overrun++; | 1078 | ldata->num_overrun++; |
| 1062 | if (time_before(tty->overrun_time, jiffies - HZ) || | 1079 | if (time_after(jiffies, ldata->overrun_time + HZ) || |
| 1063 | time_after(tty->overrun_time, jiffies)) { | 1080 | time_after(ldata->overrun_time, jiffies)) { |
| 1064 | printk(KERN_WARNING "%s: %d input overrun(s)\n", | 1081 | printk(KERN_WARNING "%s: %d input overrun(s)\n", |
| 1065 | tty_name(tty, buf), | 1082 | tty_name(tty, buf), |
| 1066 | tty->num_overrun); | 1083 | ldata->num_overrun); |
| 1067 | tty->overrun_time = jiffies; | 1084 | ldata->overrun_time = jiffies; |
| 1068 | tty->num_overrun = 0; | 1085 | ldata->num_overrun = 0; |
| 1069 | } | 1086 | } |
| 1070 | } | 1087 | } |
| 1071 | 1088 | ||
| @@ -1105,10 +1122,11 @@ static inline void n_tty_receive_parity_error(struct tty_struct *tty, | |||
| 1105 | 1122 | ||
| 1106 | static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) | 1123 | static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) |
| 1107 | { | 1124 | { |
| 1125 | struct n_tty_data *ldata = tty->disc_data; | ||
| 1108 | unsigned long flags; | 1126 | unsigned long flags; |
| 1109 | int parmrk; | 1127 | int parmrk; |
| 1110 | 1128 | ||
| 1111 | if (tty->raw) { | 1129 | if (ldata->raw) { |
| 1112 | put_tty_queue(c, tty); | 1130 | put_tty_queue(c, tty); |
| 1113 | return; | 1131 | return; |
| 1114 | } | 1132 | } |
| @@ -1147,8 +1165,8 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) | |||
| 1147 | * handle specially, do shortcut processing to speed things | 1165 | * handle specially, do shortcut processing to speed things |
| 1148 | * up. | 1166 | * up. |
| 1149 | */ | 1167 | */ |
| 1150 | if (!test_bit(c, tty->process_char_map) || tty->lnext) { | 1168 | if (!test_bit(c, tty->process_char_map) || ldata->lnext) { |
| 1151 | tty->lnext = 0; | 1169 | ldata->lnext = 0; |
| 1152 | parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0; | 1170 | parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0; |
| 1153 | if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) { | 1171 | if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) { |
| 1154 | /* beep if no space */ | 1172 | /* beep if no space */ |
| @@ -1222,7 +1240,7 @@ send_signal: | |||
| 1222 | } else if (c == '\n' && I_INLCR(tty)) | 1240 | } else if (c == '\n' && I_INLCR(tty)) |
| 1223 | c = '\r'; | 1241 | c = '\r'; |
| 1224 | 1242 | ||
| 1225 | if (tty->icanon) { | 1243 | if (ldata->icanon) { |
| 1226 | if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) || | 1244 | if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) || |
| 1227 | (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) { | 1245 | (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) { |
| 1228 | eraser(c, tty); | 1246 | eraser(c, tty); |
| @@ -1230,7 +1248,7 @@ send_signal: | |||
| 1230 | return; | 1248 | return; |
| 1231 | } | 1249 | } |
| 1232 | if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) { | 1250 | if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) { |
| 1233 | tty->lnext = 1; | 1251 | ldata->lnext = 1; |
| 1234 | if (L_ECHO(tty)) { | 1252 | if (L_ECHO(tty)) { |
| 1235 | finish_erasing(tty); | 1253 | finish_erasing(tty); |
| 1236 | if (L_ECHOCTL(tty)) { | 1254 | if (L_ECHOCTL(tty)) { |
| @@ -1373,13 +1391,14 @@ static void n_tty_write_wakeup(struct tty_struct *tty) | |||
| 1373 | static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, | 1391 | static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, |
| 1374 | char *fp, int count) | 1392 | char *fp, int count) |
| 1375 | { | 1393 | { |
| 1394 | struct n_tty_data *ldata = tty->disc_data; | ||
| 1376 | const unsigned char *p; | 1395 | const unsigned char *p; |
| 1377 | char *f, flags = TTY_NORMAL; | 1396 | char *f, flags = TTY_NORMAL; |
| 1378 | int i; | 1397 | int i; |
| 1379 | char buf[64]; | 1398 | char buf[64]; |
| 1380 | unsigned long cpuflags; | 1399 | unsigned long cpuflags; |
| 1381 | 1400 | ||
| 1382 | if (tty->real_raw) { | 1401 | if (ldata->real_raw) { |
| 1383 | spin_lock_irqsave(&tty->read_lock, cpuflags); | 1402 | spin_lock_irqsave(&tty->read_lock, cpuflags); |
| 1384 | i = min(N_TTY_BUF_SIZE - tty->read_cnt, | 1403 | i = min(N_TTY_BUF_SIZE - tty->read_cnt, |
| 1385 | N_TTY_BUF_SIZE - tty->read_head); | 1404 | N_TTY_BUF_SIZE - tty->read_head); |
| @@ -1427,7 +1446,7 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, | |||
| 1427 | 1446 | ||
| 1428 | n_tty_set_room(tty); | 1447 | n_tty_set_room(tty); |
| 1429 | 1448 | ||
| 1430 | if ((!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) || | 1449 | if ((!ldata->icanon && (tty->read_cnt >= tty->minimum_to_wake)) || |
| 1431 | L_EXTPROC(tty)) { | 1450 | L_EXTPROC(tty)) { |
| 1432 | kill_fasync(&tty->fasync, SIGIO, POLL_IN); | 1451 | kill_fasync(&tty->fasync, SIGIO, POLL_IN); |
| 1433 | if (waitqueue_active(&tty->read_wait)) | 1452 | if (waitqueue_active(&tty->read_wait)) |
| @@ -1471,6 +1490,7 @@ int is_ignored(int sig) | |||
| 1471 | 1490 | ||
| 1472 | static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) | 1491 | static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) |
| 1473 | { | 1492 | { |
| 1493 | struct n_tty_data *ldata = tty->disc_data; | ||
| 1474 | int canon_change = 1; | 1494 | int canon_change = 1; |
| 1475 | 1495 | ||
| 1476 | if (old) | 1496 | if (old) |
| @@ -1479,16 +1499,16 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) | |||
| 1479 | memset(&tty->read_flags, 0, sizeof tty->read_flags); | 1499 | memset(&tty->read_flags, 0, sizeof tty->read_flags); |
| 1480 | tty->canon_head = tty->read_tail; | 1500 | tty->canon_head = tty->read_tail; |
| 1481 | tty->canon_data = 0; | 1501 | tty->canon_data = 0; |
| 1482 | tty->erasing = 0; | 1502 | ldata->erasing = 0; |
| 1483 | } | 1503 | } |
| 1484 | 1504 | ||
| 1485 | if (canon_change && !L_ICANON(tty) && tty->read_cnt) | 1505 | if (canon_change && !L_ICANON(tty) && tty->read_cnt) |
| 1486 | wake_up_interruptible(&tty->read_wait); | 1506 | wake_up_interruptible(&tty->read_wait); |
| 1487 | 1507 | ||
| 1488 | tty->icanon = (L_ICANON(tty) != 0); | 1508 | ldata->icanon = (L_ICANON(tty) != 0); |
| 1489 | if (test_bit(TTY_HW_COOK_IN, &tty->flags)) { | 1509 | if (test_bit(TTY_HW_COOK_IN, &tty->flags)) { |
| 1490 | tty->raw = 1; | 1510 | ldata->raw = 1; |
| 1491 | tty->real_raw = 1; | 1511 | ldata->real_raw = 1; |
| 1492 | n_tty_set_room(tty); | 1512 | n_tty_set_room(tty); |
| 1493 | return; | 1513 | return; |
| 1494 | } | 1514 | } |
| @@ -1531,16 +1551,16 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) | |||
| 1531 | set_bit(SUSP_CHAR(tty), tty->process_char_map); | 1551 | set_bit(SUSP_CHAR(tty), tty->process_char_map); |
| 1532 | } | 1552 | } |
| 1533 | clear_bit(__DISABLED_CHAR, tty->process_char_map); | 1553 | clear_bit(__DISABLED_CHAR, tty->process_char_map); |
| 1534 | tty->raw = 0; | 1554 | ldata->raw = 0; |
| 1535 | tty->real_raw = 0; | 1555 | ldata->real_raw = 0; |
| 1536 | } else { | 1556 | } else { |
| 1537 | tty->raw = 1; | 1557 | ldata->raw = 1; |
| 1538 | if ((I_IGNBRK(tty) || (!I_BRKINT(tty) && !I_PARMRK(tty))) && | 1558 | if ((I_IGNBRK(tty) || (!I_BRKINT(tty) && !I_PARMRK(tty))) && |
| 1539 | (I_IGNPAR(tty) || !I_INPCK(tty)) && | 1559 | (I_IGNPAR(tty) || !I_INPCK(tty)) && |
| 1540 | (tty->driver->flags & TTY_DRIVER_REAL_RAW)) | 1560 | (tty->driver->flags & TTY_DRIVER_REAL_RAW)) |
| 1541 | tty->real_raw = 1; | 1561 | ldata->real_raw = 1; |
| 1542 | else | 1562 | else |
| 1543 | tty->real_raw = 0; | 1563 | ldata->real_raw = 0; |
| 1544 | } | 1564 | } |
| 1545 | n_tty_set_room(tty); | 1565 | n_tty_set_room(tty); |
| 1546 | /* The termios change make the tty ready for I/O */ | 1566 | /* The termios change make the tty ready for I/O */ |
| @@ -1589,6 +1609,8 @@ static int n_tty_open(struct tty_struct *tty) | |||
| 1589 | if (!ldata) | 1609 | if (!ldata) |
| 1590 | goto err; | 1610 | goto err; |
| 1591 | 1611 | ||
| 1612 | ldata->overrun_time = jiffies; | ||
| 1613 | |||
| 1592 | /* These are ugly. Currently a malloc failure here can panic */ | 1614 | /* These are ugly. Currently a malloc failure here can panic */ |
| 1593 | tty->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); | 1615 | tty->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); |
| 1594 | tty->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); | 1616 | tty->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); |
| @@ -1598,7 +1620,7 @@ static int n_tty_open(struct tty_struct *tty) | |||
| 1598 | tty->disc_data = ldata; | 1620 | tty->disc_data = ldata; |
| 1599 | reset_buffer_flags(tty); | 1621 | reset_buffer_flags(tty); |
| 1600 | tty_unthrottle(tty); | 1622 | tty_unthrottle(tty); |
| 1601 | tty->column = 0; | 1623 | ldata->column = 0; |
| 1602 | n_tty_set_termios(tty, NULL); | 1624 | n_tty_set_termios(tty, NULL); |
| 1603 | tty->minimum_to_wake = 1; | 1625 | tty->minimum_to_wake = 1; |
| 1604 | tty->closing = 0; | 1626 | tty->closing = 0; |
| @@ -1614,8 +1636,10 @@ err: | |||
| 1614 | 1636 | ||
| 1615 | static inline int input_available_p(struct tty_struct *tty, int amt) | 1637 | static inline int input_available_p(struct tty_struct *tty, int amt) |
| 1616 | { | 1638 | { |
| 1639 | struct n_tty_data *ldata = tty->disc_data; | ||
| 1640 | |||
| 1617 | tty_flush_to_ldisc(tty); | 1641 | tty_flush_to_ldisc(tty); |
| 1618 | if (tty->icanon && !L_EXTPROC(tty)) { | 1642 | if (ldata->icanon && !L_EXTPROC(tty)) { |
| 1619 | if (tty->canon_data) | 1643 | if (tty->canon_data) |
| 1620 | return 1; | 1644 | return 1; |
| 1621 | } else if (tty->read_cnt >= (amt ? amt : 1)) | 1645 | } else if (tty->read_cnt >= (amt ? amt : 1)) |
| @@ -1646,6 +1670,7 @@ static int copy_from_read_buf(struct tty_struct *tty, | |||
| 1646 | size_t *nr) | 1670 | size_t *nr) |
| 1647 | 1671 | ||
| 1648 | { | 1672 | { |
| 1673 | struct n_tty_data *ldata = tty->disc_data; | ||
| 1649 | int retval; | 1674 | int retval; |
| 1650 | size_t n; | 1675 | size_t n; |
| 1651 | unsigned long flags; | 1676 | unsigned long flags; |
| @@ -1662,12 +1687,12 @@ static int copy_from_read_buf(struct tty_struct *tty, | |||
| 1662 | is_eof = n == 1 && | 1687 | is_eof = n == 1 && |
| 1663 | tty->read_buf[tty->read_tail] == EOF_CHAR(tty); | 1688 | tty->read_buf[tty->read_tail] == EOF_CHAR(tty); |
| 1664 | tty_audit_add_data(tty, &tty->read_buf[tty->read_tail], n, | 1689 | tty_audit_add_data(tty, &tty->read_buf[tty->read_tail], n, |
| 1665 | tty->icanon); | 1690 | ldata->icanon); |
| 1666 | spin_lock_irqsave(&tty->read_lock, flags); | 1691 | spin_lock_irqsave(&tty->read_lock, flags); |
| 1667 | tty->read_tail = (tty->read_tail + n) & (N_TTY_BUF_SIZE-1); | 1692 | tty->read_tail = (tty->read_tail + n) & (N_TTY_BUF_SIZE-1); |
| 1668 | tty->read_cnt -= n; | 1693 | tty->read_cnt -= n; |
| 1669 | /* Turn single EOF into zero-length read */ | 1694 | /* Turn single EOF into zero-length read */ |
| 1670 | if (L_EXTPROC(tty) && tty->icanon && is_eof && !tty->read_cnt) | 1695 | if (L_EXTPROC(tty) && ldata->icanon && is_eof && !tty->read_cnt) |
| 1671 | n = 0; | 1696 | n = 0; |
| 1672 | spin_unlock_irqrestore(&tty->read_lock, flags); | 1697 | spin_unlock_irqrestore(&tty->read_lock, flags); |
| 1673 | *b += n; | 1698 | *b += n; |
| @@ -1736,6 +1761,7 @@ static int job_control(struct tty_struct *tty, struct file *file) | |||
| 1736 | static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, | 1761 | static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, |
| 1737 | unsigned char __user *buf, size_t nr) | 1762 | unsigned char __user *buf, size_t nr) |
| 1738 | { | 1763 | { |
| 1764 | struct n_tty_data *ldata = tty->disc_data; | ||
| 1739 | unsigned char __user *b = buf; | 1765 | unsigned char __user *b = buf; |
| 1740 | DECLARE_WAITQUEUE(wait, current); | 1766 | DECLARE_WAITQUEUE(wait, current); |
| 1741 | int c; | 1767 | int c; |
| @@ -1753,7 +1779,7 @@ do_it_again: | |||
| 1753 | 1779 | ||
| 1754 | minimum = time = 0; | 1780 | minimum = time = 0; |
| 1755 | timeout = MAX_SCHEDULE_TIMEOUT; | 1781 | timeout = MAX_SCHEDULE_TIMEOUT; |
| 1756 | if (!tty->icanon) { | 1782 | if (!ldata->icanon) { |
| 1757 | time = (HZ / 10) * TIME_CHAR(tty); | 1783 | time = (HZ / 10) * TIME_CHAR(tty); |
| 1758 | minimum = MIN_CHAR(tty); | 1784 | minimum = MIN_CHAR(tty); |
| 1759 | if (minimum) { | 1785 | if (minimum) { |
| @@ -1846,7 +1872,7 @@ do_it_again: | |||
| 1846 | nr--; | 1872 | nr--; |
| 1847 | } | 1873 | } |
| 1848 | 1874 | ||
| 1849 | if (tty->icanon && !L_EXTPROC(tty)) { | 1875 | if (ldata->icanon && !L_EXTPROC(tty)) { |
| 1850 | /* N.B. avoid overrun if nr == 0 */ | 1876 | /* N.B. avoid overrun if nr == 0 */ |
| 1851 | spin_lock_irqsave(&tty->read_lock, flags); | 1877 | spin_lock_irqsave(&tty->read_lock, flags); |
| 1852 | while (nr && tty->read_cnt) { | 1878 | while (nr && tty->read_cnt) { |
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index e835a5b8d089..67b024ca16ec 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c | |||
| @@ -2932,7 +2932,6 @@ void initialize_tty_struct(struct tty_struct *tty, | |||
| 2932 | tty_ldisc_init(tty); | 2932 | tty_ldisc_init(tty); |
| 2933 | tty->session = NULL; | 2933 | tty->session = NULL; |
| 2934 | tty->pgrp = NULL; | 2934 | tty->pgrp = NULL; |
| 2935 | tty->overrun_time = jiffies; | ||
| 2936 | tty_buffer_init(tty); | 2935 | tty_buffer_init(tty); |
| 2937 | mutex_init(&tty->legacy_mutex); | 2936 | mutex_init(&tty->legacy_mutex); |
| 2938 | mutex_init(&tty->termios_mutex); | 2937 | mutex_init(&tty->termios_mutex); |
diff --git a/include/linux/tty.h b/include/linux/tty.h index f02712da5d85..de590cec973b 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h | |||
| @@ -270,13 +270,8 @@ struct tty_struct { | |||
| 270 | * historical reasons, this is included in the tty structure. | 270 | * historical reasons, this is included in the tty structure. |
| 271 | * Mostly locked by the BKL. | 271 | * Mostly locked by the BKL. |
| 272 | */ | 272 | */ |
| 273 | unsigned int column; | ||
| 274 | unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1; | ||
| 275 | unsigned char closing:1; | 273 | unsigned char closing:1; |
| 276 | unsigned char echo_overrun:1; | ||
| 277 | unsigned short minimum_to_wake; | 274 | unsigned short minimum_to_wake; |
| 278 | unsigned long overrun_time; | ||
| 279 | int num_overrun; | ||
| 280 | unsigned long process_char_map[256/(8*sizeof(unsigned long))]; | 275 | unsigned long process_char_map[256/(8*sizeof(unsigned long))]; |
| 281 | char *read_buf; | 276 | char *read_buf; |
| 282 | int read_head; | 277 | int read_head; |
