]> git.hungrycats.org Git - linux/commitdiff
SPARC: Fix prom_printf and prom console behavior.
authorPete Zaitcev <zaitcev@redhat.com>
Sun, 11 Aug 2002 11:03:19 +0000 (04:03 -0700)
committerDavid S. Miller <davem@nuts.ninka.net>
Sun, 11 Aug 2002 11:03:19 +0000 (04:03 -0700)
arch/sparc/kernel/setup.c
arch/sparc/prom/printf.c
arch/sparc64/kernel/setup.c
arch/sparc64/prom/printf.c
include/asm-sparc/oplib.h
include/asm-sparc64/oplib.h

index 94609dc52487b1dfcdbe57694780039bc3c3849e..2e7179430026a3c064b89c828e5ef1f8aa9e1685 100644 (file)
@@ -130,7 +130,7 @@ void kernel_enter_debugger(void)
 static void
 prom_console_write(struct console *con, const char *s, unsigned n)
 {
-       prom_printf("%s", s);
+       prom_write(s, n);
 }
 
 static struct console prom_debug_console = {
index 331a2d00b62479b1f7629e491908c2bbc9cfe6e2..a80dd878a9d1b7693ddd6d86152c19c257f1218f 100644 (file)
@@ -1,11 +1,15 @@
-/* $Id: printf.c,v 1.7 2000/02/08 20:24:23 davem Exp $
+/*
  * printf.c:  Internal prom library printf facility.
  *
  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
- */
-
-/* This routine is internal to the prom library, no one else should know
- * about or use it!  It's simple and smelly anyway....
+ * Copyright (c) 2002 Pete Zaitcev (zaitcev@yahoo.com)
+ *
+ * We used to warn all over the code: DO NOT USE prom_printf(),
+ * and yet people do. Anton's banking code was outputing banks
+ * with prom_printf for most of the 2.4 lifetime. Since an effective
+ * stick is not available, we deployed a carrot: an early printk
+ * through PROM by means of -p boot option. This ought to fix it.
+ * USE printk; if you need, deploy -p.
  */
 
 #include <linux/kernel.h>
 
 static char ppbuf[1024];
 
+void
+prom_write(const char *buf, unsigned int n)
+{
+       char ch;
+
+       while (n != 0) {
+               --n;
+               if ((ch = *buf++) == '\n')
+                       prom_putchar('\r');
+               prom_putchar(ch);
+       }
+}
+
 void
 prom_printf(char *fmt, ...)
 {
        va_list args;
-       char ch, *bptr;
        int i;
 
        va_start(args, fmt);
-       i = vsprintf(ppbuf, fmt, args);
-
-       bptr = ppbuf;
-
-       while((ch = *(bptr++)) != 0) {
-               if(ch == '\n')
-                       prom_putchar('\r');
-
-               prom_putchar(ch);
-       }
+       i = vsnprintf(ppbuf, sizeof(ppbuf), fmt, args);
        va_end(args);
-       return;
+
+       prom_write(ppbuf, i);
 }
index 1f1d5414e21edd6ce5c5ff9e3efcd9f235c99915..0bf3399039ff65ec11c0a7c6f46909c3dbaf73b6 100644 (file)
@@ -73,7 +73,7 @@ asmlinkage void sys_sync(void);       /* it's really int */
 static void
 prom_console_write(struct console *con, const char *s, unsigned n)
 {
-       prom_printf("%s", s);
+       prom_write(s, n);
 }
 
 static struct console prom_console = {
index 33428e9f621f19cc7c4f12fdeca5e5e71b5e3743..01b26a70cd67786048bccb435e0e7a1a53004d52 100644 (file)
@@ -1,12 +1,16 @@
-/* $Id: printf.c,v 1.3 1997/03/18 18:00:00 jj Exp $
+/*
  * printf.c:  Internal prom library printf facility.
  *
  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
- */
-
-/* This routine is internal to the prom library, no one else should know
- * about or use it!  It's simple and smelly anyway....
+ * Copyright (c) 2002 Pete Zaitcev (zaitcev@yahoo.com)
+ *
+ * We used to warn all over the code: DO NOT USE prom_printf(),
+ * and yet people do. Anton's banking code was outputing banks
+ * with prom_printf for most of the 2.4 lifetime. Since an effective
+ * stick is not available, we deployed a carrot: an early printk
+ * through PROM by means of -p boot option. This ought to fix it.
+ * USE printk; if you need, deploy -p.
  */
 
 #include <linux/kernel.h>
 
 static char ppbuf[1024];
 
-extern void prom_puts (char *, int);
+void
+prom_write(const char *buf, unsigned int n)
+{
+       char ch;
+
+       while (n != 0) {
+               --n;
+               if ((ch = *buf++) == '\n')
+                       prom_putchar('\r');
+               prom_putchar(ch);
+       }
+}
 
 void
 prom_printf(char *fmt, ...)
 {
        va_list args;
-       char ch, *bptr, *last;
        int i;
 
        va_start(args, fmt);
-       i = vsprintf(ppbuf, fmt, args);
-
-       bptr = ppbuf;
-       last = ppbuf;
-
-       while((ch = *(bptr++)) != 0) {
-               if(ch == '\n') {
-                       if (last < bptr - 1)
-                               prom_puts (last, bptr - 1 - last);
-                       prom_putchar('\r');
-                       last = bptr - 1;
-               }
-       }
-       if (last < bptr - 1)
-               prom_puts (last, bptr - 1 - last);
+       i = vsnprintf(ppbuf, sizeof(ppbuf), fmt, args);
        va_end(args);
-       return;
+
+       prom_write(ppbuf, i);
 }
index 27ab73c6b0568b30bd61eda6d9247c79bf10d786..15c0a2dbfeb09f1a235656b2f838931f49fa7bc7 100644 (file)
@@ -153,8 +153,9 @@ extern char prom_getchar(void);
 /* Blocking put character to console. */
 extern void prom_putchar(char character);
 
-/* Prom's internal printf routine, don't use in kernel/boot code. */
-void prom_printf(char *fmt, ...);
+/* Prom's internal routines, don't use in kernel/boot code. */
+extern void prom_printf(char *fmt, ...);
+extern void prom_write(const char *buf, unsigned int len);
 
 /* Query for input device type */
 
index 54bf876d73ba58ef777490ea2e7c14c991073a53..c2cb33f588f67dc4b4ad243fcfe0ca37f79b6558 100644 (file)
@@ -153,8 +153,9 @@ extern char prom_getchar(void);
 /* Blocking put character to console. */
 extern void prom_putchar(char character);
 
-/* Prom's internal printf routine, don't use in kernel/boot code. */
-void prom_printf(char *fmt, ...);
+/* Prom's internal routines, don't use in kernel/boot code. */
+extern void prom_printf(char *fmt, ...);
+extern void prom_write(const char *buf, unsigned int len);
 
 /* Query for input device type */