Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee13...
[pandora-kernel.git] / drivers / char / specialix.c
index 0bbfce4..c0ef0f0 100644 (file)
@@ -75,7 +75,6 @@
  * Documentation/specialix.txt
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 
 #include <asm/io.h>
@@ -85,6 +84,7 @@
 #include <linux/interrupt.h>
 #include <linux/errno.h>
 #include <linux/tty.h>
+#include <linux/tty_flip.h>
 #include <linux/mm.h>
 #include <linux/serial.h>
 #include <linux/fcntl.h>
@@ -183,7 +183,6 @@ static int sx_poll = HZ;
 
 static struct tty_driver *specialix_driver;
 static unsigned char * tmp_buf;
-static DECLARE_MUTEX(tmp_buf_sem);
 
 static unsigned long baud_table[] =  {
        0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
@@ -665,7 +664,7 @@ static inline void sx_receive_exc(struct specialix_board * bp)
        struct specialix_port *port;
        struct tty_struct *tty;
        unsigned char status;
-       unsigned char ch;
+       unsigned char ch, flag;
 
        func_enter();
 
@@ -676,8 +675,6 @@ static inline void sx_receive_exc(struct specialix_board * bp)
                return;
        }
        tty = port->tty;
-       dprintk (SX_DEBUG_RX, "port: %p count: %d BUFF_SIZE: %d\n",
-                port,  tty->flip.count, TTY_FLIPBUF_SIZE);
 
        status = sx_in(bp, CD186x_RCSR);
 
@@ -691,7 +688,7 @@ static inline void sx_receive_exc(struct specialix_board * bp)
 
        /* This flip buffer check needs to be below the reading of the
           status register to reset the chip's IRQ.... */
-       if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
+       if (tty_buffer_request_room(tty, 1) == 0) {
                dprintk(SX_DEBUG_FIFO, "sx%d: port %d: Working around flip buffer overflow.\n",
                       board_No(bp), port_No(port));
                func_exit();
@@ -712,26 +709,24 @@ static inline void sx_receive_exc(struct specialix_board * bp)
        } else if (status & RCSR_BREAK) {
                dprintk(SX_DEBUG_RX, "sx%d: port %d: Handling break...\n",
                       board_No(bp), port_No(port));
-               *tty->flip.flag_buf_ptr++ = TTY_BREAK;
+               flag = TTY_BREAK;
                if (port->flags & ASYNC_SAK)
                        do_SAK(tty);
 
        } else if (status & RCSR_PE)
-               *tty->flip.flag_buf_ptr++ = TTY_PARITY;
+               flag = TTY_PARITY;
 
        else if (status & RCSR_FE)
-               *tty->flip.flag_buf_ptr++ = TTY_FRAME;
+               flag = TTY_FRAME;
 
        else if (status & RCSR_OE)
-               *tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
+               flag = TTY_OVERRUN;
 
        else
-               *tty->flip.flag_buf_ptr++ = 0;
-
-       *tty->flip.char_buf_ptr++ = ch;
-       tty->flip.count++;
-       schedule_delayed_work(&tty->flip.work, 1);
+               flag = TTY_NORMAL;
 
+       if(tty_insert_flip_char(tty, ch, flag))
+               tty_flip_buffer_push(tty);
        func_exit();
 }
 
@@ -755,18 +750,11 @@ static inline void sx_receive(struct specialix_board * bp)
        dprintk (SX_DEBUG_RX, "port: %p: count: %d\n", port, count);
        port->hits[count > 8 ? 9 : count]++;
 
-       while (count--) {
-               if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-                       printk(KERN_INFO "sx%d: port %d: Working around flip buffer overflow.\n",
-                              board_No(bp), port_No(port));
-                       break;
-               }
-               *tty->flip.char_buf_ptr++ = sx_in(bp, CD186x_RDR);
-               *tty->flip.flag_buf_ptr++ = 0;
-               tty->flip.count++;
-       }
-       schedule_delayed_work(&tty->flip.work, 1);
+       tty_buffer_request_room(tty, count);
 
+       while (count--)
+               tty_insert_flip_char(tty, sx_in(bp, CD186x_RDR), TTY_NORMAL);
+       tty_flip_buffer_push(tty);
        func_exit();
 }
 
