Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / serial / sa1100.c
index 98641c3..c2d9068 100644 (file)
@@ -35,7 +35,7 @@
 #include <linux/init.h>
 #include <linux/console.h>
 #include <linux/sysrq.h>
-#include <linux/device.h>
+#include <linux/platform_device.h>
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
 #include <linux/serial_core.h>
@@ -145,7 +145,7 @@ static void sa1100_timeout(unsigned long data)
 /*
  * interrupts disabled on entry
  */
-static void sa1100_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void sa1100_stop_tx(struct uart_port *port)
 {
        struct sa1100_port *sport = (struct sa1100_port *)port;
        u32 utcr3;
@@ -156,19 +156,16 @@ static void sa1100_stop_tx(struct uart_port *port, unsigned int tty_stop)
 }
 
 /*
- * interrupts may not be disabled on entry
+ * port locked and interrupts disabled
  */
-static void sa1100_start_tx(struct uart_port *port, unsigned int tty_start)
+static void sa1100_start_tx(struct uart_port *port)
 {
        struct sa1100_port *sport = (struct sa1100_port *)port;
-       unsigned long flags;
        u32 utcr3;
 
-       spin_lock_irqsave(&sport->port.lock, flags);
        utcr3 = UART_GET_UTCR3(sport);
        sport->port.read_status_mask |= UTSR0_TO_SM(UTSR0_TFS);
        UART_PUT_UTCR3(sport, utcr3 | UTCR3_TIE);
-       spin_unlock_irqrestore(&sport->port.lock, flags);
 }
 
 /*
@@ -204,8 +201,6 @@ sa1100_rx_chars(struct sa1100_port *sport, struct pt_regs *regs)
        while (status & UTSR1_TO_SM(UTSR1_RNE)) {
                ch = UART_GET_CHAR(sport);
 
-               if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-                       goto ignore_char;
                sport->port.icount.rx++;
 
                flg = TTY_NORMAL;
@@ -264,7 +259,7 @@ static void sa1100_tx_chars(struct sa1100_port *sport)
        sa1100_mctrl_check(sport);
 
        if (uart_circ_empty(xmit) || uart_tx_stopped(&sport->port)) {
-               sa1100_stop_tx(&sport->port, 0);
+               sa1100_stop_tx(&sport->port);
                return;
        }
 
@@ -284,7 +279,7 @@ static void sa1100_tx_chars(struct sa1100_port *sport)
                uart_write_wakeup(&sport->port);
 
        if (uart_circ_empty(xmit))
-               sa1100_stop_tx(&sport->port, 0);
+               sa1100_stop_tx(&sport->port);
 }
 
 static irqreturn_t sa1100_int(int irq, void *dev_id, struct pt_regs *regs)
@@ -633,7 +628,7 @@ static void __init sa1100_init_ports(void)
                sa1100_ports[i].port.ops       = &sa1100_pops;
                sa1100_ports[i].port.fifosize  = 8;
                sa1100_ports[i].port.line      = i;
-               sa1100_ports[i].port.iotype    = SERIAL_IO_MEM;
+               sa1100_ports[i].port.iotype    = UPIO_MEM;
                init_timer(&sa1100_ports[i].timer);
                sa1100_ports[i].timer.function = sa1100_timeout;
                sa1100_ports[i].timer.data     = (unsigned long)&sa1100_ports[i];
@@ -670,21 +665,21 @@ void __init sa1100_register_uart(int idx, int port)
                sa1100_ports[idx].port.membase = (void __iomem *)&Ser1UTCR0;
                sa1100_ports[idx].port.mapbase = _Ser1UTCR0;
                sa1100_ports[idx].port.irq     = IRQ_Ser1UART;
-               sa1100_ports[idx].port.flags   = ASYNC_BOOT_AUTOCONF;
+               sa1100_ports[idx].port.flags   = UPF_BOOT_AUTOCONF;
                break;
 
        case 2:
                sa1100_ports[idx].port.membase = (void __iomem *)&Ser2UTCR0;
                sa1100_ports[idx].port.mapbase = _Ser2UTCR0;
                sa1100_ports[idx].port.irq     = IRQ_Ser2ICP;
-               sa1100_ports[idx].port.flags   = ASYNC_BOOT_AUTOCONF;
+               sa1100_ports[idx].port.flags   = UPF_BOOT_AUTOCONF;
                break;
 
        case 3:
                sa1100_ports[idx].port.membase = (void __iomem *)&Ser3UTCR0;
                sa1100_ports[idx].port.mapbase = _Ser3UTCR0;
                sa1100_ports[idx].port.irq     = IRQ_Ser3UART;
-               sa1100_ports[idx].port.flags   = ASYNC_BOOT_AUTOCONF;
+               sa1100_ports[idx].port.flags   = UPF_BOOT_AUTOCONF;
                break;
 
        default:
@@ -694,6 +689,14 @@ void __init sa1100_register_uart(int idx, int port)
 
 
 #ifdef CONFIG_SERIAL_SA1100_CONSOLE
+static void sa1100_console_putchar(struct uart_port *port, int ch)
+{
+       struct sa1100_port *sport = (struct sa1100_port *)port;
+
+       while (!(UART_GET_UTSR1(sport) & UTSR1_TNF))
+               barrier();
+       UART_PUT_CHAR(sport, ch);
+}
 
 /*
  * Interrupts are disabled on entering
@@ -702,7 +705,7 @@ static void
 sa1100_console_write(struct console *co, const char *s, unsigned int count)
 {
        struct sa1100_port *sport = &sa1100_ports[co->index];
-       unsigned int old_utcr3, status, i;
+       unsigned int old_utcr3, status;
 
        /*
         *      First, save UTCR3 and then disable interrupts
@@ -711,21 +714,7 @@ sa1100_console_write(struct console *co, const char *s, unsigned int count)
        UART_PUT_UTCR3(sport, (old_utcr3 & ~(UTCR3_RIE | UTCR3_TIE)) |
                                UTCR3_TXE);
 
-       /*
-        *      Now, do each character
-        */
-       for (i = 0; i < count; i++) {
-               do {
-                       status = UART_GET_UTSR1(sport);
-               } while (!(status & UTSR1_TNF));
-               UART_PUT_CHAR(sport, s[i]);
-               if (s[i] == '\n') {
-                       do {
-                               status = UART_GET_UTSR1(sport);
-                       } while (!(status & UTSR1_TNF));
-                       UART_PUT_CHAR(sport, '\r');
-               }
-       }
+       uart_console_write(&sport->port, s, count, sa1100_console_putchar);
 
        /*
         *      Finally, wait for transmitter to become empty
@@ -799,7 +788,7 @@ sa1100_console_setup(struct console *co, char *options)
        return uart_set_options(&sport->port, co, baud, parity, bits, flow);
 }
 
-extern struct uart_driver sa1100_reg;
+static struct uart_driver sa1100_reg;
 static struct console sa1100_console = {
        .name           = "ttySA",
        .write          = sa1100_console_write,
@@ -834,29 +823,28 @@ static struct uart_driver sa1100_reg = {
        .cons                   = SA1100_CONSOLE,
 };
 
-static int sa1100_serial_suspend(struct device *_dev, pm_message_t state, u32 level)
+static int sa1100_serial_suspend(struct platform_device *dev, pm_message_t state)
 {
-       struct sa1100_port *sport = dev_get_drvdata(_dev);
+       struct sa1100_port *sport = platform_get_drvdata(dev);
 
-       if (sport && level == SUSPEND_DISABLE)
+       if (sport)
                uart_suspend_port(&sa1100_reg, &sport->port);
 
        return 0;
 }
 
-static int sa1100_serial_resume(struct device *_dev, u32 level)
+static int sa1100_serial_resume(struct platform_device *dev)
 {
-       struct sa1100_port *sport = dev_get_drvdata(_dev);
+       struct sa1100_port *sport = platform_get_drvdata(dev);
 
-       if (sport && level == RESUME_ENABLE)
+       if (sport)
                uart_resume_port(&sa1100_reg, &sport->port);
 
        return 0;
 }
 
-static int sa1100_serial_probe(struct device *_dev)
+static int sa1100_serial_probe(struct platform_device *dev)
 {
-       struct platform_device *dev = to_platform_device(_dev);
        struct resource *res = dev->resource;
        int i;
 
@@ -869,9 +857,9 @@ static int sa1100_serial_probe(struct device *_dev)
                        if (sa1100_ports[i].port.mapbase != res->start)
                                continue;
 
-                       sa1100_ports[i].port.dev = _dev;
+                       sa1100_ports[i].port.dev = &dev->dev;
                        uart_add_one_port(&sa1100_reg, &sa1100_ports[i].port);
-                       dev_set_drvdata(_dev, &sa1100_ports[i]);
+                       platform_set_drvdata(dev, &sa1100_ports[i]);
                        break;
                }
        }
@@ -879,11 +867,11 @@ static int sa1100_serial_probe(struct device *_dev)
        return 0;
 }
 
-static int sa1100_serial_remove(struct device *_dev)
+static int sa1100_serial_remove(struct platform_device *pdev)
 {
-       struct sa1100_port *sport = dev_get_drvdata(_dev);
+       struct sa1100_port *sport = platform_get_drvdata(pdev);
 
-       dev_set_drvdata(_dev, NULL);
+       platform_set_drvdata(pdev, NULL);
 
        if (sport)
                uart_remove_one_port(&sa1100_reg, &sport->port);
@@ -891,13 +879,14 @@ static int sa1100_serial_remove(struct device *_dev)
        return 0;
 }
 
-static struct device_driver sa11x0_serial_driver = {
-       .name           = "sa11x0-uart",
-       .bus            = &platform_bus_type,
+static struct platform_driver sa11x0_serial_driver = {
        .probe          = sa1100_serial_probe,
        .remove         = sa1100_serial_remove,
        .suspend        = sa1100_serial_suspend,
        .resume         = sa1100_serial_resume,
+       .driver         = {
+               .name   = "sa11x0-uart",
+       },
 };
 
 static int __init sa1100_serial_init(void)
@@ -910,7 +899,7 @@ static int __init sa1100_serial_init(void)
 
        ret = uart_register_driver(&sa1100_reg);
        if (ret == 0) {
-               ret = driver_register(&sa11x0_serial_driver);
+               ret = platform_driver_register(&sa11x0_serial_driver);
                if (ret)
                        uart_unregister_driver(&sa1100_reg);
        }
@@ -919,7 +908,7 @@ static int __init sa1100_serial_init(void)
 
 static void __exit sa1100_serial_exit(void)
 {
-       driver_unregister(&sa11x0_serial_driver);
+       platform_driver_unregister(&sa11x0_serial_driver);
        uart_unregister_driver(&sa1100_reg);
 }