Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
[safe/jmp/linux-2.6] / drivers / serial / m32r_sio.c
index b0ecc75..bea5c21 100644 (file)
@@ -25,7 +25,6 @@
  *  membase is an 'ioremapped' cookie.  This is compatible with the old
  *  serial.c driver, and is currently the preferred form.
  */
-#include <linux/config.h>
 
 #if defined(CONFIG_SERIAL_M32R_SIO_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
 #define SUPPORT_SYSRQ
  */
 #define is_real_interrupt(irq) ((irq) != 0)
 
-#include <asm/serial.h>
+#define BASE_BAUD      115200
 
 /* Standard COM flags */
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
+#define STD_COM_FLAGS (UPF_BOOT_AUTOCONF | UPF_SKIP_TEST)
 
 /*
  * SERIAL_PORT_DFNS tells us about built-in ports that have no
  * standard enumeration mechanism.   Platforms that can find all
  * serial ports via mechanisms like ACPI or PCI need not supply it.
  */
-#undef SERIAL_PORT_DFNS
 #if defined(CONFIG_PLAT_USRV)
 
 #define SERIAL_PORT_DFNS                                               \
 #endif /* !CONFIG_PLAT_USRV */
 
 static struct old_serial_port old_serial_port[] = {
-       SERIAL_PORT_DFNS        /* defined in asm/serial.h */
+       SERIAL_PORT_DFNS
 };
 
 #define UART_NR        ARRAY_SIZE(old_serial_port)
@@ -248,17 +246,17 @@ static void sio_error(int *status)
 
 #endif /* CONFIG_SERIAL_M32R_PLDSIO */
 
-static _INLINE_ unsigned int sio_in(struct uart_sio_port *up, int offset)
+static unsigned int sio_in(struct uart_sio_port *up, int offset)
 {
        return __sio_in(up->port.iobase + offset);
 }
 
-static _INLINE_ void sio_out(struct uart_sio_port *up, int offset, int value)
+static void sio_out(struct uart_sio_port *up, int offset, int value)
 {
        __sio_out(value, up->port.iobase + offset);
 }
 
-static _INLINE_ unsigned int serial_in(struct uart_sio_port *up, int offset)
+static unsigned int serial_in(struct uart_sio_port *up, int offset)
 {
        if (!offset)
                return 0;
@@ -266,8 +264,7 @@ static _INLINE_ unsigned int serial_in(struct uart_sio_port *up, int offset)
        return __sio_in(offset);
 }
 
