]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/serial/sunsab.c
Start split out of common open firmware code
[linux-2.6-omap-h63xx.git] / drivers / serial / sunsab.c
index 493d5bbb661be7daacc3e3f11aca47c32932811f..8a0f9e4408d4a78976040178885efc1571b7a184 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
 #include <linux/errno.h>
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
@@ -861,22 +860,31 @@ static int num_channels;
 static void sunsab_console_putchar(struct uart_port *port, int c)
 {
        struct uart_sunsab_port *up = (struct uart_sunsab_port *)port;
-       unsigned long flags;
-
-       spin_lock_irqsave(&up->port.lock, flags);
 
        sunsab_tec_wait(up);
        writeb(c, &up->regs->w.tic);
-
-       spin_unlock_irqrestore(&up->port.lock, flags);
 }
 
 static void sunsab_console_write(struct console *con, const char *s, unsigned n)
 {
        struct uart_sunsab_port *up = &sunsab_ports[con->index];
+       unsigned long flags;
+       int locked = 1;
+
+       local_irq_save(flags);
+       if (up->port.sysrq) {
+               locked = 0;
+       } else if (oops_in_progress) {
+               locked = spin_trylock(&up->port.lock);
+       } else
+               spin_lock(&up->port.lock);
 
        uart_console_write(&up->port, s, n, sunsab_console_putchar);
        sunsab_tec_wait(up);
+
+       if (locked)
+               spin_unlock(&up->port.lock);
+       local_irq_restore(flags);
 }
 
 static int sunsab_console_setup(struct console *con, char *options)
@@ -1037,7 +1045,8 @@ static int __devinit sunsab_init_one(struct uart_sunsab_port *up,
                err = request_irq(up->port.irq, sunsab_interrupt,
                                  IRQF_SHARED, "sab", up);
                if (err) {
-                       of_iounmap(up->port.membase,
+                       of_iounmap(&op->resource[0],
+                                  up->port.membase,
                                   sizeof(union sab82532_async_regs));
                        return err;
                }
@@ -1064,7 +1073,8 @@ static int __devinit sab_probe(struct of_device *op, const struct of_device_id *
                              sizeof(union sab82532_async_regs),
                              (inst * 2) + 1);
        if (err) {
-               of_iounmap(up[0].port.membase,
+               of_iounmap(&op->resource[0],
+                          up[0].port.membase,
                           sizeof(union sab82532_async_regs));
                free_irq(up[0].port.irq, &up[0]);
                return err;
@@ -1082,10 +1092,13 @@ static int __devinit sab_probe(struct of_device *op, const struct of_device_id *
 
 static void __devexit sab_remove_one(struct uart_sunsab_port *up)
 {
+       struct of_device *op = to_of_device(up->port.dev);
+
        uart_remove_one_port(&sunsab_reg, &up->port);
        if (!(up->port.line & 1))
                free_irq(up->port.irq, up);
-       of_iounmap(up->port.membase,
+       of_iounmap(&op->resource[0],
+                  up->port.membase,
                   sizeof(union sab82532_async_regs));
 }