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 @@
*
* 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
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
......@@ -53,10 +47,9 @@ struct NS16550 {
#define LSR_TEMT 0x40 /* Xmitter empty */
#define LSR_ERR 0x80 /* Error */
volatile struct NS16550 *udbg_comport;
static volatile struct NS16550 *udbg_comport;
void
udbg_init_uart(void *comport)
void udbg_init_uart(void *comport)
{
if (comport) {
udbg_comport = (struct NS16550 *)comport;
......@@ -89,8 +82,7 @@ static unsigned char scc_inittab[] = {
3, 0xc1, /* rx enable, 8 bits */
};
void
udbg_init_scc(struct device_node *np)
void udbg_init_scc(struct device_node *np)
{
unsigned long addr;
int i, x;
......@@ -127,10 +119,9 @@ udbg_init_scc(struct device_node *np)
#endif /* CONFIG_PPC_PMAC */
void
udbg_putc(unsigned char c)
void udbg_putc(unsigned char c)
{
if ( udbg_comport ) {
if (udbg_comport) {
while ((udbg_comport->lsr & LSR_THRE) == 0)
/* wait for idle */;
udbg_comport->thr = c; eieio();
......@@ -173,10 +164,9 @@ int udbg_getc_poll(void)
return -1;
}
unsigned char
udbg_getc(void)
unsigned char udbg_getc(void)
{
if ( udbg_comport ) {
if (udbg_comport) {
while ((udbg_comport->lsr & LSR_DR) == 0)
/* wait for char */;
return udbg_comport->rbr;
......@@ -192,8 +182,7 @@ udbg_getc(void)
return 0;
}
void
udbg_puts(const char *s)
void udbg_puts(const char *s)
{
if (ppc_md.udbg_putc) {
char c;
......@@ -207,8 +196,7 @@ udbg_puts(const char *s)
}
}
int
udbg_write(const char *s, int n)
int udbg_write(const char *s, int n)
{
int remain = n;
char c;
......@@ -216,18 +204,20 @@ udbg_write(const char *s, int n)
if (!ppc_md.udbg_putc)
return 0;
if ( s && *s != '\0' ) {
while ( (( c = *s++ ) != '\0') && (remain-- > 0)) {
if (s && *s != '\0') {
while (((c = *s++) != '\0') && (remain-- > 0)) {
ppc_md.udbg_putc(c);
}
}
return n - remain;
}
int
udbg_read(char *buf, int buflen) {
int udbg_read(char *buf, int buflen)
{
char c, *p = buf;
int i;
if (!ppc_md.udbg_putc)
return 0;
......@@ -239,42 +229,15 @@ udbg_read(char *buf, int buflen) {
break;
*p++ = c;
}
return i;
}
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)
{
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
void udbg_printf(const char *fmt, ...)
{
......@@ -288,17 +251,16 @@ void udbg_printf(const char *fmt, ...)
}
/* Special print used by PPCDBG() macro */
void
udbg_ppcdbg(unsigned long debug_flags, const char *fmt, ...)
void udbg_ppcdbg(unsigned long debug_flags, const char *fmt, ...)
{
unsigned long active_debugs = debug_flags & naca->debug_switch;
if ( active_debugs ) {
if (active_debugs) {
va_list ap;
unsigned char buf[UDBG_BUFSIZE];
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) &&
trace_names[i]) {
len += strlen(trace_names[i]);
......@@ -306,11 +268,12 @@ udbg_ppcdbg(unsigned long debug_flags, const char *fmt, ...)
break;
}
}
snprintf(buf, UDBG_BUFSIZE, " [%s]: ", current->comm);
len += strlen(buf);
udbg_puts(buf);
while(len < 18) {
while (len < 18) {
udbg_puts(" ");
len++;
}
......@@ -318,13 +281,11 @@ udbg_ppcdbg(unsigned long debug_flags, const char *fmt, ...)
va_start(ap, fmt);
vsnprintf(buf, UDBG_BUFSIZE, fmt, ap);
udbg_puts(buf);
va_end(ap);
}
}
unsigned long
udbg_ifdebug(unsigned long flags)
unsigned long udbg_ifdebug(unsigned long flags)
{
return (flags & naca->debug_switch);
}
......@@ -19,11 +19,8 @@ int udbg_write(const char *s, int n);
int udbg_read(char *buf, int buflen);
struct console;
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_ppcdbg(unsigned long flags, const char *fmt, ...);
unsigned long udbg_ifdebug(unsigned long flags);
void udbg_init_uart(void *comport);
#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