-static _INLINE_ void
-serial_out(struct uart_sio_port *up, int offset, int value)
+static void serial_out(struct uart_sio_port *up, int offset, int value)
 {
        if (!offset)
                return;
@@ -289,7 +286,7 @@ static void m32r_sio_start_tx(struct uart_port *port)
 {
 #ifdef CONFIG_SERIAL_M32R_PLDSIO
        struct uart_sio_port *up = (struct uart_sio_port *)port;
-       struct circ_buf *xmit = &up->port.info->xmit;
+       struct circ_buf *xmit = &up->port.state->xmit;
 
        if (!(up->ier & UART_IER_THRI)) {
                up->ier |= UART_IER_THRI;
@@ -326,22 +323,16 @@ static void m32r_sio_enable_ms(struct uart_port *port)
        serial_out(up, UART_IER, up->ier);
 }
 
-static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status,
-       struct pt_regs *regs)
+static void receive_chars(struct uart_sio_port *up, int *status)
 {
-       struct tty_struct *tty = up->port.info->tty;
+       struct tty_struct *tty = up->port.state->port.tty;
        unsigned char ch;
+       unsigned char flag;
        int max_count = 256;
 
        do {
-               if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) {
-                       tty->flip.work.func((void *)tty);
-                       if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-                               return; // if TTY_DONT_FLIP is set
-               }
                ch = sio_in(up, SIORXB);
-               *tty->flip.char_buf_ptr = ch;
-               *tty->flip.flag_buf_ptr = TTY_NORMAL;
+               flag = TTY_NORMAL;
                up->port.icount.rx++;
 
                if (unlikely(*status & (UART_LSR_BI | UART_LSR_PE |
@@ -380,30 +371,24 @@ static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status,
 
                        if (*status & UART_LSR_BI) {
                                DEBUG_INTR("handling break....");
-                               *tty->flip.flag_buf_ptr = TTY_BREAK;
+                               flag = TTY_BREAK;
                        } else if (*status & UART_LSR_PE)
-                               *tty->flip.flag_buf_ptr = TTY_PARITY;
+                               flag = TTY_PARITY;
                        else if (*status & UART_LSR_FE)
-                               *tty->flip.flag_buf_ptr = TTY_FRAME;
+                               flag = TTY_FRAME;
                }
-               if (uart_handle_sysrq_char(&up->port, ch, regs))
+               if (uart_handle_sysrq_char(&up->port, ch))
                        goto ignore_char;
-               if ((*status & up->port.ignore_status_mask) == 0) {
-                       tty->flip.flag_buf_ptr++;
-                       tty->flip.char_buf_ptr++;
-                       tty->flip.count++;
-               }
-               if ((*status & UART_LSR_OE) &&
-                   tty->flip.count < TTY_FLIPBUF_SIZE) {
+               if ((*status & up->port.ignore_status_mask) == 0)
+                       tty_insert_flip_char(tty, ch, flag);
+
+               if (*status & UART_LSR_OE) {
                        /*
                         * Overrun is special, since it's reported
                         * immediately, and doesn't affect the current
                         * character.
                         */
-                       *tty->flip.flag_buf_ptr = TTY_OVERRUN;
-                       tty->flip.flag_buf_ptr++;
-                       tty->flip.char_buf_ptr++;
-                       tty->flip.count++;
+                       tty_insert_flip_char(tty, 0, TTY_OVERRUN);
                }
        ignore_char:
                *status = serial_in(up, UART_LSR);
@@ -411,9 +396,9 @@ static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status,
        tty_flip_buffer_push(tty);
 }
 
-static _INLINE_ void transmit_chars(struct uart_sio_port *up)
+static void transmit_chars(struct uart_sio_port *up)
 {
-       struct circ_buf *xmit = &up->port.info->xmit;
+       struct circ_buf *xmit = &up->port.state->xmit;
        int count;
 
        if (up->port.x_char) {
@@ -436,7 +421,7 @@ static _INLINE_ void transmit_chars(struct uart_sio_port *up)
                up->port.icount.tx++;
                if (uart_circ_empty(xmit))
                        break;
-               while (!serial_in(up, UART_LSR) & UART_LSR_THRE);
+               while (!(serial_in(up, UART_LSR) & UART_LSR_THRE));
 
        } while (--count > 0);
 
@@ -453,12 +438,12 @@ static _INLINE_ void transmit_chars(struct uart_sio_port *up)
  * This handles the interrupt from one port.
  */
 static inline void m32r_sio_handle_port(struct uart_sio_port *up,
-       unsigned int status, struct pt_regs *regs)
+       unsigned int status)
 {
        DEBUG_INTR("status = %x...", status);
 
        if (status & 0x04)
-               receive_chars(up, &status, regs);
+               receive_chars(up, &status);
        if (status & 0x01)
                transmit_chars(up);
 }
@@ -477,8 +462,7 @@ static inline void m32r_sio_handle_port(struct uart_sio_port *up,
  * This means we need to loop through all ports. checking that they
  * don't have an interrupt pending.
  */
-static irqreturn_t m32r_sio_interrupt(int irq, void *dev_id,
-       struct pt_regs *regs)
+static irqreturn_t m32r_sio_interrupt(int irq, void *dev_id)
 {
        struct irq_info *i = dev_id;
        struct list_head *l, *end = NULL;
@@ -506,7 +490,7 @@ static irqreturn_t m32r_sio_interrupt(int irq, void *dev_id,
                sts = sio_in(up, SIOSTS);
                if (sts & 0x5) {
                        spin_lock(&up->port.lock);
-                       m32r_sio_handle_port(up, sts, regs);
+                       m32r_sio_handle_port(up, sts);
                        spin_unlock(&up->port.lock);
 
                        end = NULL;
@@ -555,7 +539,7 @@ static void serial_do_unlink(struct irq_info *i, struct uart_sio_port *up)
 static int serial_link_irq_chain(struct uart_sio_port *up)
 {
        struct irq_info *i = irq_lists + up->port.irq;
-       int ret, irq_flags = up->port.flags & UPF_SHARE_IRQ ? SA_SHIRQ : 0;
+       int ret, irq_flags = 0;
 
        spin_lock_irq(&i->lock);
 
@@ -606,7 +590,7 @@ static void m32r_sio_timeout(unsigned long data)
        sts = sio_in(up, SIOSTS);
        if (sts & 0x5) {
                spin_lock(&up->port.lock);
-               m32r_sio_handle_port(up, sts, NULL);
+               m32r_sio_handle_port(up, sts);
                spin_unlock(&up->port.lock);
        }
 
@@ -715,7 +699,7 @@ static unsigned int m32r_sio_get_divisor(struct uart_port *port,
 }
 
 static void m32r_sio_set_termios(struct uart_port *port,
-       struct termios *termios, struct termios *old)
+       struct ktermios *termios, struct ktermios *old)
 {
        struct uart_sio_port *up = (struct uart_sio_port *)port;
        unsigned char cval = 0;
@@ -938,7 +922,7 @@ static void m32r_sio_config_port(struct uart_port *port, int flags)
 static int
 m32r_sio_verify_port(struct uart_port *port, struct serial_struct *ser)
 {
-       if (ser->irq >= NR_IRQS || ser->irq < 0 ||
+       if (ser->irq >= nr_irqs || ser->irq < 0 ||
            ser->baud_base < 9600 || ser->type < PORT_UNKNOWN ||
            ser->type >= ARRAY_SIZE(uart_config))
                return -EINVAL;
@@ -1050,6 +1034,14 @@ static inline void wait_for_xmitr(struct uart_sio_port *up)
        }
 }
 
+static void m32r_sio_console_putchar(struct uart_port *port, int ch)
+{
+       struct uart_sio_port *up = (struct uart_sio_port *)port;
+
+       wait_for_xmitr(up);
+       sio_out(up, SIOTXB, ch);
+}
+
 /*
  *     Print a string to the serial port trying not to disturb
  *     any possible real use of the port...
@@ -1061,7 +1053,6 @@ static void m32r_sio_console_write(struct console *co, const char *s,
 {
        struct uart_sio_port *up = &m32r_sio_ports[co->index];
        unsigned int ier;
-       int i;
 
        /*
         *      First save the UER then disable the interrupts
@@ -1069,23 +1060,7 @@ static void m32r_sio_console_write(struct console *co, const char *s,
        ier = sio_in(up, SIOTRCR);
        sio_out(up, SIOTRCR, 0);
 
-       /*
-        *      Now, do each character
-        */
-       for (i = 0; i < count; i++, s++) {
-               wait_for_xmitr(up);
-
-               /*
-                *      Send the character out.
-                *      If a LF, also do CR...
-                */
-               sio_out(up, SIOTXB, *s);
-
-               if (*s == 10) {
-                       wait_for_xmitr(up);
-                       sio_out(up, SIOTXB, 13);
-               }
-       }
+       uart_console_write(&up->port, s, count, m32r_sio_console_putchar);
 
        /*
         *      Finally, wait for transmitter to become empty
@@ -1152,7 +1127,6 @@ console_initcall(m32r_sio_console_init);
 static struct uart_driver m32r_sio_reg = {
        .owner                  = THIS_MODULE,
        .driver_name            = "sio",
-       .devfs_name             = "tts/",
        .dev_name               = "ttyS",
        .major                  = TTY_MAJOR,
        .minor                  = 64,
@@ -1186,9 +1160,9 @@ static int __init m32r_sio_init(void)
 {
        int ret, i;
 
-       printk(KERN_INFO "Serial: M32R SIO driver $Revision: 1.11 $ ");
+       printk(KERN_INFO "Serial: M32R SIO driver\n");
 
-       for (i = 0; i < NR_IRQS; i++)
+       for (i = 0; i < nr_irqs; i++)
                spin_lock_init(&irq_lists[i].lock);
 
        ret = uart_register_driver(&m32r_sio_reg);
@@ -1215,4 +1189,4 @@ EXPORT_SYMBOL(m32r_sio_suspend_port);
 EXPORT_SYMBOL(m32r_sio_resume_port);
 
 MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("Generic M32R SIO serial driver $Revision: 1.11 $");
+MODULE_DESCRIPTION("Generic M32R SIO serial driver");