aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/n_tty.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty/n_tty.c')
-rw-r--r--drivers/tty/n_tty.c123
1 files changed, 72 insertions, 51 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 4794537a50ff..0a6fcda96152 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -96,6 +96,11 @@ struct n_tty_data {
96 int canon_data; 96 int canon_data;
97 unsigned long canon_head; 97 unsigned long canon_head;
98 unsigned int canon_column; 98 unsigned int canon_column;
99
100 struct mutex atomic_read_lock;
101 struct mutex output_lock;
102 struct mutex echo_lock;
103 spinlock_t read_lock;
99}; 104};
100 105
101static inline int tty_put_user(struct tty_struct *tty, unsigned char x, 106static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
@@ -171,14 +176,15 @@ static void put_tty_queue_nolock(unsigned char c, struct tty_struct *tty)
171 176
172static void put_tty_queue(unsigned char c, struct tty_struct *tty) 177static void put_tty_queue(unsigned char c, struct tty_struct *tty)
173{ 178{
179 struct n_tty_data *ldata = tty->disc_data;
174 unsigned long flags; 180 unsigned long flags;
175 /* 181 /*
176 * The problem of stomping on the buffers ends here. 182 * The problem of stomping on the buffers ends here.
177 * Why didn't anyone see this one coming? --AJK 183 * Why didn't anyone see this one coming? --AJK
178 */ 184 */
179 spin_lock_irqsave(&tty->read_lock, flags); 185 spin_lock_irqsave(&ldata->read_lock, flags);
180 put_tty_queue_nolock(c, tty); 186 put_tty_queue_nolock(c, tty);
181 spin_unlock_irqrestore(&tty->read_lock, flags); 187 spin_unlock_irqrestore(&ldata->read_lock, flags);
182} 188}
183 189
184/** 190/**
@@ -212,13 +218,13 @@ static void reset_buffer_flags(struct tty_struct *tty)
212 struct n_tty_data *ldata = tty->disc_data; 218 struct n_tty_data *ldata = tty->disc_data;
213 unsigned long flags; 219 unsigned long flags;
214 220
215 spin_lock_irqsave(&tty->read_lock, flags); 221 spin_lock_irqsave(&ldata->read_lock, flags);
216 ldata->read_head = ldata->read_tail = ldata->read_cnt = 0; 222 ldata->read_head = ldata->read_tail = ldata->read_cnt = 0;
217 spin_unlock_irqrestore(&tty->read_lock, flags); 223 spin_unlock_irqrestore(&ldata->read_lock, flags);
218 224
219 mutex_lock(&tty->echo_lock); 225 mutex_lock(&ldata->echo_lock);
220 ldata->echo_pos = ldata->echo_cnt = ldata->echo_overrun = 0; 226 ldata->echo_pos = ldata->echo_cnt = ldata->echo_overrun = 0;
221 mutex_unlock(&tty->echo_lock); 227 mutex_unlock(&ldata->echo_lock);
222 228
223 ldata->canon_head = ldata->canon_data = ldata->erasing = 0; 229 ldata->canon_head = ldata->canon_data = ldata->erasing = 0;
224 bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE); 230 bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE);
@@ -270,7 +276,7 @@ static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)
270 unsigned long flags; 276 unsigned long flags;
271 ssize_t n = 0; 277 ssize_t n = 0;
272 278
273 spin_lock_irqsave(&tty->read_lock, flags); 279 spin_lock_irqsave(&ldata->read_lock, flags);
274 if (!ldata->icanon) { 280 if (!ldata->icanon) {
275 n = ldata->read_cnt; 281 n = ldata->read_cnt;
276 } else if (ldata->canon_data) { 282 } else if (ldata->canon_data) {
@@ -278,7 +284,7 @@ static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)
278 ldata->canon_head - ldata->read_tail : 284 ldata->canon_head - ldata->read_tail :
279 ldata->canon_head + (N_TTY_BUF_SIZE - ldata->read_tail); 285 ldata->canon_head + (N_TTY_BUF_SIZE - ldata->read_tail);
280 } 286 }
281 spin_unlock_irqrestore(&tty->read_lock, flags); 287 spin_unlock_irqrestore(&ldata->read_lock, flags);
282 return n; 288 return n;
283} 289}
284 290
@@ -408,14 +414,15 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space)
408 414
409static int process_output(unsigned char c, struct tty_struct *tty) 415static int process_output(unsigned char c, struct tty_struct *tty)
410{ 416{
417 struct n_tty_data *ldata = tty->disc_data;
411 int space, retval; 418 int space, retval;
412 419
413 mutex_lock(&tty->output_lock); 420 mutex_lock(&ldata->output_lock);
414 421
415 space = tty_write_room(tty); 422 space = tty_write_room(tty);
416 retval = do_output_char(c, tty, space); 423 retval = do_output_char(c, tty, space);
417 424
418 mutex_unlock(&tty->output_lock); 425 mutex_unlock(&ldata->output_lock);
419 if (retval < 0) 426 if (retval < 0)
420 return -1; 427 return -1;
421 else 428 else
@@ -449,11 +456,11 @@ static ssize_t process_output_block(struct tty_struct *tty,
449 int i; 456 int i;
450 const unsigned char *cp; 457 const unsigned char *cp;
451 458
452 mutex_lock(&tty->output_lock); 459 mutex_lock(&ldata->output_lock);
453 460
454 space = tty_write_room(tty); 461 space = tty_write_room(tty);
455 if (!space) { 462 if (!space) {
456 mutex_unlock(&tty->output_lock); 463 mutex_unlock(&ldata->output_lock);
457 return 0; 464 return 0;
458 } 465 }
459 if (nr > space) 466 if (nr > space)
@@ -496,7 +503,7 @@ static ssize_t process_output_block(struct tty_struct *tty,
496break_out: 503break_out:
497 i = tty->ops->write(tty, buf, i); 504 i = tty->ops->write(tty, buf, i);
498 505
499 mutex_unlock(&tty->output_lock); 506 mutex_unlock(&ldata->output_lock);
500 return i; 507 return i;
501} 508}
502 509
@@ -536,8 +543,8 @@ static void process_echoes(struct tty_struct *tty)
536 if (!ldata->echo_cnt) 543 if (!ldata->echo_cnt)
537 return; 544 return;
538 545
539 mutex_lock(&tty->output_lock); 546 mutex_lock(&ldata->output_lock);
540 mutex_lock(&tty->echo_lock); 547 mutex_lock(&ldata->echo_lock);
541 548
542 space = tty_write_room(tty); 549 space = tty_write_room(tty);
543 550
@@ -682,8 +689,8 @@ static void process_echoes(struct tty_struct *tty)
682 ldata->echo_overrun = 0; 689 ldata->echo_overrun = 0;
683 } 690 }
684 691
685 mutex_unlock(&tty->echo_lock); 692 mutex_unlock(&ldata->echo_lock);
686 mutex_unlock(&tty->output_lock); 693 mutex_unlock(&ldata->output_lock);
687 694
688 if (tty->ops->flush_chars) 695 if (tty->ops->flush_chars)
689 tty->ops->flush_chars(tty); 696 tty->ops->flush_chars(tty);
@@ -748,12 +755,14 @@ static void add_echo_byte(unsigned char c, struct tty_struct *tty)
748 755
749static void echo_move_back_col(struct tty_struct *tty) 756static void echo_move_back_col(struct tty_struct *tty)
750{ 757{
751 mutex_lock(&tty->echo_lock); 758 struct n_tty_data *ldata = tty->disc_data;
759
760 mutex_lock(&ldata->echo_lock);
752 761
753 add_echo_byte(ECHO_OP_START, tty); 762 add_echo_byte(ECHO_OP_START, tty);
754 add_echo_byte(ECHO_OP_MOVE_BACK_COL, tty); 763 add_echo_byte(ECHO_OP_MOVE_BACK_COL, tty);
755 764
756 mutex_unlock(&tty->echo_lock); 765 mutex_unlock(&ldata->echo_lock);
757} 766}
758 767
759/** 768/**
@@ -768,12 +777,14 @@ static void echo_move_back_col(struct tty_struct *tty)
768 777
769static void echo_set_canon_col(struct tty_struct *tty) 778static void echo_set_canon_col(struct tty_struct *tty)
770{ 779{
771 mutex_lock(&tty->echo_lock); 780 struct n_tty_data *ldata = tty->disc_data;
781
782 mutex_lock(&ldata->echo_lock);
772 783
773 add_echo_byte(ECHO_OP_START, tty); 784 add_echo_byte(ECHO_OP_START, tty);
774 add_echo_byte(ECHO_OP_SET_CANON_COL, tty); 785 add_echo_byte(ECHO_OP_SET_CANON_COL, tty);
775 786
776 mutex_unlock(&tty->echo_lock); 787 mutex_unlock(&ldata->echo_lock);
777} 788}
778 789
779/** 790/**
@@ -796,7 +807,9 @@ static void echo_set_canon_col(struct tty_struct *tty)
796static void echo_erase_tab(unsigned int num_chars, int after_tab, 807static void echo_erase_tab(unsigned int num_chars, int after_tab,
797 struct tty_struct *tty) 808 struct tty_struct *tty)
798{ 809{
799 mutex_lock(&tty->echo_lock); 810 struct n_tty_data *ldata = tty->disc_data;
811
812 mutex_lock(&ldata->echo_lock);
800 813
801 add_echo_byte(ECHO_OP_START, tty); 814 add_echo_byte(ECHO_OP_START, tty);
802 add_echo_byte(ECHO_OP_ERASE_TAB, tty); 815 add_echo_byte(ECHO_OP_ERASE_TAB, tty);
@@ -810,7 +823,7 @@ static void echo_erase_tab(unsigned int num_chars, int after_tab,
810 823
811 add_echo_byte(num_chars, tty); 824 add_echo_byte(num_chars, tty);
812 825
813 mutex_unlock(&tty->echo_lock); 826 mutex_unlock(&ldata->echo_lock);
814} 827}
815 828
816/** 829/**
@@ -828,7 +841,9 @@ static void echo_erase_tab(unsigned int num_chars, int after_tab,
828 841
829static void echo_char_raw(unsigned char c, struct tty_struct *tty) 842static void echo_char_raw(unsigned char c, struct tty_struct *tty)
830{ 843{
831 mutex_lock(&tty->echo_lock); 844 struct n_tty_data *ldata = tty->disc_data;
845
846 mutex_lock(&ldata->echo_lock);
832 847
833 if (c == ECHO_OP_START) { 848 if (c == ECHO_OP_START) {
834 add_echo_byte(ECHO_OP_START, tty); 849 add_echo_byte(ECHO_OP_START, tty);
@@ -837,7 +852,7 @@ static void echo_char_raw(unsigned char c, struct tty_struct *tty)
837 add_echo_byte(c, tty); 852 add_echo_byte(c, tty);
838 } 853 }
839 854
840 mutex_unlock(&tty->echo_lock); 855 mutex_unlock(&ldata->echo_lock);
841} 856}
842 857
843/** 858/**
@@ -856,7 +871,9 @@ static void echo_char_raw(unsigned char c, struct tty_struct *tty)
856 871
857static void echo_char(unsigned char c, struct tty_struct *tty) 872static void echo_char(unsigned char c, struct tty_struct *tty)
858{ 873{
859 mutex_lock(&tty->echo_lock); 874 struct n_tty_data *ldata = tty->disc_data;
875
876 mutex_lock(&ldata->echo_lock);
860 877
861 if (c == ECHO_OP_START) { 878 if (c == ECHO_OP_START) {
862 add_echo_byte(ECHO_OP_START, tty); 879 add_echo_byte(ECHO_OP_START, tty);
@@ -867,7 +884,7 @@ static void echo_char(unsigned char c, struct tty_struct *tty)
867 add_echo_byte(c, tty); 884 add_echo_byte(c, tty);
868 } 885 }
869 886
870 mutex_unlock(&tty->echo_lock); 887 mutex_unlock(&ldata->echo_lock);
871} 888}
872 889
873/** 890/**
@@ -914,19 +931,19 @@ static void eraser(unsigned char c, struct tty_struct *tty)
914 kill_type = WERASE; 931 kill_type = WERASE;
915 else { 932 else {
916 if (!L_ECHO(tty)) { 933 if (!L_ECHO(tty)) {
917 spin_lock_irqsave(&tty->read_lock, flags); 934 spin_lock_irqsave(&ldata->read_lock, flags);
918 ldata->read_cnt -= ((ldata->read_head - ldata->canon_head) & 935 ldata->read_cnt -= ((ldata->read_head - ldata->canon_head) &
919 (N_TTY_BUF_SIZE - 1)); 936 (N_TTY_BUF_SIZE - 1));
920 ldata->read_head = ldata->canon_head; 937 ldata->read_head = ldata->canon_head;
921 spin_unlock_irqrestore(&tty->read_lock, flags); 938 spin_unlock_irqrestore(&ldata->read_lock, flags);
922 return; 939 return;
923 } 940 }
924 if (!L_ECHOK(tty) || !L_ECHOKE(tty) || !L_ECHOE(tty)) { 941 if (!L_ECHOK(tty) || !L_ECHOKE(tty) || !L_ECHOE(tty)) {
925 spin_lock_irqsave(&tty->read_lock, flags); 942 spin_lock_irqsave(&ldata->read_lock, flags);
926 ldata->read_cnt -= ((ldata->read_head - ldata->canon_head) & 943 ldata->read_cnt -= ((ldata->read_head - ldata->canon_head) &
927 (N_TTY_BUF_SIZE - 1)); 944 (N_TTY_BUF_SIZE - 1));
928 ldata->read_head = ldata->canon_head; 945 ldata->read_head = ldata->canon_head;
929 spin_unlock_irqrestore(&tty->read_lock, flags); 946 spin_unlock_irqrestore(&ldata->read_lock, flags);
930 finish_erasing(tty); 947 finish_erasing(tty);
931 echo_char(KILL_CHAR(tty), tty); 948 echo_char(KILL_CHAR(tty), tty);
932 /* Add a newline if ECHOK is on and ECHOKE is off. */ 949 /* Add a newline if ECHOK is on and ECHOKE is off. */
@@ -960,10 +977,10 @@ static void eraser(unsigned char c, struct tty_struct *tty)
960 break; 977 break;
961 } 978 }
962 cnt = (ldata->read_head - head) & (N_TTY_BUF_SIZE-1); 979 cnt = (ldata->read_head - head) & (N_TTY_BUF_SIZE-1);
963 spin_lock_irqsave(&tty->read_lock, flags); 980 spin_lock_irqsave(&ldata->read_lock, flags);
964 ldata->read_head = head; 981 ldata->read_head = head;
965 ldata->read_cnt -= cnt; 982 ldata->read_cnt -= cnt;
966 spin_unlock_irqrestore(&tty->read_lock, flags); 983 spin_unlock_irqrestore(&ldata->read_lock, flags);
967 if (L_ECHO(tty)) { 984 if (L_ECHO(tty)) {
968 if (L_ECHOPRT(tty)) { 985 if (L_ECHOPRT(tty)) {
969 if (!ldata->erasing) { 986 if (!ldata->erasing) {
@@ -1338,12 +1355,12 @@ send_signal:
1338 put_tty_queue(c, tty); 1355 put_tty_queue(c, tty);
1339 1356
1340handle_newline: 1357handle_newline:
1341 spin_lock_irqsave(&tty->read_lock, flags); 1358 spin_lock_irqsave(&ldata->read_lock, flags);
1342 set_bit(ldata->read_head, ldata->read_flags); 1359 set_bit(ldata->read_head, ldata->read_flags);
1343 put_tty_queue_nolock(c, tty); 1360 put_tty_queue_nolock(c, tty);
1344 ldata->canon_head = ldata->read_head; 1361 ldata->canon_head = ldata->read_head;
1345 ldata->canon_data++; 1362 ldata->canon_data++;
1346 spin_unlock_irqrestore(&tty->read_lock, flags); 1363 spin_unlock_irqrestore(&ldata->read_lock, flags);
1347 kill_fasync(&tty->fasync, SIGIO, POLL_IN); 1364 kill_fasync(&tty->fasync, SIGIO, POLL_IN);
1348 if (waitqueue_active(&tty->read_wait)) 1365 if (waitqueue_active(&tty->read_wait))
1349 wake_up_interruptible(&tty->read_wait); 1366 wake_up_interruptible(&tty->read_wait);
@@ -1417,7 +1434,7 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
1417 unsigned long cpuflags; 1434 unsigned long cpuflags;
1418 1435
1419 if (ldata->real_raw) { 1436 if (ldata->real_raw) {
1420 spin_lock_irqsave(&tty->read_lock, cpuflags); 1437 spin_lock_irqsave(&ldata->read_lock, cpuflags);
1421 i = min(N_TTY_BUF_SIZE - ldata->read_cnt, 1438 i = min(N_TTY_BUF_SIZE - ldata->read_cnt,
1422 N_TTY_BUF_SIZE - ldata->read_head); 1439 N_TTY_BUF_SIZE - ldata->read_head);
1423 i = min(count, i); 1440 i = min(count, i);
@@ -1433,7 +1450,7 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
1433 memcpy(ldata->read_buf + ldata->read_head, cp, i); 1450 memcpy(ldata->read_buf + ldata->read_head, cp, i);
1434 ldata->read_head = (ldata->read_head + i) & (N_TTY_BUF_SIZE-1); 1451 ldata->read_head = (ldata->read_head + i) & (N_TTY_BUF_SIZE-1);
1435 ldata->read_cnt += i; 1452 ldata->read_cnt += i;
1436 spin_unlock_irqrestore(&tty->read_lock, cpuflags); 1453 spin_unlock_irqrestore(&ldata->read_lock, cpuflags);
1437 } else { 1454 } else {
1438 for (i = count, p = cp, f = fp; i; i--, p++) { 1455 for (i = count, p = cp, f = fp; i; i--, p++) {
1439 if (f) 1456 if (f)
@@ -1626,6 +1643,10 @@ static int n_tty_open(struct tty_struct *tty)
1626 goto err; 1643 goto err;
1627 1644
1628 ldata->overrun_time = jiffies; 1645 ldata->overrun_time = jiffies;
1646 mutex_init(&ldata->atomic_read_lock);
1647 mutex_init(&ldata->output_lock);
1648 mutex_init(&ldata->echo_lock);
1649 spin_lock_init(&ldata->read_lock);
1629 1650
1630 /* These are ugly. Currently a malloc failure here can panic */ 1651 /* These are ugly. Currently a malloc failure here can panic */
1631 ldata->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); 1652 ldata->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
@@ -1677,7 +1698,7 @@ static inline int input_available_p(struct tty_struct *tty, int amt)
1677 * buffer, and once to drain the space from the (physical) beginning of 1698 * buffer, and once to drain the space from the (physical) beginning of
1678 * the buffer to head pointer. 1699 * the buffer to head pointer.
1679 * 1700 *
1680 * Called under the tty->atomic_read_lock sem 1701 * Called under the ldata->atomic_read_lock sem
1681 * 1702 *
1682 */ 1703 */
1683 1704
@@ -1693,10 +1714,10 @@ static int copy_from_read_buf(struct tty_struct *tty,
1693 bool is_eof; 1714 bool is_eof;
1694 1715
1695 retval = 0; 1716 retval = 0;
1696 spin_lock_irqsave(&tty->read_lock, flags); 1717 spin_lock_irqsave(&ldata->read_lock, flags);
1697 n = min(ldata->read_cnt, N_TTY_BUF_SIZE - ldata->read_tail); 1718 n = min(ldata->read_cnt, N_TTY_BUF_SIZE - ldata->read_tail);
1698 n = min(*nr, n); 1719 n = min(*nr, n);
1699 spin_unlock_irqrestore(&tty->read_lock, flags); 1720 spin_unlock_irqrestore(&ldata->read_lock, flags);
1700 if (n) { 1721 if (n) {
1701 retval = copy_to_user(*b, &ldata->read_buf[ldata->read_tail], n); 1722 retval = copy_to_user(*b, &ldata->read_buf[ldata->read_tail], n);
1702 n -= retval; 1723 n -= retval;
@@ -1704,13 +1725,13 @@ static int copy_from_read_buf(struct tty_struct *tty,
1704 ldata->read_buf[ldata->read_tail] == EOF_CHAR(tty); 1725 ldata->read_buf[ldata->read_tail] == EOF_CHAR(tty);
1705 tty_audit_add_data(tty, &ldata->read_buf[ldata->read_tail], n, 1726 tty_audit_add_data(tty, &ldata->read_buf[ldata->read_tail], n,
1706 ldata->icanon); 1727 ldata->icanon);
1707 spin_lock_irqsave(&tty->read_lock, flags); 1728 spin_lock_irqsave(&ldata->read_lock, flags);
1708 ldata->read_tail = (ldata->read_tail + n) & (N_TTY_BUF_SIZE-1); 1729 ldata->read_tail = (ldata->read_tail + n) & (N_TTY_BUF_SIZE-1);
1709 ldata->read_cnt -= n; 1730 ldata->read_cnt -= n;
1710 /* Turn single EOF into zero-length read */ 1731 /* Turn single EOF into zero-length read */
1711 if (L_EXTPROC(tty) && ldata->icanon && is_eof && !ldata->read_cnt) 1732 if (L_EXTPROC(tty) && ldata->icanon && is_eof && !ldata->read_cnt)
1712 n = 0; 1733 n = 0;
1713 spin_unlock_irqrestore(&tty->read_lock, flags); 1734 spin_unlock_irqrestore(&ldata->read_lock, flags);
1714 *b += n; 1735 *b += n;
1715 *nr -= n; 1736 *nr -= n;
1716 } 1737 }
@@ -1818,10 +1839,10 @@ do_it_again:
1818 * Internal serialization of reads. 1839 * Internal serialization of reads.
1819 */ 1840 */
1820 if (file->f_flags & O_NONBLOCK) { 1841 if (file->f_flags & O_NONBLOCK) {
1821 if (!mutex_trylock(&tty->atomic_read_lock)) 1842 if (!mutex_trylock(&ldata->atomic_read_lock))
1822 return -EAGAIN; 1843 return -EAGAIN;
1823 } else { 1844 } else {
1824 if (mutex_lock_interruptible(&tty->atomic_read_lock)) 1845 if (mutex_lock_interruptible(&ldata->atomic_read_lock))
1825 return -ERESTARTSYS; 1846 return -ERESTARTSYS;
1826 } 1847 }
1827 packet = tty->packet; 1848 packet = tty->packet;
@@ -1890,7 +1911,7 @@ do_it_again:
1890 1911
1891 if (ldata->icanon && !L_EXTPROC(tty)) { 1912 if (ldata->icanon && !L_EXTPROC(tty)) {
1892 /* N.B. avoid overrun if nr == 0 */ 1913 /* N.B. avoid overrun if nr == 0 */
1893 spin_lock_irqsave(&tty->read_lock, flags); 1914 spin_lock_irqsave(&ldata->read_lock, flags);
1894 while (nr && ldata->read_cnt) { 1915 while (nr && ldata->read_cnt) {
1895 int eol; 1916 int eol;
1896 1917
@@ -1908,25 +1929,25 @@ do_it_again:
1908 if (--ldata->canon_data < 0) 1929 if (--ldata->canon_data < 0)
1909 ldata->canon_data = 0; 1930 ldata->canon_data = 0;
1910 } 1931 }
1911 spin_unlock_irqrestore(&tty->read_lock, flags); 1932 spin_unlock_irqrestore(&ldata->read_lock, flags);
1912 1933
1913 if (!eol || (c != __DISABLED_CHAR)) { 1934 if (!eol || (c != __DISABLED_CHAR)) {
1914 if (tty_put_user(tty, c, b++)) { 1935 if (tty_put_user(tty, c, b++)) {
1915 retval = -EFAULT; 1936 retval = -EFAULT;
1916 b--; 1937 b--;
1917 spin_lock_irqsave(&tty->read_lock, flags); 1938 spin_lock_irqsave(&ldata->read_lock, flags);
1918 break; 1939 break;
1919 } 1940 }
1920 nr--; 1941 nr--;
1921 } 1942 }
1922 if (eol) { 1943 if (eol) {
1923 tty_audit_push(tty); 1944 tty_audit_push(tty);
1924 spin_lock_irqsave(&tty->read_lock, flags); 1945 spin_lock_irqsave(&ldata->read_lock, flags);
1925 break; 1946 break;
1926 } 1947 }
1927 spin_lock_irqsave(&tty->read_lock, flags); 1948 spin_lock_irqsave(&ldata->read_lock, flags);
1928 } 1949 }
1929 spin_unlock_irqrestore(&tty->read_lock, flags); 1950 spin_unlock_irqrestore(&ldata->read_lock, flags);
1930 if (retval) 1951 if (retval)
1931 break; 1952 break;
1932 } else { 1953 } else {
@@ -1958,7 +1979,7 @@ do_it_again:
1958 if (time) 1979 if (time)
1959 timeout = time; 1980 timeout = time;
1960 } 1981 }
1961 mutex_unlock(&tty->atomic_read_lock); 1982 mutex_unlock(&ldata->atomic_read_lock);
1962 remove_wait_queue(&tty->read_wait, &wait); 1983 remove_wait_queue(&tty->read_wait, &wait);
1963 1984
1964 if (!waitqueue_active(&tty->read_wait)) 1985 if (!waitqueue_active(&tty->read_wait))