Commit 464abf90 authored by Anton Blanchard's avatar Anton Blanchard Committed by Linus Torvalds

[PATCH] ppc64: udbg fix

Some udbg.c cleanups:

- remove some old comments
- clean up formatting
- remove unused udbg_puthex and udbg_printSP
Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 18cb7eec
...@@ -3,12 +3,6 @@ ...@@ -3,12 +3,6 @@
* *
* c 2001 PPC 64 Team, IBM Corp * c 2001 PPC 64 Team, IBM Corp
* *
* NOTE: I am trying to make this code avoid any static data references to
* simplify debugging early boot. We'll see how that goes...
*
* To use this call udbg_init() first. It will init the uart to 9600 8N1.
* You may need to update the COM1 define if your uart is at a different addr.
*
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version * as published by the Free Software Foundation; either version
...@@ -53,10 +47,9 @@ struct NS16550 { ...@@ -53,10 +47,9 @@ struct NS16550 {
#define LSR_TEMT 0x40 /* Xmitter empty */ #define LSR_TEMT 0x40 /* Xmitter empty */
#define LSR_ERR 0x80 /* Error */ #define LSR_ERR 0x80 /* Error */
volatile struct NS16550 *udbg_comport; static volatile struct NS16550 *udbg_comport;
void void udbg_init_uart(void *comport)
udbg_init_uart(void *comport)
{ {
if (comport) { if (comport) {
udbg_comport = (struct NS16550 *)comport; udbg_comport = (struct NS16550 *)comport;
...@@ -89,8 +82,7 @@ static unsigned char scc_inittab[] = { ...@@ -89,8 +82,7 @@ static unsigned char scc_inittab[] = {
3, 0xc1, /* rx enable, 8 bits */ 3, 0xc1, /* rx enable, 8 bits */
}; };
void void udbg_init_scc(struct device_node *np)
udbg_init_scc(struct device_node *np)
{ {
unsigned long addr; unsigned long addr;
int i, x; int i, x;
...@@ -127,10 +119,9 @@ udbg_init_scc(struct device_node *np) ...@@ -127,10 +119,9 @@ udbg_init_scc(struct device_node *np)
#endif /* CONFIG_PPC_PMAC */ #endif /* CONFIG_PPC_PMAC */
void void udbg_putc(unsigned char c)
udbg_putc(unsigned char c)
{ {
if ( udbg_comport ) { if (udbg_comport) {
while ((udbg_comport->lsr & LSR_THRE) == 0) while ((udbg_comport->lsr & LSR_THRE) == 0)
/* wait for idle */; /* wait for idle */;
udbg_comport->thr = c; eieio(); udbg_comport->thr = c; eieio();
...@@ -173,10 +164,9 @@ int udbg_getc_poll(void) ...@@ -173,10 +164,9 @@ int udbg_getc_poll(void)
return -1; return -1;
} }
unsigned char unsigned char udbg_getc(void)
udbg_getc(void)
{ {
if ( udbg_comport ) { if (udbg_comport) {
while ((udbg_comport->lsr & LSR_DR) == 0) while ((udbg_comport->lsr & LSR_DR) == 0)
/* wait for char */; /* wait for char */;
return udbg_comport->rbr; return udbg_comport->rbr;
...@@ -192,8 +182,7 @@ udbg_getc(void) ...@@ -192,8 +182,7 @@ udbg_getc(void)
return 0; return 0;
} }
void void udbg_puts(const char *s)
udbg_puts(const char *s)
{ {
if (ppc_md.udbg_putc) { if (ppc_md.udbg_putc) {
char c; char c;
...@@ -207,8 +196,7 @@ udbg_puts(const char *s) ...@@ -207,8 +196,7 @@ udbg_puts(const char *s)
} }
} }
int int udbg_write(const char *s, int n)
udbg_write(const char *s, int n)
{ {
int remain = n; int remain = n;
char c; char c;
...@@ -216,18 +204,20 @@ udbg_write(const char *s, int n) ...@@ -216,18 +204,20 @@ udbg_write(const char *s, int n)
if (!ppc_md.udbg_putc) if (!ppc_md.udbg_putc)
return 0; return 0;
if ( s && *s != '\0' ) { if (s && *s != '\0') {
while ( (( c = *s++ ) != '\0') && (remain-- > 0)) { while (((c = *s++) != '\0') && (remain-- > 0)) {
ppc_md.udbg_putc(c); ppc_md.udbg_putc(c);
} }
} }
return n - remain; return n - remain;
} }
int int udbg_read(char *buf, int buflen)
udbg_read(char *buf, int buflen) { {
char c, *p = buf; char c, *p = buf;
int i; int i;
if (!ppc_md.udbg_putc) if (!ppc_md.udbg_putc)
return 0; return 0;
...@@ -239,42 +229,15 @@ udbg_read(char *buf, int buflen) { ...@@ -239,42 +229,15 @@ udbg_read(char *buf, int buflen) {
break; break;
*p++ = c; *p++ = c;
} }
return i; return i;
} }
void void udbg_console_write(struct console *con, const char *s, unsigned int n)
udbg_console_write(struct console *con, const char *s, unsigned int n)
{ {
udbg_write(s, n); udbg_write(s, n);
} }
void
udbg_puthex(unsigned long val)
{
int i, nibbles = sizeof(val)*2;
unsigned char buf[sizeof(val)*2+1];
for (i = nibbles-1; i >= 0; i--) {
buf[i] = (val & 0xf) + '0';
if (buf[i] > '9')
buf[i] += ('a'-'0'-10);
val >>= 4;
}
buf[nibbles] = '\0';
udbg_puts(buf);
}
void
udbg_printSP(const char *s)
{
if (systemcfg->platform == PLATFORM_PSERIES) {
unsigned long sp;
asm("mr %0,1" : "=r" (sp) :);
if (s)
udbg_puts(s);
udbg_puthex(sp);
}
}
#define UDBG_BUFSIZE 256 #define UDBG_BUFSIZE 256
void udbg_printf(const char *fmt, ...) void udbg_printf(const char *fmt, ...)
{ {
...@@ -288,17 +251,16 @@ void udbg_printf(const char *fmt, ...) ...@@ -288,17 +251,16 @@ void udbg_printf(const char *fmt, ...)
} }
/* Special print used by PPCDBG() macro */ /* Special print used by PPCDBG() macro */
void void udbg_ppcdbg(unsigned long debug_flags, const char *fmt, ...)
udbg_ppcdbg(unsigned long debug_flags, const char *fmt, ...)
{ {
unsigned long active_debugs = debug_flags & naca->debug_switch; unsigned long active_debugs = debug_flags & naca->debug_switch;
if ( active_debugs ) { if (active_debugs) {
va_list ap; va_list ap;
unsigned char buf[UDBG_BUFSIZE]; unsigned char buf[UDBG_BUFSIZE];
unsigned long i, len = 0; unsigned long i, len = 0;
for(i=0; i < PPCDBG_NUM_FLAGS ;i++) { for (i=0; i < PPCDBG_NUM_FLAGS; i++) {
if (((1U << i) & active_debugs) && if (((1U << i) & active_debugs) &&
trace_names[i]) { trace_names[i]) {
len += strlen(trace_names[i]); len += strlen(trace_names[i]);
...@@ -306,11 +268,12 @@ udbg_ppcdbg(unsigned long debug_flags, const char *fmt, ...) ...@@ -306,11 +268,12 @@ udbg_ppcdbg(unsigned long debug_flags, const char *fmt, ...)
break; break;
} }
} }
snprintf(buf, UDBG_BUFSIZE, " [%s]: ", current->comm); snprintf(buf, UDBG_BUFSIZE, " [%s]: ", current->comm);
len += strlen(buf); len += strlen(buf);
udbg_puts(buf); udbg_puts(buf);
while(len < 18) { while (len < 18) {
udbg_puts(" "); udbg_puts(" ");
len++; len++;
} }
...@@ -318,13 +281,11 @@ udbg_ppcdbg(unsigned long debug_flags, const char *fmt, ...) ...@@ -318,13 +281,11 @@ udbg_ppcdbg(unsigned long debug_flags, const char *fmt, ...)
va_start(ap, fmt); va_start(ap, fmt);
vsnprintf(buf, UDBG_BUFSIZE, fmt, ap); vsnprintf(buf, UDBG_BUFSIZE, fmt, ap);
udbg_puts(buf); udbg_puts(buf);
va_end(ap); va_end(ap);
} }
} }
unsigned long unsigned long udbg_ifdebug(unsigned long flags)
udbg_ifdebug(unsigned long flags)
{ {
return (flags & naca->debug_switch); return (flags & naca->debug_switch);
} }
...@@ -19,11 +19,8 @@ int udbg_write(const char *s, int n); ...@@ -19,11 +19,8 @@ int udbg_write(const char *s, int n);
int udbg_read(char *buf, int buflen); int udbg_read(char *buf, int buflen);
struct console; struct console;
void udbg_console_write(struct console *con, const char *s, unsigned int n); void udbg_console_write(struct console *con, const char *s, unsigned int n);
void udbg_puthex(unsigned long val);
void udbg_printSP(const char *s);
void udbg_printf(const char *fmt, ...); void udbg_printf(const char *fmt, ...);
void udbg_ppcdbg(unsigned long flags, const char *fmt, ...); void udbg_ppcdbg(unsigned long flags, const char *fmt, ...);
unsigned long udbg_ifdebug(unsigned long flags); unsigned long udbg_ifdebug(unsigned long flags);
void udbg_init_uart(void *comport);
#endif #endif
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