Skip to content

Commit

Permalink
hvc_dcc: Simplify put_chars()/get_chars() loops
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephen Boyd authored and Greg Kroah-Hartman committed Feb 4, 2011
1 parent a996320 commit bf73bd3
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions drivers/tty/hvc/hvc_dcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static int hvc_dcc_put_chars(uint32_t vt, const char *buf, int count)
while (__dcc_getstatus() & DCC_STATUS_TX)
cpu_relax();

__dcc_putchar((char)(buf[i] & 0xFF));
__dcc_putchar(buf[i]);
}

return count;
Expand All @@ -99,15 +99,11 @@ static int hvc_dcc_get_chars(uint32_t vt, char *buf, int count)
{
int i;

for (i = 0; i < count; ++i) {
int c = -1;

for (i = 0; i < count; ++i)
if (__dcc_getstatus() & DCC_STATUS_RX)
c = __dcc_getchar();
if (c < 0)
buf[i] = __dcc_getchar();
else
break;
buf[i] = c;
}

return i;
}
Expand Down

0 comments on commit bf73bd3

Please sign in to comment.