[PARISC] pdc_console: fix bizarre panic on boot
[sfrench/cifs-2.6.git] / arch / parisc / kernel / pdc_cons.c
index e7afc899d71722139e9fd3e142a45487ac3cc68e..ccb68090781efdc24b553ce9e6162899ed349c03 100644 (file)
 #include <linux/tty.h>
 #include <asm/pdc.h>           /* for iodc_call() proto and friends */
 
+static spinlock_t pdc_console_lock = SPIN_LOCK_UNLOCKED;
 
 static void pdc_console_write(struct console *co, const char *s, unsigned count)
 {
-       pdc_iodc_print(s, count);
+       int i = 0;
+       unsigned long flags;
+
+       spin_lock_irqsave(&pdc_console_lock, flags);
+       do {
+               i += pdc_iodc_print(s + i, count - i);
+       } while (i < count);
+       spin_unlock_irqrestore(&pdc_console_lock, flags);
 }
 
 int pdc_console_poll_key(struct console *co)
 {
-       return pdc_iodc_getc();
+       int c;
+       unsigned long flags;
+
+       spin_lock_irqsave(&pdc_console_lock, flags);
+       c = pdc_iodc_getc();
+       spin_unlock_irqrestore(&pdc_console_lock, flags);
+
+       return c;
 }
 
 static int pdc_console_setup(struct console *co, char *options)