aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2008-02-08 07:18:44 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-08 12:22:25 -0500
commit4edf1827ea19e65ca27ed197384d63f4d1dc8836 (patch)
tree5c495b258256303db6c251cc4a2cfb195c3180a6 /drivers
parentdb1acaa632870ec87b65e062bc72ca375837a1f6 (diff)
n_tty: clean up old code to follow coding style and (mostly) checkpatch
Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/n_tty.c148
1 files changed, 73 insertions, 75 deletions
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index 90c3969012a3..46b2a1cc8b54 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * n_tty.c --- implements the N_TTY line discipline. 2 * n_tty.c --- implements the N_TTY line discipline.
3 * 3 *
4 * This code used to be in tty_io.c, but things are getting hairy 4 * This code used to be in tty_io.c, but things are getting hairy
5 * enough that it made sense to split things off. (The N_TTY 5 * enough that it made sense to split things off. (The N_TTY
6 * processing has changed so much that it's hardly recognizable, 6 * processing has changed so much that it's hardly recognizable,
@@ -8,19 +8,19 @@
8 * 8 *
9 * Note that the open routine for N_TTY is guaranteed never to return 9 * Note that the open routine for N_TTY is guaranteed never to return
10 * an error. This is because Linux will fall back to setting a line 10 * an error. This is because Linux will fall back to setting a line
11 * to N_TTY if it can not switch to any other line discipline. 11 * to N_TTY if it can not switch to any other line discipline.
12 * 12 *
13 * Written by Theodore Ts'o, Copyright 1994. 13 * Written by Theodore Ts'o, Copyright 1994.
14 * 14 *
15 * This file also contains code originally written by Linus Torvalds, 15 * This file also contains code originally written by Linus Torvalds,
16 * Copyright 1991, 1992, 1993, and by Julian Cowley, Copyright 1994. 16 * Copyright 1991, 1992, 1993, and by Julian Cowley, Copyright 1994.
17 * 17 *
18 * This file may be redistributed under the terms of the GNU General Public 18 * This file may be redistributed under the terms of the GNU General Public
19 * License. 19 * License.
20 * 20 *
21 * Reduced memory usage for older ARM systems - Russell King. 21 * Reduced memory usage for older ARM systems - Russell King.
22 * 22 *
23 * 2000/01/20 Fixed SMP locking on put_tty_queue using bits of 23 * 2000/01/20 Fixed SMP locking on put_tty_queue using bits of
24 * the patch by Andrew J. Kroll <ag784@freenet.buffalo.edu> 24 * the patch by Andrew J. Kroll <ag784@freenet.buffalo.edu>
25 * who actually finally proved there really was a race. 25 * who actually finally proved there really was a race.
26 * 26 *
@@ -144,11 +144,11 @@ static void put_tty_queue(unsigned char c, struct tty_struct *tty)
144 * Can sleep, may be called under the atomic_read_lock mutex but 144 * Can sleep, may be called under the atomic_read_lock mutex but
145 * this is not guaranteed. 145 * this is not guaranteed.
146 */ 146 */
147 147
148static void check_unthrottle(struct tty_struct * tty) 148static void check_unthrottle(struct tty_struct *tty)
149{ 149{
150 if (tty->count && 150 if (tty->count &&
151 test_and_clear_bit(TTY_THROTTLED, &tty->flags) && 151 test_and_clear_bit(TTY_THROTTLED, &tty->flags) &&
152 tty->driver->unthrottle) 152 tty->driver->unthrottle)
153 tty->driver->unthrottle(tty); 153 tty->driver->unthrottle(tty);
154} 154}
@@ -157,7 +157,7 @@ static void check_unthrottle(struct tty_struct * tty)
157 * reset_buffer_flags - reset buffer state 157 * reset_buffer_flags - reset buffer state
158 * @tty: terminal to reset 158 * @tty: terminal to reset
159 * 159 *
160 * Reset the read buffer counters, clear the flags, 160 * Reset the read buffer counters, clear the flags,
161 * and make sure the driver is unthrottled. Called 161 * and make sure the driver is unthrottled. Called
162 * from n_tty_open() and n_tty_flush_buffer(). 162 * from n_tty_open() and n_tty_flush_buffer().
163 */ 163 */
@@ -186,12 +186,12 @@ static void reset_buffer_flags(struct tty_struct *tty)
186 * FIXME: tty->ctrl_status is not spinlocked and relies on 186 * FIXME: tty->ctrl_status is not spinlocked and relies on
187 * lock_kernel() still. 187 * lock_kernel() still.
188 */ 188 */
189 189
190static void n_tty_flush_buffer(struct tty_struct * tty) 190static void n_tty_flush_buffer(struct tty_struct *tty)
191{ 191{
192 /* clear everything and unthrottle the driver */ 192 /* clear everything and unthrottle the driver */
193 reset_buffer_flags(tty); 193 reset_buffer_flags(tty);
194 194
195 if (!tty->link) 195 if (!tty->link)
196 return; 196 return;
197 197
@@ -206,9 +206,9 @@ static void n_tty_flush_buffer(struct tty_struct * tty)
206 * @tty: tty device 206 * @tty: tty device
207 * 207 *
208 * Report the number of characters buffered to be delivered to user 208 * Report the number of characters buffered to be delivered to user
209 * at this instant in time. 209 * at this instant in time.
210 */ 210 */
211 211
212static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty) 212static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)
213{ 213{
214 unsigned long flags; 214 unsigned long flags;
@@ -234,7 +234,7 @@ static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)
234 * character. We use this to correctly compute the on screen size 234 * character. We use this to correctly compute the on screen size
235 * of the character when printing 235 * of the character when printing
236 */ 236 */
237 237
238static inline int is_utf8_continuation(unsigned char c) 238static inline int is_utf8_continuation(unsigned char c)
239{ 239{
240 return (c & 0xc0) == 0x80; 240 return (c & 0xc0) == 0x80;
@@ -247,7 +247,7 @@ static inline int is_utf8_continuation(unsigned char c)
247 * Returns true if the utf8 character 'c' is a multibyte continuation 247 * Returns true if the utf8 character 'c' is a multibyte continuation
248 * character and the terminal is in unicode mode. 248 * character and the terminal is in unicode mode.
249 */ 249 */
250 250
251static inline int is_continuation(unsigned char c, struct tty_struct *tty) 251static inline int is_continuation(unsigned char c, struct tty_struct *tty)
252{ 252{
253 return I_IUTF8(tty) && is_utf8_continuation(c); 253 return I_IUTF8(tty) && is_utf8_continuation(c);
@@ -266,7 +266,7 @@ static inline int is_continuation(unsigned char c, struct tty_struct *tty)
266 * Called from both the receive and transmit sides and can be called 266 * Called from both the receive and transmit sides and can be called
267 * re-entrantly. Relies on lock_kernel() still. 267 * re-entrantly. Relies on lock_kernel() still.
268 */ 268 */
269 269
270static int opost(unsigned char c, struct tty_struct *tty) 270static int opost(unsigned char c, struct tty_struct *tty)
271{ 271{
272 int space, spaces; 272 int space, spaces;
@@ -339,9 +339,9 @@ static int opost(unsigned char c, struct tty_struct *tty)
339 * 339 *
340 * Called from write_chan under the tty layer write lock. 340 * Called from write_chan under the tty layer write lock.
341 */ 341 */
342 342
343static ssize_t opost_block(struct tty_struct * tty, 343static ssize_t opost_block(struct tty_struct *tty,
344 const unsigned char * buf, unsigned int nr) 344 const unsigned char *buf, unsigned int nr)
345{ 345{
346 int space; 346 int space;
347 int i; 347 int i;
@@ -386,7 +386,7 @@ static ssize_t opost_block(struct tty_struct * tty,
386break_out: 386break_out:
387 if (tty->driver->flush_chars) 387 if (tty->driver->flush_chars)
388 tty->driver->flush_chars(tty); 388 tty->driver->flush_chars(tty);
389 i = tty->driver->write(tty, buf, i); 389 i = tty->driver->write(tty, buf, i);
390 return i; 390 return i;
391} 391}
392 392
@@ -398,7 +398,7 @@ break_out:
398 * 398 *
399 * Queue a byte to the driver layer for output 399 * Queue a byte to the driver layer for output
400 */ 400 */
401 401
402static inline void put_char(unsigned char c, struct tty_struct *tty) 402static inline void put_char(unsigned char c, struct tty_struct *tty)
403{ 403{
404 tty->driver->put_char(tty, c); 404 tty->driver->put_char(tty, c);
@@ -409,7 +409,7 @@ static inline void put_char(unsigned char c, struct tty_struct *tty)
409 * @c: unicode byte to echo 409 * @c: unicode byte to echo
410 * @tty: terminal device 410 * @tty: terminal device
411 * 411 *
412 * Echo user input back onto the screen. This must be called only when 412 * Echo user input back onto the screen. This must be called only when
413 * L_ECHO(tty) is true. Called from the driver receive_buf path. 413 * L_ECHO(tty) is true. Called from the driver receive_buf path.
414 */ 414 */
415 415
@@ -441,7 +441,7 @@ static inline void finish_erasing(struct tty_struct *tty)
441 * present in the stream from the driver layer. Handles the complexities 441 * present in the stream from the driver layer. Handles the complexities
442 * of UTF-8 multibyte symbols. 442 * of UTF-8 multibyte symbols.
443 */ 443 */
444 444
445static void eraser(unsigned char c, struct tty_struct *tty) 445static void eraser(unsigned char c, struct tty_struct *tty)
446{ 446{
447 enum { ERASE, WERASE, KILL } kill_type; 447 enum { ERASE, WERASE, KILL } kill_type;
@@ -541,7 +541,7 @@ static void eraser(unsigned char c, struct tty_struct *tty)
541 541
542 /* should never happen */ 542 /* should never happen */
543 if (tty->column > 0x80000000) 543 if (tty->column > 0x80000000)
544 tty->column = 0; 544 tty->column = 0;
545 545
546 /* Now backup to that column. */ 546 /* Now backup to that column. */
547 while (tty->column > col) { 547 while (tty->column > col) {
@@ -585,7 +585,7 @@ static void eraser(unsigned char c, struct tty_struct *tty)
585 * settings and character used. Called from the driver receive_buf 585 * settings and character used. Called from the driver receive_buf
586 * path so serialized. 586 * path so serialized.
587 */ 587 */
588 588
589static inline void isig(int sig, struct tty_struct *tty, int flush) 589static inline void isig(int sig, struct tty_struct *tty, int flush)
590{ 590{
591 if (tty->pgrp) 591 if (tty->pgrp)
@@ -606,7 +606,7 @@ static inline void isig(int sig, struct tty_struct *tty, int flush)
606 * 606 *
607 * Called from the receive_buf path so single threaded. 607 * Called from the receive_buf path so single threaded.
608 */ 608 */
609 609
610static inline void n_tty_receive_break(struct tty_struct *tty) 610static inline void n_tty_receive_break(struct tty_struct *tty)
611{ 611{
612 if (I_IGNBRK(tty)) 612 if (I_IGNBRK(tty))
@@ -635,7 +635,7 @@ static inline void n_tty_receive_break(struct tty_struct *tty)
635 * need locking as num_overrun and overrun_time are function 635 * need locking as num_overrun and overrun_time are function
636 * private. 636 * private.
637 */ 637 */
638 638
639static inline void n_tty_receive_overrun(struct tty_struct *tty) 639static inline void n_tty_receive_overrun(struct tty_struct *tty)
640{ 640{
641 char buf[64]; 641 char buf[64];
@@ -662,9 +662,8 @@ static inline void n_tty_receive_overrun(struct tty_struct *tty)
662static inline void n_tty_receive_parity_error(struct tty_struct *tty, 662static inline void n_tty_receive_parity_error(struct tty_struct *tty,
663 unsigned char c) 663 unsigned char c)
664{ 664{
665 if (I_IGNPAR(tty)) { 665 if (I_IGNPAR(tty))
666 return; 666 return;
667 }
668 if (I_PARMRK(tty)) { 667 if (I_PARMRK(tty)) {
669 put_tty_queue('\377', tty); 668 put_tty_queue('\377', tty);
670 put_tty_queue('\0', tty); 669 put_tty_queue('\0', tty);
@@ -682,7 +681,7 @@ static inline void n_tty_receive_parity_error(struct tty_struct *tty,
682 * @c: character 681 * @c: character
683 * 682 *
684 * Process an individual character of input received from the driver. 683 * Process an individual character of input received from the driver.
685 * This is serialized with respect to itself by the rules for the 684 * This is serialized with respect to itself by the rules for the
686 * driver above. 685 * driver above.
687 */ 686 */
688 687
@@ -694,7 +693,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
694 put_tty_queue(c, tty); 693 put_tty_queue(c, tty);
695 return; 694 return;
696 } 695 }
697 696
698 if (I_ISTRIP(tty)) 697 if (I_ISTRIP(tty))
699 c &= 0x7f; 698 c &= 0x7f;
700 if (I_IUCLC(tty) && L_IEXTEN(tty)) 699 if (I_IUCLC(tty) && L_IEXTEN(tty))
@@ -739,7 +738,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
739 put_tty_queue(c, tty); 738 put_tty_queue(c, tty);
740 return; 739 return;
741 } 740 }
742 741
743 if (c == '\r') { 742 if (c == '\r') {
744 if (I_IGNCR(tty)) 743 if (I_IGNCR(tty))
745 return; 744 return;
@@ -825,8 +824,8 @@ send_signal:
825 goto handle_newline; 824 goto handle_newline;
826 } 825 }
827 if (c == EOF_CHAR(tty)) { 826 if (c == EOF_CHAR(tty)) {
828 if (tty->canon_head != tty->read_head) 827 if (tty->canon_head != tty->read_head)
829 set_bit(TTY_PUSH, &tty->flags); 828 set_bit(TTY_PUSH, &tty->flags);
830 c = __DISABLED_CHAR; 829 c = __DISABLED_CHAR;
831 goto handle_newline; 830 goto handle_newline;
832 } 831 }
@@ -850,7 +849,7 @@ send_signal:
850 if (I_PARMRK(tty) && c == (unsigned char) '\377') 849 if (I_PARMRK(tty) && c == (unsigned char) '\377')
851 put_tty_queue(c, tty); 850 put_tty_queue(c, tty);
852 851
853 handle_newline: 852handle_newline:
854 spin_lock_irqsave(&tty->read_lock, flags); 853 spin_lock_irqsave(&tty->read_lock, flags);
855 set_bit(tty->read_head, tty->read_flags); 854 set_bit(tty->read_head, tty->read_flags);
856 put_tty_queue_nolock(c, tty); 855 put_tty_queue_nolock(c, tty);
@@ -863,7 +862,7 @@ send_signal:
863 return; 862 return;
864 } 863 }
865 } 864 }
866 865
867 finish_erasing(tty); 866 finish_erasing(tty);
868 if (L_ECHO(tty)) { 867 if (L_ECHO(tty)) {
869 if (tty->read_cnt >= N_TTY_BUF_SIZE-1) { 868 if (tty->read_cnt >= N_TTY_BUF_SIZE-1) {
@@ -884,7 +883,7 @@ send_signal:
884 put_tty_queue(c, tty); 883 put_tty_queue(c, tty);
885 884
886 put_tty_queue(c, tty); 885 put_tty_queue(c, tty);
887} 886}
888 887
889 888
890/** 889/**
@@ -898,12 +897,10 @@ send_signal:
898 897
899static void n_tty_write_wakeup(struct tty_struct *tty) 898static void n_tty_write_wakeup(struct tty_struct *tty)
900{ 899{
901 if (tty->fasync) 900 if (tty->fasync) {
902 { 901 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
903 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
904 kill_fasync(&tty->fasync, SIGIO, POLL_OUT); 902 kill_fasync(&tty->fasync, SIGIO, POLL_OUT);
905 } 903 }
906 return;
907} 904}
908 905
909/** 906/**
@@ -918,7 +915,7 @@ static void n_tty_write_wakeup(struct tty_struct *tty)
918 * not from interrupt context. The driver is responsible for making 915 * not from interrupt context. The driver is responsible for making
919 * calls one at a time and in order (or using flush_to_ldisc) 916 * calls one at a time and in order (or using flush_to_ldisc)
920 */ 917 */
921 918
922static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, 919static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
923 char *fp, int count) 920 char *fp, int count)
924{ 921{
@@ -950,7 +947,7 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
950 tty->read_cnt += i; 947 tty->read_cnt += i;
951 spin_unlock_irqrestore(&tty->read_lock, cpuflags); 948 spin_unlock_irqrestore(&tty->read_lock, cpuflags);
952 } else { 949 } else {
953 for (i=count, p = cp, f = fp; i; i--, p++) { 950 for (i = count, p = cp, f = fp; i; i--, p++) {
954 if (f) 951 if (f)
955 flags = *f++; 952 flags = *f++;
956 switch (flags) { 953 switch (flags) {
@@ -968,7 +965,7 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
968 n_tty_receive_overrun(tty); 965 n_tty_receive_overrun(tty);
969 break; 966 break;
970 default: 967 default:
971 printk("%s: unknown flag %d\n", 968 printk(KERN_ERR "%s: unknown flag %d\n",
972 tty_name(tty, buf), flags); 969 tty_name(tty, buf), flags);
973 break; 970 break;
974 } 971 }
@@ -1001,7 +998,7 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
1001int is_ignored(int sig) 998int is_ignored(int sig)
1002{ 999{
1003 return (sigismember(&current->blocked, sig) || 1000 return (sigismember(&current->blocked, sig) ||
1004 current->sighand->action[sig-1].sa.sa_handler == SIG_IGN); 1001 current->sighand->action[sig-1].sa.sa_handler == SIG_IGN);
1005} 1002}
1006 1003
1007/** 1004/**
@@ -1011,16 +1008,16 @@ int is_ignored(int sig)
1011 * 1008 *
1012 * Called by the tty layer when the user changes termios flags so 1009 * Called by the tty layer when the user changes termios flags so
1013 * that the line discipline can plan ahead. This function cannot sleep 1010 * that the line discipline can plan ahead. This function cannot sleep
1014 * and is protected from re-entry by the tty layer. The user is 1011 * and is protected from re-entry by the tty layer. The user is
1015 * guaranteed that this function will not be re-entered or in progress 1012 * guaranteed that this function will not be re-entered or in progress
1016 * when the ldisc is closed. 1013 * when the ldisc is closed.
1017 */ 1014 */
1018 1015
1019static void n_tty_set_termios(struct tty_struct *tty, struct ktermios * old) 1016static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
1020{ 1017{
1021 if (!tty) 1018 if (!tty)
1022 return; 1019 return;
1023 1020
1024 tty->icanon = (L_ICANON(tty) != 0); 1021 tty->icanon = (L_ICANON(tty) != 0);
1025 if (test_bit(TTY_HW_COOK_IN, &tty->flags)) { 1022 if (test_bit(TTY_HW_COOK_IN, &tty->flags)) {
1026 tty->raw = 1; 1023 tty->raw = 1;
@@ -1085,12 +1082,12 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios * old)
1085 * n_tty_close - close the ldisc for this tty 1082 * n_tty_close - close the ldisc for this tty
1086 * @tty: device 1083 * @tty: device
1087 * 1084 *
1088 * Called from the terminal layer when this line discipline is 1085 * Called from the terminal layer when this line discipline is
1089 * being shut down, either because of a close or becsuse of a 1086 * being shut down, either because of a close or becsuse of a
1090 * discipline change. The function will not be called while other 1087 * discipline change. The function will not be called while other
1091 * ldisc methods are in progress. 1088 * ldisc methods are in progress.
1092 */ 1089 */
1093 1090
1094static void n_tty_close(struct tty_struct *tty) 1091static void n_tty_close(struct tty_struct *tty)
1095{ 1092{
1096 n_tty_flush_buffer(tty); 1093 n_tty_flush_buffer(tty);
@@ -1104,7 +1101,7 @@ static void n_tty_close(struct tty_struct *tty)
1104 * n_tty_open - open an ldisc 1101 * n_tty_open - open an ldisc
1105 * @tty: terminal to open 1102 * @tty: terminal to open
1106 * 1103 *
1107 * Called when this line discipline is being attached to the 1104 * Called when this line discipline is being attached to the
1108 * terminal device. Can sleep. Called serialized so that no 1105 * terminal device. Can sleep. Called serialized so that no
1109 * other events will occur in parallel. No further open will occur 1106 * other events will occur in parallel. No further open will occur
1110 * until a close. 1107 * until a close.
@@ -1157,7 +1154,7 @@ static inline int input_available_p(struct tty_struct *tty, int amt)
1157 * Called under the tty->atomic_read_lock sem 1154 * Called under the tty->atomic_read_lock sem
1158 * 1155 *
1159 */ 1156 */
1160 1157
1161static int copy_from_read_buf(struct tty_struct *tty, 1158static int copy_from_read_buf(struct tty_struct *tty,
1162 unsigned char __user **b, 1159 unsigned char __user **b,
1163 size_t *nr) 1160 size_t *nr)
@@ -1186,7 +1183,8 @@ static int copy_from_read_buf(struct tty_struct *tty,
1186 return retval; 1183 return retval;
1187} 1184}
1188 1185
1189extern ssize_t redirected_tty_write(struct file *,const char *,size_t,loff_t *); 1186extern ssize_t redirected_tty_write(struct file *, const char *,
1187 size_t, loff_t *);
1190 1188
1191/** 1189/**
1192 * job_control - check job control 1190 * job_control - check job control
@@ -1194,10 +1192,10 @@ extern ssize_t redirected_tty_write(struct file *,const char *,size_t,loff_t *);
1194 * @file: file handle 1192 * @file: file handle
1195 * 1193 *
1196 * Perform job control management checks on this file/tty descriptor 1194 * Perform job control management checks on this file/tty descriptor
1197 * and if appropriate send any needed signals and return a negative 1195 * and if appropriate send any needed signals and return a negative
1198 * error code if action should be taken. 1196 * error code if action should be taken.
1199 */ 1197 */
1200 1198
1201static int job_control(struct tty_struct *tty, struct file *file) 1199static int job_control(struct tty_struct *tty, struct file *file)
1202{ 1200{
1203 /* Job control check -- must be done at start and after 1201 /* Job control check -- must be done at start and after
@@ -1208,7 +1206,7 @@ static int job_control(struct tty_struct *tty, struct file *file)
1208 if (file->f_op->write != redirected_tty_write && 1206 if (file->f_op->write != redirected_tty_write &&
1209 current->signal->tty == tty) { 1207 current->signal->tty == tty) {
1210 if (!tty->pgrp) 1208 if (!tty->pgrp)
1211 printk("read_chan: no tty->pgrp!\n"); 1209 printk(KERN_ERR "read_chan: no tty->pgrp!\n");
1212 else if (task_pgrp(current) != tty->pgrp) { 1210 else if (task_pgrp(current) != tty->pgrp) {
1213 if (is_ignored(SIGTTIN) || 1211 if (is_ignored(SIGTTIN) ||
1214 is_current_pgrp_orphaned()) 1212 is_current_pgrp_orphaned())
@@ -1220,7 +1218,7 @@ static int job_control(struct tty_struct *tty, struct file *file)
1220 } 1218 }
1221 return 0; 1219 return 0;
1222} 1220}
1223 1221
1224 1222
1225/** 1223/**
1226 * read_chan - read function for tty 1224 * read_chan - read function for tty
@@ -1236,7 +1234,7 @@ static int job_control(struct tty_struct *tty, struct file *file)
1236 * 1234 *
1237 * This code must be sure never to sleep through a hangup. 1235 * This code must be sure never to sleep through a hangup.
1238 */ 1236 */
1239 1237
1240static ssize_t read_chan(struct tty_struct *tty, struct file *file, 1238static ssize_t read_chan(struct tty_struct *tty, struct file *file,
1241 unsigned char __user *buf, size_t nr) 1239 unsigned char __user *buf, size_t nr)
1242{ 1240{
@@ -1252,14 +1250,14 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file,
1252do_it_again: 1250do_it_again:
1253 1251
1254 if (!tty->read_buf) { 1252 if (!tty->read_buf) {
1255 printk("n_tty_read_chan: called with read_buf == NULL?!?\n"); 1253 printk(KERN_ERR "n_tty_read_chan: read_buf == NULL?!?\n");
1256 return -EIO; 1254 return -EIO;
1257 } 1255 }
1258 1256
1259 c = job_control(tty, file); 1257 c = job_control(tty, file);
1260 if(c < 0) 1258 if (c < 0)
1261 return c; 1259 return c;
1262 1260
1263 minimum = time = 0; 1261 minimum = time = 0;
1264 timeout = MAX_SCHEDULE_TIMEOUT; 1262 timeout = MAX_SCHEDULE_TIMEOUT;
1265 if (!tty->icanon) { 1263 if (!tty->icanon) {
@@ -1287,8 +1285,7 @@ do_it_again:
1287 if (file->f_flags & O_NONBLOCK) { 1285 if (file->f_flags & O_NONBLOCK) {
1288 if (!mutex_trylock(&tty->atomic_read_lock)) 1286 if (!mutex_trylock(&tty->atomic_read_lock))
1289 return -EAGAIN; 1287 return -EAGAIN;
1290 } 1288 } else {
1291 else {
1292 if (mutex_lock_interruptible(&tty->atomic_read_lock)) 1289 if (mutex_lock_interruptible(&tty->atomic_read_lock))
1293 return -ERESTARTSYS; 1290 return -ERESTARTSYS;
1294 } 1291 }
@@ -1314,11 +1311,11 @@ do_it_again:
1314 so that any interrupt will set the state back to 1311 so that any interrupt will set the state back to
1315 TASK_RUNNING. */ 1312 TASK_RUNNING. */
1316 set_current_state(TASK_INTERRUPTIBLE); 1313 set_current_state(TASK_INTERRUPTIBLE);
1317 1314
1318 if (((minimum - (b - buf)) < tty->minimum_to_wake) && 1315 if (((minimum - (b - buf)) < tty->minimum_to_wake) &&
1319 ((minimum - (b - buf)) >= 1)) 1316 ((minimum - (b - buf)) >= 1))
1320 tty->minimum_to_wake = (minimum - (b - buf)); 1317 tty->minimum_to_wake = (minimum - (b - buf));
1321 1318
1322 if (!input_available_p(tty, 0)) { 1319 if (!input_available_p(tty, 0)) {
1323 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) { 1320 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) {
1324 retval = -EIO; 1321 retval = -EIO;
@@ -1355,7 +1352,7 @@ do_it_again:
1355 if (tty->icanon) { 1352 if (tty->icanon) {
1356 /* N.B. avoid overrun if nr == 0 */ 1353 /* N.B. avoid overrun if nr == 0 */
1357 while (nr && tty->read_cnt) { 1354 while (nr && tty->read_cnt) {
1358 int eol; 1355 int eol;
1359 1356
1360 eol = test_and_clear_bit(tty->read_tail, 1357 eol = test_and_clear_bit(tty->read_tail,
1361 tty->read_flags); 1358 tty->read_flags);
@@ -1427,7 +1424,7 @@ do_it_again:
1427 if (size) { 1424 if (size) {
1428 retval = size; 1425 retval = size;
1429 if (nr) 1426 if (nr)
1430 clear_bit(TTY_PUSH, &tty->flags); 1427 clear_bit(TTY_PUSH, &tty->flags);
1431 } else if (test_and_clear_bit(TTY_PUSH, &tty->flags)) 1428 } else if (test_and_clear_bit(TTY_PUSH, &tty->flags))
1432 goto do_it_again; 1429 goto do_it_again;
1433 1430
@@ -1450,9 +1447,9 @@ do_it_again:
1450 * 1447 *
1451 * This code must be sure never to sleep through a hangup. 1448 * This code must be sure never to sleep through a hangup.
1452 */ 1449 */
1453 1450
1454static ssize_t write_chan(struct tty_struct * tty, struct file * file, 1451static ssize_t write_chan(struct tty_struct *tty, struct file *file,
1455 const unsigned char * buf, size_t nr) 1452 const unsigned char *buf, size_t nr)
1456{ 1453{
1457 const unsigned char *b = buf; 1454 const unsigned char *b = buf;
1458 DECLARE_WAITQUEUE(wait, current); 1455 DECLARE_WAITQUEUE(wait, current);
@@ -1542,8 +1539,9 @@ break_out:
1542 * recompute the new limits. Possibly set_termios should issue 1539 * recompute the new limits. Possibly set_termios should issue
1543 * a read wakeup to fix this bug. 1540 * a read wakeup to fix this bug.
1544 */ 1541 */
1545 1542
1546static unsigned int normal_poll(struct tty_struct * tty, struct file * file, poll_table *wait) 1543static unsigned int normal_poll(struct tty_struct *tty, struct file *file,
1544 poll_table *wait)
1547{ 1545{
1548 unsigned int mask = 0; 1546 unsigned int mask = 0;
1549 1547