Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / drivers / char / sx.c
index 3ad758a..8cc1487 100644 (file)
 #define RCS_ID "$Id: sx.c,v 1.33 2000/03/08 10:01:02 wolff, pvdl Exp $"
 #define RCS_REV "$Revision: 1.33 $"
 
-
 #include <linux/module.h>
-#include <linux/config.h> 
 #include <linux/kdev_t.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -345,9 +343,9 @@ static int si_probe_addrs[]= {0xc0000, 0xd0000, 0xe0000,
                               0xc8000, 0xd8000, 0xe8000, 0xa0000};
 static int si1_probe_addrs[]= { 0xd0000};
 
-#define NR_SX_ADDRS (sizeof(sx_probe_addrs)/sizeof (int))
-#define NR_SI_ADDRS (sizeof(si_probe_addrs)/sizeof (int))
-#define NR_SI1_ADDRS (sizeof(si1_probe_addrs)/sizeof (int))
+#define NR_SX_ADDRS ARRAY_SIZE(sx_probe_addrs)
+#define NR_SI_ADDRS ARRAY_SIZE(si_probe_addrs)
+#define NR_SI1_ADDRS ARRAY_SIZE(si1_probe_addrs)
 
 
 /* Set the mask to all-ones. This alas, only supports 32 interrupts. 
@@ -410,7 +408,7 @@ static struct real_driver sx_real_driver = {
  *
  */
 
-static struct file_operations sx_fw_fops = {
+static const struct file_operations sx_fw_fops = {
        .owner          = THIS_MODULE,
        .ioctl          = sx_fw_ioctl,
 };
@@ -931,7 +929,7 @@ static int sx_set_real_termios (void *ptr)
        case CS6:sx_write_channel_byte (port, hi_mask, 0x3f);break;
        case CS5:sx_write_channel_byte (port, hi_mask, 0x1f);break;
        default:
-               printk (KERN_INFO "sx: Invalid wordsize: %d\n", CFLAG & CSIZE);
+               printk (KERN_INFO "sx: Invalid wordsize: %u\n", CFLAG & CSIZE);
                break;
        }
 
@@ -958,7 +956,7 @@ static int sx_set_real_termios (void *ptr)
        } else {
                set_bit(TTY_HW_COOK_IN, &port->gs.tty->flags);
        }
-       sx_dprintk (SX_DEBUG_TERMIOS, "iflags: %x(%d) ", 
+       sx_dprintk (SX_DEBUG_TERMIOS, "iflags: %x(%d) ",
                    port->gs.tty->termios->c_iflag, 
                    I_OTHER(port->gs.tty));
 
@@ -973,7 +971,7 @@ static int sx_set_real_termios (void *ptr)
        } else {
                clear_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags);
        }
