Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hvc_dcc: Simplify put_chars()/get_chars() loops

Casting and anding with 0xff is unnecessary in
hvc_dcc_put_chars() since buf is already a char[].
__dcc_get_char() can't return an int less than 0 since it only
returns a char. Simplify the if statement in hvc_dcc_get_chars()
to take this into account.

Cc: Daniel Walker <dwalker@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Stephen Boyd and committed by
Greg Kroah-Hartman
bf73bd35 a9963201

+4 -8
+4 -8
drivers/tty/hvc/hvc_dcc.c
··· 89 89 while (__dcc_getstatus() & DCC_STATUS_TX) 90 90 cpu_relax(); 91 91 92 - __dcc_putchar((char)(buf[i] & 0xFF)); 92 + __dcc_putchar(buf[i]); 93 93 } 94 94 95 95 return count; ··· 99 99 { 100 100 int i; 101 101 102 - for (i = 0; i < count; ++i) { 103 - int c = -1; 104 - 102 + for (i = 0; i < count; ++i) 105 103 if (__dcc_getstatus() & DCC_STATUS_RX) 106 - c = __dcc_getchar(); 107 - if (c < 0) 104 + buf[i] = __dcc_getchar(); 105 + else 108 106 break; 109 - buf[i] = c; 110 - } 111 107 112 108 return i; 113 109 }