The patch titled tty: minor code efficiency and style cleanup has been removed from the -mm tree. Its filename was tty-minor-code-efficiency-and-style-cleanup.patch This patch was dropped because of rejects The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: tty: minor code efficiency and style cleanup From: Joe Peterson <joe@xxxxxxxxxxx> No behavior changes. Signed-off-by: Joe Peterson <joe@xxxxxxxxxxx> Cc: Alan Cox <alan@xxxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/char/n_tty.c | 61 +++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff -puN drivers/char/n_tty.c~tty-minor-code-efficiency-and-style-cleanup drivers/char/n_tty.c --- a/drivers/char/n_tty.c~tty-minor-code-efficiency-and-style-cleanup +++ a/drivers/char/n_tty.c @@ -465,11 +465,11 @@ break_out: /** - * process_echoes - write pending echoed characters + * process_echoes - write pending echo characters * @tty: terminal device * - * Write echoed (and other ldisc-generated) characters to the - * tty that have been stored previously in the echo buffer. + * Write previously buffered echo (and other ldisc-generated) + * characters to the tty. * * Characters generated by the ldisc (including echoes) need to * be buffered because the driver's write buffer can fill during @@ -498,11 +498,11 @@ break_out: static void process_echoes(struct tty_struct *tty) { - int space, num, nr; + int space, nr; unsigned char c; unsigned char *cp, *buf_end; - if (!(num = tty->echo_cnt)) + if (!tty->echo_cnt) return; lock_kernel(); @@ -511,7 +511,7 @@ static void process_echoes(struct tty_st buf_end = tty->echo_buf + N_TTY_BUF_SIZE; cp = tty->echo_buf + tty->echo_pos; - nr = num; + nr = tty->echo_cnt; while (nr > 0) { c = *cp; if (c == ECHO_OP_START) { @@ -645,14 +645,15 @@ static void process_echoes(struct tty_st cp -= N_TTY_BUF_SIZE; } - tty->echo_cnt = nr; - if (tty->echo_cnt == 0) { + if (nr == 0) { tty->echo_pos = 0; + tty->echo_cnt = 0; tty->echo_overrun = 0; } else { - int num_processed = (num - nr); + int num_processed = tty->echo_cnt - nr; tty->echo_pos += num_processed; - tty->echo_pos &= (N_TTY_BUF_SIZE - 1); + tty->echo_pos &= N_TTY_BUF_SIZE - 1; + tty->echo_cnt = nr; if (num_processed > 0) tty->echo_overrun = 0; } @@ -673,42 +674,43 @@ static void process_echoes(struct tty_st static void add_echo_byte(unsigned char c, struct tty_struct *tty) { - int add_char_pos; + int new_byte_pos; unsigned long flags; spin_lock_irqsave(&tty->echo_lock, flags); - add_char_pos = tty->echo_pos + tty->echo_cnt; - if (add_char_pos >= N_TTY_BUF_SIZE) - add_char_pos -= N_TTY_BUF_SIZE; - - /* Detect overrun */ if (tty->echo_cnt == N_TTY_BUF_SIZE) { + /* Circular buffer is already at capacity */ + new_byte_pos = tty->echo_pos; + /* - * If the start position pointer needs to be advanced - * due to running out of buffer space, be sure it is - * done in such a way as to remove whole - * operation byte groups. + * Since the buffer start position needs to be advanced, + * be sure to step by a whole operation byte group. */ - if (*(tty->echo_buf + - (tty->echo_pos & (N_TTY_BUF_SIZE - 1))) == ECHO_OP_START) + if (tty->echo_buf[tty->echo_pos] == ECHO_OP_START) { - if (*(tty->echo_buf + - ((tty->echo_pos + 1) & (N_TTY_BUF_SIZE - 1))) == ECHO_OP_TAB_ERASE) { + if (tty->echo_buf[(tty->echo_pos + 1) & + (N_TTY_BUF_SIZE - 1)] == + ECHO_OP_TAB_ERASE) { tty->echo_pos += 4; tty->echo_cnt -= 3; } else { tty->echo_pos += 2; tty->echo_cnt -= 1; } - } else + } else { tty->echo_pos++; - tty->echo_pos &= (N_TTY_BUF_SIZE - 1); + } + tty->echo_pos &= N_TTY_BUF_SIZE - 1; + tty->echo_overrun = 1; - } else + } else { + new_byte_pos = tty->echo_pos + tty->echo_cnt; + new_byte_pos &= N_TTY_BUF_SIZE - 1; tty->echo_cnt++; + } - tty->echo_buf[add_char_pos] = c; + tty->echo_buf[new_byte_pos] = c; spin_unlock_irqrestore(&tty->echo_lock, flags); } @@ -772,8 +774,9 @@ static void echo_char_raw(unsigned char if (c == ECHO_OP_START) { add_echo_byte(ECHO_OP_START, tty); add_echo_byte(ECHO_OP_START, tty); - } else + } else { add_echo_byte(c, tty); + } } /** _ Patches currently in -mm which might be from joe@xxxxxxxxxxx are tty-minor-code-efficiency-and-style-cleanup.patch tty-fix-echo-tab-erase-and-locking.patch tty-fix-echo-tab-erase-and-locking-fix.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html