-       sx_dprintk (SX_DEBUG_TERMIOS, "oflags: %x(%d)\n", 
+       sx_dprintk (SX_DEBUG_TERMIOS, "oflags: %x(%d)\n",
                    port->gs.tty->termios->c_oflag, 
                    O_OTHER(port->gs.tty));
        /* port->c_dcd = sx_get_CD (port); */
@@ -1085,6 +1083,7 @@ static inline void sx_receive_chars (struct sx_port *port)
        int rx_op;
        struct tty_struct *tty;
        int copied=0;
+       unsigned char *rp;
 
        func_enter2 ();
        tty = port->gs.tty;
@@ -1094,31 +1093,25 @@ static inline void sx_receive_chars (struct sx_port *port)
 
                sx_dprintk (SX_DEBUG_RECEIVE, "rxop=%d, c = %d.\n", rx_op, c); 
 
-               /* Don't copy more bytes than there is room for in the buffer */
-               if (tty->flip.count + c > TTY_FLIPBUF_SIZE) 
-                       c = TTY_FLIPBUF_SIZE - tty->flip.count;
-
-               sx_dprintk (SX_DEBUG_RECEIVE, "c = %d.\n", c); 
-
                /* Don't copy past the end of the hardware receive buffer */
                if (rx_op + c > 0x100) c = 0x100 - rx_op;
 
                sx_dprintk (SX_DEBUG_RECEIVE, "c = %d.\n", c);
 
+               /* Don't copy more bytes than there is room for in the buffer */
+
+               c = tty_prepare_flip_string(tty, &rp, c);
+
+               sx_dprintk (SX_DEBUG_RECEIVE, "c = %d.\n", c); 
+
                /* If for one reason or another, we can't copy more data, we're done! */
                if (c == 0) break;
 
                sx_dprintk (SX_DEBUG_RECEIVE , "Copying over %d chars. First is %d at %lx\n", c, 
                            read_sx_byte (port->board, CHAN_OFFSET(port,hi_rxbuf) + rx_op),
                            CHAN_OFFSET(port, hi_rxbuf)); 
-               memcpy_fromio (tty->flip.char_buf_ptr, 
+               memcpy_fromio (rp,
                               port->board->base + CHAN_OFFSET(port,hi_rxbuf) + rx_op, c);
-               memset(tty->flip.flag_buf_ptr, TTY_NORMAL, c);
-
-               /* Update the kernel buffer end */
-               tty->flip.count += c;
-               tty->flip.char_buf_ptr += c;
-               tty->flip.flag_buf_ptr += c;
 
                /* This one last. ( Not essential.)
                   It allows the card to start putting more data into the buffer! 
@@ -1998,7 +1991,7 @@ static int sx_init_board (struct sx_board *board)
                if(board->irq > 0) {
                        /* fixed irq, probably PCI */
                        if(sx_irqmask & (1 << board->irq)) { /* may we use this irq? */
-                               if(request_irq(board->irq, sx_interrupt, SA_SHIRQ | SA_INTERRUPT, "sx", board)) {
+                               if(request_irq(board->irq, sx_interrupt, IRQF_SHARED | IRQF_DISABLED, "sx", board)) {
                                        printk(KERN_ERR "sx: Cannot allocate irq %d.\n", board->irq);
                                        board->irq = 0;
                                }
@@ -2010,7 +2003,7 @@ static int sx_init_board (struct sx_board *board)
                        int irqmask = sx_irqmask & (IS_SX_BOARD(board) ? SX_ISA_IRQ_MASK : SI2_ISA_IRQ_MASK);
                        for(irqnr = 15; irqnr > 0; irqnr--)
                                if(irqmask & (1 << irqnr))
-                                       if(! request_irq(irqnr, sx_interrupt, SA_SHIRQ | SA_INTERRUPT, "sx", board))
+                                       if(! request_irq(irqnr, sx_interrupt, IRQF_SHARED | IRQF_DISABLED, "sx", board))
                                                break;
                        if(! irqnr)
                                printk(KERN_ERR "sx: Cannot allocate IRQ.\n");
@@ -2178,15 +2171,17 @@ static int probe_si (struct sx_board *board)
        if ( IS_SI1_BOARD(board)) {
                /* This should be an SI1 board, which has this
                   location writable... */
-               if (read_sx_byte (board, SI2_ISA_ID_BASE) != 0x10)
+               if (read_sx_byte (board, SI2_ISA_ID_BASE) != 0x10) {
                        func_exit ();
                        return 0; 
+               }
        } else {
                /* This should be an SI2 board, which has the bottom
                   3 bits non-writable... */
-               if (read_sx_byte (board, SI2_ISA_ID_BASE) == 0x10)
+               if (read_sx_byte (board, SI2_ISA_ID_BASE) == 0x10) {
                        func_exit ();
                        return 0; 
+               }
        }
 
        /* Now we're pretty much convinced that there is an SI board here, 
@@ -2197,15 +2192,17 @@ static int probe_si (struct sx_board *board)
        if ( IS_SI1_BOARD(board)) {
                /* This should be an SI1 board, which has this
                   location writable... */
-               if (read_sx_byte (board, SI2_ISA_ID_BASE) != 0x10)
+               if (read_sx_byte (board, SI2_ISA_ID_BASE) != 0x10) {
                        func_exit();
                        return 0; 
+               }
        } else {
                /* This should be an SI2 board, which has the bottom
                   3 bits non-writable... */
-               if (read_sx_byte (board, SI2_ISA_ID_BASE) == 0x10)
+               if (read_sx_byte (board, SI2_ISA_ID_BASE) == 0x10) {
                        func_exit ();
                        return 0; 
+               }
        }
 
        printheader ();
@@ -2319,9 +2316,9 @@ static int sx_init_portstructs (int nboards, int nports)
                        port->board = board;
                        port->gs.rd = &sx_real_driver;
 #ifdef NEW_WRITE_LOCKING
-                       port->gs.port_write_sem = MUTEX;
+                       port->gs.port_write_mutex = MUTEX;
 #endif
-                       port->gs.driver_lock = SPIN_LOCK_UNLOCKED;
+                       spin_lock_init(&port->gs.driver_lock);
                        /*
                         * Initializing wait queue
                         */