@@ -1027,9 +1015,9 @@ static inline int sx_setup_board(struct specialix_board * bp)
                return 0;
 
        if (bp->flags & SX_BOARD_IS_PCI)
-               error = request_irq(bp->irq, sx_interrupt, SA_INTERRUPT | SA_SHIRQ, "specialix IO8+", bp);
+               error = request_irq(bp->irq, sx_interrupt, IRQF_DISABLED | IRQF_SHARED, "specialix IO8+", bp);
        else
-               error = request_irq(bp->irq, sx_interrupt, SA_INTERRUPT, "specialix IO8+", bp);
+               error = request_irq(bp->irq, sx_interrupt, IRQF_DISABLED, "specialix IO8+", bp);
 
        if (error)
                return error;
@@ -1099,24 +1087,16 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
                port->MSVR =  (sx_in(bp, CD186x_MSVR) & MSVR_RTS);
        spin_unlock_irqrestore(&bp->lock, flags);
        dprintk (SX_DEBUG_TERMIOS, "sx: got MSVR=%02x.\n", port->MSVR);
-       baud = C_BAUD(tty);
+       baud = tty_get_baud_rate(tty);
 
-       if (baud & CBAUDEX) {
-               baud &= ~CBAUDEX;
-               if (baud < 1 || baud > 2)
-                       port->tty->termios->c_cflag &= ~CBAUDEX;
-               else
-                       baud += 15;
-       }
-       if (baud == 15) {
+       if (baud == 38400) {
                if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
                        baud ++;
                if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
                        baud += 2;
        }
 
-
-       if (!baud_table[baud]) {
+       if (!baud) {
                /* Drop DTR & exit */
                dprintk (SX_DEBUG_TERMIOS, "Dropping DTR...  Hmm....\n");
                if (!SX_CRTSCTS (tty)) {
@@ -1146,7 +1126,7 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
                                  "This is an untested option, please be carefull.\n",
                                  port_No (port), tmp);
        else
-               tmp = (((SX_OSCFREQ + baud_table[baud]/2) / baud_table[baud] +
+               tmp = (((SX_OSCFREQ + baud/2) / baud +
                         CD186x_TPC/2) / CD186x_TPC);
 
        if ((tmp < 0x10) && time_before(again, jiffies)) {
@@ -1694,7 +1674,7 @@ static int sx_write(struct tty_struct * tty,
 
        bp = port_Board(port);
 
-       if (!tty || !port->xmit_buf || !tmp_buf) {
+       if (!port->xmit_buf || !tmp_buf) {
                func_exit();
                return 0;
        }
@@ -1744,7 +1724,7 @@ static void sx_put_char(struct tty_struct * tty, unsigned char ch)
                return;
        }
        dprintk (SX_DEBUG_TX, "check tty: %p %p\n", tty, port->xmit_buf);
-       if (!tty || !port->xmit_buf) {
+       if (!port->xmit_buf) {
                func_exit();
                return;
        }
@@ -2488,7 +2468,7 @@ static int __init specialix_init(void)
 #endif
 
        for (i = 0; i < SX_NBOARD; i++)
-               sx_board[i].lock = SPIN_LOCK_UNLOCKED;
+               spin_lock_init(&sx_board[i].lock);
 
        if (sx_init_drivers()) {
                func_exit();
@@ -2566,8 +2546,6 @@ static int __init specialix_init_module(void)
 
        func_enter();
 
-       init_MUTEX(&tmp_buf_sem); /* Init de the semaphore - pvdl */
-
        if (iobase[0] || iobase[1] || iobase[2] || iobase[3]) {
                for(i = 0; i < SX_NBOARD; i++) {
                        sx_board[i].base = iobase[i];
@@ -2598,6 +2576,12 @@ static void __exit specialix_exit_module(void)
        func_exit();
 }
 
+static struct pci_device_id specialx_pci_tbl[] __devinitdata = {
+       { PCI_DEVICE(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_IO8) },
+       { }
+};
+MODULE_DEVICE_TABLE(pci, specialx_pci_tbl);
+
 module_init(specialix_init_module);
 module_exit(specialix_exit_module);