Let's `mcf_console_putc' require a `struct uart_port *' instead of a
`struct console *'.  This makes cleaner and slightly more efficient
code, and also makes mcf_console_putc easier to use for early debugging.

Signed-off-by: Philippe De Muyter <p...@macqel.be>
---
 drivers/tty/serial/mcf.c |   32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 deletions(-)

On Tue, Jan 15, 2013 at 11:28:38PM +1000, Greg Ungerer wrote:
> If you are getting into the kernel startup code, then take the trace
> up to the C code level. Code up a simple console char output routine
> (use the serial driver console routines as an example).

diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c
index fcd56ab..5f60382 100644
--- a/drivers/tty/serial/mcf.c
+++ b/drivers/tty/serial/mcf.c
@@ -473,31 +473,39 @@ int __init early_mcf_setup(struct mcf_platform_uart 
*platp)
 
 /****************************************************************************/
 
-static void mcf_console_putc(struct console *co, const char c)
+static inline void mcf_console_wait(struct uart_port *port, unsigned char 
condition)
 {
-       struct uart_port *port = &(mcf_ports + co->index)->port;
        int i;
 
-       for (i = 0; (i < 0x10000); i++) {
-               if (readb(port->membase + MCFUART_USR) & MCFUART_USR_TXREADY)
+       for (i = 0; i < 0x10000; i++) {
+               if (readb(port->membase + MCFUART_USR) & condition)
                        break;
        }
+}
+
+/****************************************************************************/
+
+static void mcf_console_putc(struct uart_port *port, const char c)
+{
+
+       mcf_console_wait(port, MCFUART_USR_TXREADY);
        writeb(c, port->membase + MCFUART_UTB);
-       for (i = 0; (i < 0x10000); i++) {
-               if (readb(port->membase + MCFUART_USR) & MCFUART_USR_TXREADY)
-                       break;
-       }
 }
 
 /****************************************************************************/
 
 static void mcf_console_write(struct console *co, const char *s, unsigned int 
count)
 {
-       for (; (count); count--, s++) {
-               mcf_console_putc(co, *s);
-               if (*s == '\n')
-                       mcf_console_putc(co, '\r');
+       struct uart_port *port = &(mcf_ports + co->index)->port;
+
+       while (count--) {
+               unsigned char c = *s++;
+
+               mcf_console_putc(port, c);
+               if (c == '\n')
+                       mcf_console_putc(port, '\r');
        }
+       mcf_console_wait(port, MCFUART_USR_TXEMPTY);
 }
 
 /****************************************************************************/
-- 
1.7.1

_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to