aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/n_tty.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/n_tty.c')
-rw-r--r--drivers/char/n_tty.c79
1 files changed, 40 insertions, 39 deletions
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index 4e28b35024ec..2e50f4dfc79c 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -272,7 +272,8 @@ static inline int is_continuation(unsigned char c, struct tty_struct *tty)
272 * 272 *
273 * This is a helper function that handles one output character 273 * This is a helper function that handles one output character
274 * (including special characters like TAB, CR, LF, etc.), 274 * (including special characters like TAB, CR, LF, etc.),
275 * putting the results in the tty driver's write buffer. 275 * doing OPOST processing and putting the results in the
276 * tty driver's write buffer.
276 * 277 *
277 * Note that Linux currently ignores TABDLY, CRDLY, VTDLY, FFDLY 278 * Note that Linux currently ignores TABDLY, CRDLY, VTDLY, FFDLY
278 * and NLDLY. They simply aren't relevant in the world today. 279 * and NLDLY. They simply aren't relevant in the world today.
@@ -350,8 +351,9 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space)
350 * @c: character (or partial unicode symbol) 351 * @c: character (or partial unicode symbol)
351 * @tty: terminal device 352 * @tty: terminal device
352 * 353 *
353 * Perform OPOST processing. Returns -1 when the output device is 354 * Output one character with OPOST processing.
354 * full and the character must be retried. 355 * Returns -1 when the output device is full and the character
356 * must be retried.
355 * 357 *
356 * Locking: output_lock to protect column state and space left 358 * Locking: output_lock to protect column state and space left
357 * (also, this is called from n_tty_write under the 359 * (also, this is called from n_tty_write under the
@@ -377,8 +379,11 @@ static int process_output(unsigned char c, struct tty_struct *tty)
377/** 379/**
378 * process_output_block - block post processor 380 * process_output_block - block post processor
379 * @tty: terminal device 381 * @tty: terminal device
380 * @inbuf: user buffer 382 * @buf: character buffer
381 * @nr: number of bytes 383 * @nr: number of bytes to output
384 *
385 * Output a block of characters with OPOST processing.
386 * Returns the number of characters output.
382 * 387 *
383 * This path is used to speed up block console writes, among other 388 * This path is used to speed up block console writes, among other
384 * things when processing blocks of output data. It handles only 389 * things when processing blocks of output data. It handles only
@@ -571,33 +576,23 @@ static void process_echoes(struct tty_struct *tty)
571 break; 576 break;
572 577
573 default: 578 default:
574 if (iscntrl(op)) {
575 if (L_ECHOCTL(tty)) {
576 /*
577 * Ensure there is enough space
578 * for the whole ctrl pair.
579 */
580 if (space < 2) {
581 no_space_left = 1;
582 break;
583 }
584 tty_put_char(tty, '^');
585 tty_put_char(tty, op ^ 0100);
586 tty->column += 2;
587 space -= 2;
588 } else {
589 if (!space) {
590 no_space_left = 1;
591 break;
592 }
593 tty_put_char(tty, op);
594 space--;
595 }
596 }
597 /* 579 /*
598 * If above falls through, this was an 580 * If the op is not a special byte code,
599 * undefined op. 581 * it is a ctrl char tagged to be echoed
582 * as "^X" (where X is the letter
583 * representing the control char).
584 * Note that we must ensure there is
585 * enough space for the whole ctrl pair.
586 *
600 */ 587 */
588 if (space < 2) {
589 no_space_left = 1;
590 break;
591 }
592 tty_put_char(tty, '^');
593 tty_put_char(tty, op ^ 0100);
594 tty->column += 2;
595 space -= 2;
601 cp += 2; 596 cp += 2;
602 nr -= 2; 597 nr -= 2;
603 } 598 }
@@ -605,12 +600,18 @@ static void process_echoes(struct tty_struct *tty)
605 if (no_space_left) 600 if (no_space_left)
606 break; 601 break;
607 } else { 602 } else {
608 int retval; 603 if (O_OPOST(tty) &&
609 604 !(test_bit(TTY_HW_COOK_OUT, &tty->flags))) {
610 retval = do_output_char(c, tty, space); 605 int retval = do_output_char(c, tty, space);
611 if (retval < 0) 606 if (retval < 0)
612 break; 607 break;
613 space -= retval; 608 space -= retval;
609 } else {
610 if (!space)
611 break;
612 tty_put_char(tty, c);
613 space -= 1;
614 }
614 cp += 1; 615 cp += 1;
615 nr -= 1; 616 nr -= 1;
616 } 617 }
@@ -798,8 +799,8 @@ static void echo_char_raw(unsigned char c, struct tty_struct *tty)
798 * Echo user input back onto the screen. This must be called only when 799 * Echo user input back onto the screen. This must be called only when
799 * L_ECHO(tty) is true. Called from the driver receive_buf path. 800 * L_ECHO(tty) is true. Called from the driver receive_buf path.
800 * 801 *
801 * This variant tags control characters to be possibly echoed as 802 * This variant tags control characters to be echoed as "^X"
802 * as "^X" (where X is the letter representing the control char). 803 * (where X is the letter representing the control char).
803 * 804 *
804 * Locking: echo_lock to protect the echo buffer 805 * Locking: echo_lock to protect the echo buffer
805 */ 806 */
@@ -812,7 +813,7 @@ static void echo_char(unsigned char c, struct tty_struct *tty)
812 add_echo_byte(ECHO_OP_START, tty); 813 add_echo_byte(ECHO_OP_START, tty);
813 add_echo_byte(ECHO_OP_START, tty); 814 add_echo_byte(ECHO_OP_START, tty);
814 } else { 815 } else {
815 if (iscntrl(c) && c != '\t') 816 if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t')
816 add_echo_byte(ECHO_OP_START, tty); 817 add_echo_byte(ECHO_OP_START, tty);
817 add_echo_byte(c, tty); 818 add_echo_byte(c, tty);
818 } 819 }