Commit fadf34f0 authored by Tobias Klauser's avatar Tobias Klauser Committed by Greg Kroah-Hartman

altera_uart: Simplify altera_uart_console_putc

The check for the TRDY flag after writing the character is not needed.
Also do a cpu_relax() inside the loop.

Pass a struct uart_port to altera_uart_console_putc, so we do not need
to get it (and dereference pointers) for every character.

Cc: Thomas Chou <thomas@wytron.com.tw>
Signed-off-by: default avatarTobias Klauser <tklauser@distanz.ch>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent d8d721f4
...@@ -391,31 +391,24 @@ int __init early_altera_uart_setup(struct altera_uart_platform_uart *platp) ...@@ -391,31 +391,24 @@ int __init early_altera_uart_setup(struct altera_uart_platform_uart *platp)
return 0; return 0;
} }
static void altera_uart_console_putc(struct console *co, const char c) static void altera_uart_console_putc(struct uart_port *port, const char c)
{ {
struct uart_port *port = &(altera_uart_ports + co->index)->port; while (!(readl(port->membase + ALTERA_UART_STATUS_REG) &
int i; ALTERA_UART_STATUS_TRDY_MSK))
cpu_relax();
for (i = 0; i < 0x10000; i++) {
if (readl(port->membase + ALTERA_UART_STATUS_REG) &
ALTERA_UART_STATUS_TRDY_MSK)
break;
}
writel(c, port->membase + ALTERA_UART_TXDATA_REG); writel(c, port->membase + ALTERA_UART_TXDATA_REG);
for (i = 0; i < 0x10000; i++) {
if (readl(port->membase + ALTERA_UART_STATUS_REG) &
ALTERA_UART_STATUS_TRDY_MSK)
break;
}
} }
static void altera_uart_console_write(struct console *co, const char *s, static void altera_uart_console_write(struct console *co, const char *s,
unsigned int count) unsigned int count)
{ {
struct uart_port *port = &(altera_uart_ports + co->index)->port;
for (; count; count--, s++) { for (; count; count--, s++) {
altera_uart_console_putc(co, *s); altera_uart_console_putc(port, *s);
if (*s == '\n') if (*s == '\n')
altera_uart_console_putc(co, '\r'); altera_uart_console_putc(port, '\r');
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment