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 / char / synclinkmp.c
index e31235c..8587401 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: synclinkmp.c,v 4.34 2005/03/04 15:07:10 paulkf Exp $
+ * $Id: synclinkmp.c,v 4.38 2005/07/15 13:29:44 paulkf Exp $
  *
  * Device driver for Microgate SyncLink Multiport
  * high speed multiprotocol serial adapter.
@@ -55,7 +55,6 @@
 #include <linux/netdevice.h>
 #include <linux/vmalloc.h>
 #include <linux/init.h>
-#include <asm/serial.h>
 #include <linux/delay.h>
 #include <linux/ioctl.h>
 
@@ -157,8 +156,8 @@ typedef struct _synclinkmp_info {
        int                     flags;
        int                     count;          /* count of opens */
        int                     line;
-       unsigned int            close_delay;
-       unsigned int            closing_wait;   /* time to wait before closing */
+       unsigned short          close_delay;
+       unsigned short          closing_wait;   /* time to wait before closing */
 
        struct mgsl_icount      icount;
 
@@ -487,7 +486,7 @@ module_param_array(maxframe, int, NULL, 0);
 module_param_array(dosyncppp, int, NULL, 0);
 
 static char *driver_name = "SyncLink MultiPort driver";
-static char *driver_version = "$Revision: 4.34 $";
+static char *driver_version = "$Revision: 4.38 $";
 
 static int synclinkmp_init_one(struct pci_dev *dev,const struct pci_device_id *ent);
 static void synclinkmp_remove_one(struct pci_dev *dev);
@@ -556,7 +555,6 @@ static int  set_txidle(SLMP_INFO *info, int idle_mode);
 static int  tx_enable(SLMP_INFO *info, int enable);
 static int  tx_abort(SLMP_INFO *info);
 static int  rx_enable(SLMP_INFO *info, int enable);
-static int  map_status(int signals);
 static int  modem_input_wait(SLMP_INFO *info,int arg);
 static int  wait_mgsl_event(SLMP_INFO *info, int __user *mask_ptr);
 static int  tiocmget(struct tty_struct *tty, struct file *file);
@@ -645,7 +643,7 @@ static unsigned char tx_active_fifo_level = 16;     // tx request FIFO activation le
 static unsigned char tx_negate_fifo_level = 32;        // tx request FIFO negation level in bytes
 
 static u32 misc_ctrl_value = 0x007e4040;
-static u32 lcr1_brdr_value = 0x00800029;
+static u32 lcr1_brdr_value = 0x00800028;
 
 static u32 read_ahead_count = 8;
 
@@ -1652,7 +1650,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
        }
 
        info->params.encoding = new_encoding;
-       info->params.crc_type = new_crctype;;
+       info->params.crc_type = new_crctype;
 
        /* if network interface up, reprogram hardware */
        if (info->netcount)
@@ -2198,7 +2196,7 @@ void isr_rxint(SLMP_INFO * info)
                        if ( tty ) {
                                if (!(status & info->ignore_status_mask1)) {
                                        if (info->read_status_mask1 & BRKD) {
-                                               *tty->flip.flag_buf_ptr = TTY_BREAK;
+                                               tty_insert_flip_char(tty, 0, TTY_BREAK);
                                                if (info->flags & ASYNC_SAK)
                                                        do_SAK(tty);
                                        }
@@ -2242,16 +2240,10 @@ void isr_rxrdy(SLMP_INFO * info)
 
        while((status = read_reg(info,CST0)) & BIT0)
        {
+               int flag = 0;
+               int over = 0;
                DataByte = read_reg(info,TRB);
 
-               if ( tty ) {
-                       if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-                               continue;
-
-                       *tty->flip.char_buf_ptr = DataByte;
-                       *tty->flip.flag_buf_ptr = 0;
-               }
-
                icount->rx++;
 
                if ( status & (PE + FRME + OVRN) ) {
@@ -2274,42 +2266,34 @@ void isr_rxrdy(SLMP_INFO * info)
 
                        if ( tty ) {
                                if (status & PE)
-                                       *tty->flip.flag_buf_ptr = TTY_PARITY;
+                                       flag = TTY_PARITY;
                                else if (status & FRME)
-                                       *tty->flip.flag_buf_ptr = TTY_FRAME;
+                                       flag = TTY_FRAME;
                                if (status & OVRN) {
                                        /* Overrun is special, since it's
                                         * reported immediately, and doesn't
                                         * affect the current character
                                         */
-                                       if (tty->flip.count < TTY_FLIPBUF_SIZE) {
-                                               tty->flip.count++;
-                                               tty->flip.flag_buf_ptr++;
-                                               tty->flip.char_buf_ptr++;
-                                               *tty->flip.flag_buf_ptr = TTY_OVERRUN;
-                                       }
+                                       over = 1;
                                }
                        }
                }       /* end of if (error) */
 
                if ( tty ) {
-                       tty->flip.flag_buf_ptr++;
-                       tty->flip.char_buf_ptr++;
-                       tty->flip.count++;
+                       tty_insert_flip_char(tty, DataByte, flag);
+                       if (over)
+                               tty_insert_flip_char(tty, 0, TTY_OVERRUN);
                }
        }
 
        if ( debug_level >= DEBUG_LEVEL_ISR ) {
-               printk("%s(%d):%s isr_rxrdy() flip count=%d\n",
-                       __FILE__,__LINE__,info->device_name,
-                       tty ? tty->flip.count : 0);
                printk("%s(%d):%s rx=%d brk=%d parity=%d frame=%d overrun=%d\n",
                        __FILE__,__LINE__,info->device_name,
                        icount->rx,icount->brk,icount->parity,
                        icount->frame,icount->overrun);
        }
 
-       if ( tty && tty->flip.count )
+       if ( tty )
                tty_flip_buffer_push(tty);
 }
 
@@ -2750,6 +2734,8 @@ static int startup(SLMP_INFO * info)
 
        info->pending_bh = 0;
 
+       memset(&info->icount, 0, sizeof(info->icount));
+
        /* program hardware for current parameters */
        reset_port(info);
 
@@ -2787,10 +2773,8 @@ static void shutdown(SLMP_INFO * info)
        del_timer(&info->tx_timer);
        del_timer(&info->status_timer);
 
-       if (info->tx_buf) {
-               kfree(info->tx_buf);
-               info->tx_buf = NULL;
-       }
+       kfree(info->tx_buf);
+       info->tx_buf = NULL;
 
        spin_lock_irqsave(&info->lock,flags);
 
@@ -2953,12 +2937,12 @@ static int get_stats(SLMP_INFO * info, struct mgsl_icount __user *user_icount)
                printk("%s(%d):%s get_params()\n",
                         __FILE__,__LINE__, info->device_name);
 
-       COPY_TO_USER(err,user_icount, &info->icount, sizeof(struct mgsl_icount));
-       if (err) {
-               if ( debug_level >= DEBUG_LEVEL_INFO )
-                       printk( "%s(%d):%s get_stats() user buffer copy failed\n",
-                               __FILE__,__LINE__,info->device_name);
-               return -EFAULT;
+       if (!user_icount) {
+               memset(&info->icount, 0, sizeof(info->icount));
+       } else {
+               COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount));
+               if (err)
+                       return -EFAULT;
        }
 
        return 0;
@@ -3109,16 +3093,6 @@ static int rx_enable(SLMP_INFO * info, int enable)
        return 0;
 }
 
-static int map_status(int signals)
-{
-       /* Map status bits to API event bits */
-
-       return ((signals & SerialSignal_DSR) ? MgslEvent_DsrActive : MgslEvent_DsrInactive) +
-              ((signals & SerialSignal_CTS) ? MgslEvent_CtsActive : MgslEvent_CtsInactive) +
-              ((signals & SerialSignal_DCD) ? MgslEvent_DcdActive : MgslEvent_DcdInactive) +
-              ((signals & SerialSignal_RI)  ? MgslEvent_RiActive : MgslEvent_RiInactive);
-}
-
 /* wait for specified event to occur
  */
 static int wait_mgsl_event(SLMP_INFO * info, int __user *mask_ptr)
@@ -3145,7 +3119,7 @@ static int wait_mgsl_event(SLMP_INFO * info, int __user *mask_ptr)
 
        /* return immediately if state matches requested events */
        get_signals(info);
-       s = map_status(info->serial_signals);
+       s = info->serial_signals;
 
        events = mask &
                ( ((s & SerialSignal_DSR) ? MgslEvent_DsrActive:MgslEvent_DsrInactive) +
@@ -3620,8 +3594,7 @@ int alloc_tmp_rx_buf(SLMP_INFO *info)
 
 void free_tmp_rx_buf(SLMP_INFO *info)
 {
-       if (info->tmp_rx_buf)
-               kfree(info->tmp_rx_buf);
+       kfree(info->tmp_rx_buf);
        info->tmp_rx_buf = NULL;
 }
 
@@ -4489,11 +4462,13 @@ void async_mode(SLMP_INFO *info)
        /* MD2, Mode Register 2
         *
         * 07..02  Reserved, must be 0
-        * 01..00  CNCT<1..0> Channel connection, 0=normal
+        * 01..00  CNCT<1..0> Channel connection, 00=normal 11=local loopback
         *
         * 0000 0000
         */
        RegValue = 0x00;
+       if (info->params.loopback)
+               RegValue |= (BIT1 + BIT0);
        write_reg(info, MD2, RegValue);
 
        /* RXS, Receive clock source
@@ -4574,9 +4549,6 @@ void async_mode(SLMP_INFO *info)
        write_reg(info, IE2, info->ie2_value);
 
        set_rate( info, info->params.data_rate * 16 );
-
-       if (info->params.loopback)
-               enable_loopback(info,1);
 }
 
 /* Program the SCA for HDLC communications.
@@ -5118,7 +5090,7 @@ void tx_load_dma_buffer(SLMP_INFO *info, const char *buf, unsigned int count)
 int register_test(SLMP_INFO *info)
 {
        static unsigned char testval[] = {0x00, 0xff, 0xaa, 0x55, 0x69, 0x96};
-       static unsigned int count = sizeof(testval)/sizeof(unsigned char);
+       static unsigned int count = ARRAY_SIZE(testval);
        unsigned int i;
        int rc = TRUE;
        unsigned long flags;
@@ -5436,7 +5408,7 @@ int memory_test(SLMP_INFO *info)
 {
        static unsigned long testval[] = { 0x0, 0x55555555, 0xaaaaaaaa,
                0x66666666, 0x99999999, 0xffffffff, 0x12345678 };
-       unsigned long count = sizeof(testval)/sizeof(unsigned long);
+       unsigned long count = ARRAY_SIZE(testval);
        unsigned long i;
        unsigned long limit = SCA_MEM_SIZE/sizeof(unsigned long);
        unsigned long * addr = (unsigned long *)info->memory_base;