edac: add e752x parameter for sysbus_parity selection
[safe/jmp/linux-2.6] / drivers / char / synclinkmp.c
index ec949e4..e98c3e6 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.
@@ -34,7 +34,6 @@
 
 #define MAX_DEVICES 12
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/signal.h>
@@ -55,7 +54,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>
 
 #include <linux/termios.h>
 #include <linux/workqueue.h>
 #include <linux/hdlc.h>
+#include <linux/synclink.h>
 
-#ifdef CONFIG_HDLC_MODULE
-#define CONFIG_HDLC 1
+#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINKMP_MODULE))
+#define SYNCLINK_GENERIC_HDLC 1
+#else
+#define SYNCLINK_GENERIC_HDLC 0
 #endif
 
 #define GET_USER(error,value,addr) error = get_user(value,addr)
@@ -80,8 +81,6 @@
 
 #include <asm/uaccess.h>
 
-#include "linux/synclink.h"
-
 static MGSL_PARAMS default_params = {
        MGSL_MODE_HDLC,                 /* unsigned long mode */
        0,                              /* unsigned char loopback; */
@@ -135,8 +134,6 @@ typedef struct _SCADESC_EX
 
 #define IO_PIN_SHUTDOWN_LIMIT 100
 
-#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
-
 struct _input_signal_events {
        int     ri_up;
        int     ri_down;
@@ -191,9 +188,9 @@ typedef struct _synclinkmp_info {
 
        u32 pending_bh;
 
-       int bh_running;                         /* Protection from multiple */
+       bool bh_running;                                /* Protection from multiple */
        int isr_overflow;
-       int bh_requested;
+       bool bh_requested;
 
        int dcd_chkcount;                       /* check counts to prevent */
        int cts_chkcount;                       /* too many IRQs if a signal */
@@ -216,11 +213,11 @@ typedef struct _synclinkmp_info {
        unsigned char *tmp_rx_buf;
        unsigned int tmp_rx_buf_count;
 
-       int rx_enabled;
-       int rx_overflow;
+       bool rx_enabled;
+       bool rx_overflow;
 
-       int tx_enabled;
-       int tx_active;
+       bool tx_enabled;
+       bool tx_active;
        u32 idle_mode;
 
        unsigned char ie0_value;
@@ -241,13 +238,13 @@ typedef struct _synclinkmp_info {
 
        unsigned int irq_level;                 /* interrupt level */
        unsigned long irq_flags;
-       int irq_requested;                      /* nonzero if IRQ requested */
+       bool irq_requested;                     /* true if IRQ requested */
 
        MGSL_PARAMS params;                     /* communications parameters */
 
        unsigned char serial_signals;           /* current serial signal states */
 
-       int irq_occurred;                       /* for diagnostics use */
+       bool irq_occurred;                      /* for diagnostics use */
        unsigned int init_error;                /* Initialization startup error */
 
        u32 last_mem_alloc;
@@ -258,7 +255,7 @@ typedef struct _synclinkmp_info {
        unsigned char* sca_base;                /* HD64570 SCA Memory address */
        u32 phys_sca_base;
        u32 sca_offset;
-       int sca_base_requested;
+       bool sca_base_requested;
 
        unsigned char* lcr_base;                /* local config registers (PCI only) */
        u32 phys_lcr_base;
@@ -268,12 +265,12 @@ typedef struct _synclinkmp_info {
        unsigned char* statctrl_base;           /* status/control register memory */
        u32 phys_statctrl_base;
        u32 statctrl_offset;
-       int sca_statctrl_requested;
+       bool sca_statctrl_requested;
 
        u32 misc_ctrl_value;
        char flag_buf[MAX_ASYNC_BUFFER_SIZE];
        char char_buf[MAX_ASYNC_BUFFER_SIZE];
-       BOOLEAN drop_rts_on_tx_done;
+       bool drop_rts_on_tx_done;
 
        struct  _input_signal_events    input_signal_events;
 
@@ -282,7 +279,7 @@ typedef struct _synclinkmp_info {
        int dosyncppp;
        spinlock_t netlock;
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        struct net_device *netdev;
 #endif
 
@@ -487,7 +484,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);
@@ -519,7 +516,7 @@ static struct tty_driver *serial_driver;
 static int  open(struct tty_struct *tty, struct file * filp);
 static void close(struct tty_struct *tty, struct file * filp);
 static void hangup(struct tty_struct *tty);
-static void set_termios(struct tty_struct *tty, struct termios *old_termios);
+static void set_termios(struct tty_struct *tty, struct ktermios *old_termios);
 
 static int  write(struct tty_struct *tty, const unsigned char *buf, int count);
 static void put_char(struct tty_struct *tty, unsigned char ch);
@@ -538,7 +535,7 @@ static void throttle(struct tty_struct * tty);
 static void unthrottle(struct tty_struct * tty);
 static void set_break(struct tty_struct *tty, int break_state);
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
 #define dev_to_port(D) (dev_to_hdlc(D)->priv)
 static void hdlcdev_tx_done(SLMP_INFO *info);
 static void hdlcdev_rx(SLMP_INFO *info, char *buf, int size);
@@ -556,7 +553,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);
@@ -575,12 +571,12 @@ static void shutdown(SLMP_INFO *info);
 static void program_hw(SLMP_INFO *info);
 static void change_params(SLMP_INFO *info);
 
-static int  init_adapter(SLMP_INFO *info);
-static int  register_test(SLMP_INFO *info);
-static int  irq_test(SLMP_INFO *info);
-static int  loopback_test(SLMP_INFO *info);
+static bool init_adapter(SLMP_INFO *info);
+static bool register_test(SLMP_INFO *info);
+static bool irq_test(SLMP_INFO *info);
+static bool loopback_test(SLMP_INFO *info);
 static int  adapter_test(SLMP_INFO *info);
-static int  memory_test(SLMP_INFO *info);
+static bool memory_test(SLMP_INFO *info);
 
 static void reset_adapter(SLMP_INFO *info);
 static void reset_port(SLMP_INFO *info);
@@ -591,7 +587,7 @@ static void rx_stop(SLMP_INFO *info);
 static void rx_start(SLMP_INFO *info);
 static void rx_reset_buffers(SLMP_INFO *info);
 static void rx_free_frame_buffers(SLMP_INFO *info, unsigned int first, unsigned int last);
-static int  rx_get_frame(SLMP_INFO *info);
+static bool rx_get_frame(SLMP_INFO *info);
 
 static void tx_start(SLMP_INFO *info);
 static void tx_stop(SLMP_INFO *info);
@@ -605,7 +601,7 @@ static void enable_loopback(SLMP_INFO *info, int enable);
 static void set_rate(SLMP_INFO *info, u32 data_rate);
 
 static int  bh_action(SLMP_INFO *info);
-static void bh_handler(void* Context);
+static void bh_handler(struct work_struct *work);
 static void bh_receive(SLMP_INFO *info);
 static void bh_transmit(SLMP_INFO *info);
 static void bh_status(SLMP_INFO *info);
@@ -645,7 +641,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;
 
@@ -919,7 +915,7 @@ static void hangup(struct tty_struct *tty)
 
 /* Set new termios settings
  */
-static void set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        SLMP_INFO *info = (SLMP_INFO *)tty->driver_data;
        unsigned long flags;
@@ -928,12 +924,6 @@ static void set_termios(struct tty_struct *tty, struct termios *old_termios)
                printk("%s(%d):%s set_termios()\n", __FILE__,__LINE__,
                        tty->driver->name );
 
-       /* just return if nothing has changed */
-       if ((tty->termios->c_cflag == old_termios->c_cflag)
-           && (RELEVANT_IFLAG(tty->termios->c_iflag)
-               == RELEVANT_IFLAG(old_termios->c_iflag)))
-         return;
-
        change_params(info);
 
        /* Handle transition to B0 status */
@@ -990,7 +980,7 @@ static int write(struct tty_struct *tty,
        if (sanity_check(info, tty->name, "write"))
                goto cleanup;
 
-       if (!tty || !info->tx_buf)
+       if (!info->tx_buf)
                goto cleanup;
 
        if (info->params.mode == MGSL_MODE_HDLC) {
@@ -1069,7 +1059,7 @@ static void put_char(struct tty_struct *tty, unsigned char ch)
        if (sanity_check(info, tty->name, "put_char"))
                return;
 
-       if (!tty || !info->tx_buf)
+       if (!info->tx_buf)
                return;
 
        spin_lock_irqsave(&info->lock,flags);
@@ -1259,7 +1249,6 @@ static void flush_buffer(struct tty_struct *tty)
        del_timer(&info->tx_timer);
        spin_unlock_irqrestore(&info->lock,flags);
 
-       wake_up_interruptible(&tty->write_wait);
        tty_wakeup(tty);
 }
 
@@ -1484,7 +1473,7 @@ static inline int line_info(char *buf, SLMP_INFO *info)
 
 /* Called to print information about devices
  */
-int read_proc(char *page, char **start, off_t off, int count,
+static int read_proc(char *page, char **start, off_t off, int count,
              int *eof, void *data)
 {
        int len = 0, l;
@@ -1610,7 +1599,7 @@ static void set_break(struct tty_struct *tty, int break_state)
        spin_unlock_irqrestore(&info->lock,flags);
 }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
 
 /**
  * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
@@ -1652,7 +1641,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)
@@ -1755,8 +1744,10 @@ static int hdlcdev_open(struct net_device *dev)
        spin_lock_irqsave(&info->lock, flags);
        get_signals(info);
        spin_unlock_irqrestore(&info->lock, flags);
-       hdlc_set_carrier(info->serial_signals & SerialSignal_DCD, dev);
-
+       if (info->serial_signals & SerialSignal_DCD)
+               netif_carrier_on(dev);
+       else
+               netif_carrier_off(dev);
        return 0;
 }
 
@@ -2033,7 +2024,7 @@ static void hdlcdev_exit(SLMP_INFO *info)
 /* Return next bottom half action to perform.
  * Return Value:       BH action code or 0 if nothing to do.
  */
-int bh_action(SLMP_INFO *info)
+static int bh_action(SLMP_INFO *info)
 {
        unsigned long flags;
        int rc = 0;
@@ -2053,8 +2044,8 @@ int bh_action(SLMP_INFO *info)
 
        if (!rc) {
                /* Mark BH routine as complete */
-               info->bh_running   = 0;
-               info->bh_requested = 0;
+               info->bh_running = false;
+               info->bh_requested = false;
        }
 
        spin_unlock_irqrestore(&info->lock,flags);
@@ -2064,9 +2055,9 @@ int bh_action(SLMP_INFO *info)
 
 /* Perform bottom half processing of work items queued by ISR.
  */
-void bh_handler(void* Context)
+static void bh_handler(struct work_struct *work)
 {
-       SLMP_INFO *info = (SLMP_INFO*)Context;
+       SLMP_INFO *info = container_of(work, SLMP_INFO, task);
        int action;
 
        if (!info)
@@ -2076,7 +2067,7 @@ void bh_handler(void* Context)
                printk( "%s(%d):%s bh_handler() entry\n",
                        __FILE__,__LINE__,info->device_name);
 
-       info->bh_running = 1;
+       info->bh_running = true;
 
        while((action = bh_action(info)) != 0) {
 
@@ -2109,7 +2100,7 @@ void bh_handler(void* Context)
                        __FILE__,__LINE__,info->device_name);
 }
 
-void bh_receive(SLMP_INFO *info)
+static void bh_receive(SLMP_INFO *info)
 {
        if ( debug_level >= DEBUG_LEVEL_BH )
                printk( "%s(%d):%s bh_receive()\n",
@@ -2118,7 +2109,7 @@ void bh_receive(SLMP_INFO *info)
        while( rx_get_frame(info) );
 }
 
-void bh_transmit(SLMP_INFO *info)
+static void bh_transmit(SLMP_INFO *info)
 {
        struct tty_struct *tty = info->tty;
 
@@ -2126,13 +2117,11 @@ void bh_transmit(SLMP_INFO *info)
                printk( "%s(%d):%s bh_transmit() entry\n",
                        __FILE__,__LINE__,info->device_name);
 
-       if (tty) {
+       if (tty)
                tty_wakeup(tty);
-               wake_up_interruptible(&tty->write_wait);
-       }
 }
 
-void bh_status(SLMP_INFO *info)
+static void bh_status(SLMP_INFO *info)
 {
        if ( debug_level >= DEBUG_LEVEL_BH )
                printk( "%s(%d):%s bh_status() entry\n",
@@ -2144,7 +2133,7 @@ void bh_status(SLMP_INFO *info)
        info->cts_chkcount = 0;
 }
 
-void isr_timer(SLMP_INFO * info)
+static void isr_timer(SLMP_INFO * info)
 {
        unsigned char timer = (info->port_num & 1) ? TIMER2 : TIMER0;
 
@@ -2163,14 +2152,14 @@ void isr_timer(SLMP_INFO * info)
         */
        write_reg(info, (unsigned char)(timer + TMCS), 0);
 
-       info->irq_occurred = TRUE;
+       info->irq_occurred = true;
 
        if ( debug_level >= DEBUG_LEVEL_ISR )
                printk("%s(%d):%s isr_timer()\n",
                        __FILE__,__LINE__,info->device_name);
 }
 
-void isr_rxint(SLMP_INFO * info)
+static void isr_rxint(SLMP_INFO * info)
 {
        struct tty_struct *tty = info->tty;
        struct  mgsl_icount *icount = &info->icount;
@@ -2198,7 +2187,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);
                                        }
@@ -2229,7 +2218,7 @@ void isr_rxint(SLMP_INFO * info)
 /*
  * handle async rx data interrupts
  */
-void isr_rxrdy(SLMP_INFO * info)
+static void isr_rxrdy(SLMP_INFO * info)
 {
        u16 status;
        unsigned char DataByte;
@@ -2242,16 +2231,10 @@ void isr_rxrdy(SLMP_INFO * info)
 
        while((status = read_reg(info,CST0)) & BIT0)
        {
+               int flag = 0;
+               bool over = false;
                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 +2257,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 = true;
                                }
                        }
                }       /* 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);
 }
 
@@ -2343,18 +2318,18 @@ static void isr_txeom(SLMP_INFO * info, unsigned char status)
                                info->icount.txok++;
                }
 
-               info->tx_active = 0;
+               info->tx_active = false;
                info->tx_count = info->tx_put = info->tx_get = 0;
 
                del_timer(&info->tx_timer);
 
                if (info->params.mode != MGSL_MODE_ASYNC && info->drop_rts_on_tx_done ) {
                        info->serial_signals &= ~SerialSignal_RTS;
-                       info->drop_rts_on_tx_done = 0;
+                       info->drop_rts_on_tx_done = false;
                        set_signals(info);
                }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                if (info->netcount)
                        hdlcdev_tx_done(info);
                else
@@ -2373,7 +2348,7 @@ static void isr_txeom(SLMP_INFO * info, unsigned char status)
 /*
  * handle tx status interrupts
  */
-void isr_txint(SLMP_INFO * info)
+static void isr_txint(SLMP_INFO * info)
 {
        unsigned char status = read_reg(info, SR1) & info->ie1_value & (UDRN + IDLE + CCTS);
 
@@ -2401,7 +2376,7 @@ void isr_txint(SLMP_INFO * info)
 /*
  * handle async tx data interrupts
  */
-void isr_txrdy(SLMP_INFO * info)
+static void isr_txrdy(SLMP_INFO * info)
 {
        if ( debug_level >= DEBUG_LEVEL_ISR )
                printk("%s(%d):%s isr_txrdy() tx_count=%d\n",
@@ -2423,7 +2398,7 @@ void isr_txrdy(SLMP_INFO * info)
        if ( info->tx_count )
                tx_load_fifo( info );
        else {
-               info->tx_active = 0;
+               info->tx_active = false;
                info->ie0_value &= ~TXRDYE;
                write_reg(info, IE0, info->ie0_value);
        }
@@ -2432,7 +2407,7 @@ void isr_txrdy(SLMP_INFO * info)
                info->pending_bh |= BH_TRANSMIT;
 }
 
-void isr_rxdmaok(SLMP_INFO * info)
+static void isr_rxdmaok(SLMP_INFO * info)
 {
        /* BIT7 = EOT (end of transfer)
         * BIT6 = EOM (end of message/frame)
@@ -2449,7 +2424,7 @@ void isr_rxdmaok(SLMP_INFO * info)
        info->pending_bh |= BH_RECEIVE;
 }
 
-void isr_rxdmaerror(SLMP_INFO * info)
+static void isr_rxdmaerror(SLMP_INFO * info)
 {
        /* BIT5 = BOF (buffer overflow)
         * BIT4 = COF (counter overflow)
@@ -2463,11 +2438,11 @@ void isr_rxdmaerror(SLMP_INFO * info)
                printk("%s(%d):%s isr_rxdmaerror(), status=%02x\n",
                        __FILE__,__LINE__,info->device_name,status);
 
-       info->rx_overflow = TRUE;
+       info->rx_overflow = true;
        info->pending_bh |= BH_RECEIVE;
 }
 
-void isr_txdmaok(SLMP_INFO * info)
+static void isr_txdmaok(SLMP_INFO * info)
 {
        unsigned char status_reg1 = read_reg(info, SR1);
 
@@ -2485,7 +2460,7 @@ void isr_txdmaok(SLMP_INFO * info)
        write_reg(info, IE0, info->ie0_value);
 }
 
-void isr_txdmaerror(SLMP_INFO * info)
+static void isr_txdmaerror(SLMP_INFO * info)
 {
        /* BIT5 = BOF (buffer overflow)
         * BIT4 = COF (counter overflow)
@@ -2502,7 +2477,7 @@ void isr_txdmaerror(SLMP_INFO * info)
 
 /* handle input serial signal changes
  */
-void isr_io_pin( SLMP_INFO *info, u16 status )
+static void isr_io_pin( SLMP_INFO *info, u16 status )
 {
        struct  mgsl_icount *icount;
 
@@ -2538,9 +2513,13 @@ void isr_io_pin( SLMP_INFO *info, u16 status )
                                info->input_signal_events.dcd_up++;
                        } else
                                info->input_signal_events.dcd_down++;
-#ifdef CONFIG_HDLC
-                       if (info->netcount)
-                               hdlc_set_carrier(status & SerialSignal_DCD, info->netdev);
+#if SYNCLINK_GENERIC_HDLC
+                       if (info->netcount) {
+                               if (status & SerialSignal_DCD)
+                                       netif_carrier_on(info->netdev);
+                               else
+                                       netif_carrier_off(info->netdev);
+                       }
 #endif
                }
                if (status & MISCSTATUS_CTS_LATCHED)
@@ -2607,10 +2586,9 @@ void isr_io_pin( SLMP_INFO *info, u16 status )
  *     dev_id          device ID supplied during interrupt registration
  *     regs            interrupted processor context
  */
-static irqreturn_t synclinkmp_interrupt(int irq, void *dev_id,
-                                       struct pt_regs *regs)
+static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
 {
-       SLMP_INFO * info;
+       SLMP_INFO *info = dev_id;
        unsigned char status, status0, status1=0;
        unsigned char dmastatus, dmastatus0, dmastatus1=0;
        unsigned char timerstatus0, timerstatus1=0;
@@ -2619,12 +2597,8 @@ static irqreturn_t synclinkmp_interrupt(int irq, void *dev_id,
        unsigned short tmp;
 
        if ( debug_level >= DEBUG_LEVEL_ISR )
-               printk("%s(%d): synclinkmp_interrupt(%d)entry.\n",
-                       __FILE__,__LINE__,irq);
-
-       info = (SLMP_INFO *)dev_id;
-       if (!info)
-               return IRQ_NONE;
+               printk(KERN_DEBUG "%s(%d): synclinkmp_interrupt(%d)entry.\n",
+                       __FILE__, __LINE__, info->irq_level);
 
        spin_lock(&info->lock);
 
@@ -2637,9 +2611,9 @@ static irqreturn_t synclinkmp_interrupt(int irq, void *dev_id,
                timerstatus0 = read_reg(info, ISR2);
 
                if ( debug_level >= DEBUG_LEVEL_ISR )
-                       printk("%s(%d):%s status0=%02x, dmastatus0=%02x, timerstatus0=%02x\n",
-                               __FILE__,__LINE__,info->device_name,
-                               status0,dmastatus0,timerstatus0);
+                       printk(KERN_DEBUG "%s(%d):%s status0=%02x, dmastatus0=%02x, timerstatus0=%02x\n",
+                               __FILE__, __LINE__, info->device_name,
+                               status0, dmastatus0, timerstatus0);
 
                if (info->port_count == 4) {
                        /* get status for SCA1 (ports 2-3) */
@@ -2717,15 +2691,15 @@ static irqreturn_t synclinkmp_interrupt(int irq, void *dev_id,
                                printk("%s(%d):%s queueing bh task.\n",
                                        __FILE__,__LINE__,port->device_name);
                        schedule_work(&port->task);
-                       port->bh_requested = 1;
+                       port->bh_requested = true;
                }
        }
 
        spin_unlock(&info->lock);
 
        if ( debug_level >= DEBUG_LEVEL_ISR )
-               printk("%s(%d):synclinkmp_interrupt(%d)exit.\n",
-                       __FILE__,__LINE__,irq);
+               printk(KERN_DEBUG "%s(%d):synclinkmp_interrupt(%d)exit.\n",
+                       __FILE__, __LINE__, info->irq_level);
        return IRQ_HANDLED;
 }
 
@@ -2740,7 +2714,7 @@ static int startup(SLMP_INFO * info)
                return 0;
 
        if (!info->tx_buf) {
-               info->tx_buf = (unsigned char *)kmalloc(info->max_frame_size, GFP_KERNEL);
+               info->tx_buf = kmalloc(info->max_frame_size, GFP_KERNEL);
                if (!info->tx_buf) {
                        printk(KERN_ERR"%s(%d):%s can't allocate transmit buffer\n",
                                __FILE__,__LINE__,info->device_name);
@@ -2750,13 +2724,14 @@ 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);
 
        change_params(info);
 
-       info->status_timer.expires = jiffies + msecs_to_jiffies(10);
-       add_timer(&info->status_timer);
+       mod_timer(&info->status_timer, jiffies + msecs_to_jiffies(10));
 
        if (info->tty)
                clear_bit(TTY_IO_ERROR, &info->tty->flags);
@@ -2787,10 +2762,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 +2926,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 +3082,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 +3108,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) +
@@ -3357,7 +3320,8 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 {
        DECLARE_WAITQUEUE(wait, current);
        int             retval;
-       int             do_clocal = 0, extra_count = 0;
+       bool            do_clocal = false;
+       bool            extra_count = false;
        unsigned long   flags;
 
        if (debug_level >= DEBUG_LEVEL_INFO)
@@ -3372,7 +3336,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
        }
 
        if (tty->termios->c_cflag & CLOCAL)
-               do_clocal = 1;
+               do_clocal = true;
 
        /* Wait for carrier detect and the line to become
         * free (i.e., not in use by the callout).  While we are in
@@ -3390,7 +3354,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 
        spin_lock_irqsave(&info->lock, flags);
        if (!tty_hung_up_p(filp)) {
-               extra_count = 1;
+               extra_count = true;
                info->count--;
        }
        spin_unlock_irqrestore(&info->lock, flags);
@@ -3450,7 +3414,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
        return retval;
 }
 
-int alloc_dma_bufs(SLMP_INFO *info)
+static int alloc_dma_bufs(SLMP_INFO *info)
 {
        unsigned short BuffersPerFrame;
        unsigned short BufferCount;
@@ -3524,7 +3488,7 @@ int alloc_dma_bufs(SLMP_INFO *info)
 
 /* Allocate DMA buffers for the transmit and receive descriptor lists.
  */
-int alloc_buf_list(SLMP_INFO *info)
+static int alloc_buf_list(SLMP_INFO *info)
 {
        unsigned int i;
 
@@ -3583,7 +3547,7 @@ int alloc_buf_list(SLMP_INFO *info)
 
 /* Allocate the frame DMA buffers used by the specified buffer list.
  */
-int alloc_frame_bufs(SLMP_INFO *info, SCADESC *buf_list,SCADESC_EX *buf_list_ex,int count)
+static int alloc_frame_bufs(SLMP_INFO *info, SCADESC *buf_list,SCADESC_EX *buf_list_ex,int count)
 {
        int i;
        unsigned long phys_addr;
@@ -3600,7 +3564,7 @@ int alloc_frame_bufs(SLMP_INFO *info, SCADESC *buf_list,SCADESC_EX *buf_list_ex,
        return 0;
 }
 
-void free_dma_bufs(SLMP_INFO *info)
+static void free_dma_bufs(SLMP_INFO *info)
 {
        info->buffer_list = NULL;
        info->rx_buf_list = NULL;
@@ -3610,7 +3574,7 @@ void free_dma_bufs(SLMP_INFO *info)
 /* allocate buffer large enough to hold max_frame_size.
  * This buffer is used to pass an assembled frame to the line discipline.
  */
-int alloc_tmp_rx_buf(SLMP_INFO *info)
+static int alloc_tmp_rx_buf(SLMP_INFO *info)
 {
        info->tmp_rx_buf = kmalloc(info->max_frame_size, GFP_KERNEL);
        if (info->tmp_rx_buf == NULL)
@@ -3618,14 +3582,13 @@ int alloc_tmp_rx_buf(SLMP_INFO *info)
        return 0;
 }
 
-void free_tmp_rx_buf(SLMP_INFO *info)
+static 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;
 }
 
-int claim_resources(SLMP_INFO *info)
+static int claim_resources(SLMP_INFO *info)
 {
        if (request_mem_region(info->phys_memory_base,SCA_MEM_SIZE,"synclinkmp") == NULL) {
                printk( "%s(%d):%s mem addr conflict, Addr=%08X\n",
@@ -3634,7 +3597,7 @@ int claim_resources(SLMP_INFO *info)
                goto errout;
        }
        else
-               info->shared_mem_requested = 1;
+               info->shared_mem_requested = true;
 
        if (request_mem_region(info->phys_lcr_base + info->lcr_offset,128,"synclinkmp") == NULL) {
                printk( "%s(%d):%s lcr mem addr conflict, Addr=%08X\n",
@@ -3643,7 +3606,7 @@ int claim_resources(SLMP_INFO *info)
                goto errout;
        }
        else
-               info->lcr_mem_requested = 1;
+               info->lcr_mem_requested = true;
 
        if (request_mem_region(info->phys_sca_base + info->sca_offset,SCA_BASE_SIZE,"synclinkmp") == NULL) {
                printk( "%s(%d):%s sca mem addr conflict, Addr=%08X\n",
@@ -3652,7 +3615,7 @@ int claim_resources(SLMP_INFO *info)
                goto errout;
        }
        else
-               info->sca_base_requested = 1;
+               info->sca_base_requested = true;
 
        if (request_mem_region(info->phys_statctrl_base + info->statctrl_offset,SCA_REG_SIZE,"synclinkmp") == NULL) {
                printk( "%s(%d):%s stat/ctrl mem addr conflict, Addr=%08X\n",
@@ -3661,7 +3624,7 @@ int claim_resources(SLMP_INFO *info)
                goto errout;
        }
        else
-               info->sca_statctrl_requested = 1;
+               info->sca_statctrl_requested = true;
 
        info->memory_base = ioremap(info->phys_memory_base,SCA_MEM_SIZE);
        if (!info->memory_base) {
@@ -3712,7 +3675,7 @@ errout:
        return -ENODEV;
 }
 
-void release_resources(SLMP_INFO *info)
+static void release_resources(SLMP_INFO *info)
 {
        if ( debug_level >= DEBUG_LEVEL_INFO )
                printk( "%s(%d):%s release_resources() entry\n",
@@ -3720,24 +3683,24 @@ void release_resources(SLMP_INFO *info)
 
        if ( info->irq_requested ) {
                free_irq(info->irq_level, info);
-               info->irq_requested = 0;
+               info->irq_requested = false;
        }
 
        if ( info->shared_mem_requested ) {
                release_mem_region(info->phys_memory_base,SCA_MEM_SIZE);
-               info->shared_mem_requested = 0;
+               info->shared_mem_requested = false;
        }
        if ( info->lcr_mem_requested ) {
                release_mem_region(info->phys_lcr_base + info->lcr_offset,128);
-               info->lcr_mem_requested = 0;
+               info->lcr_mem_requested = false;
        }
        if ( info->sca_base_requested ) {
                release_mem_region(info->phys_sca_base + info->sca_offset,SCA_BASE_SIZE);
-               info->sca_base_requested = 0;
+               info->sca_base_requested = false;
        }
        if ( info->sca_statctrl_requested ) {
                release_mem_region(info->phys_statctrl_base + info->statctrl_offset,SCA_REG_SIZE);
-               info->sca_statctrl_requested = 0;
+               info->sca_statctrl_requested = false;
        }
 
        if (info->memory_base){
@@ -3768,7 +3731,7 @@ void release_resources(SLMP_INFO *info)
 /* Add the specified device instance data structure to the
  * global linked list of devices and increment the device count.
  */
-void add_device(SLMP_INFO *info)
+static void add_device(SLMP_INFO *info)
 {
        info->next_device = NULL;
        info->line = synclinkmp_device_count;
@@ -3806,7 +3769,7 @@ void add_device(SLMP_INFO *info)
                info->irq_level,
                info->max_frame_size );
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        hdlcdev_init(info);
 #endif
 }
@@ -3819,16 +3782,15 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev)
 {
        SLMP_INFO *info;
 
-       info = (SLMP_INFO *)kmalloc(sizeof(SLMP_INFO),
+       info = kzalloc(sizeof(SLMP_INFO),
                 GFP_KERNEL);
 
        if (!info) {
                printk("%s(%d) Error can't allocate device instance data for adapter %d, port %d\n",
                        __FILE__,__LINE__, adapter_num, port_num);
        } else {
-               memset(info, 0, sizeof(SLMP_INFO));
                info->magic = MGSL_MAGIC;
-               INIT_WORK(&info->task, bh_handler, info);
+               INIT_WORK(&info->task, bh_handler);
                info->max_frame_size = 4096;
                info->close_delay = 5*HZ/10;
                info->closing_wait = 30*HZ;
@@ -3863,15 +3825,11 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev)
                info->phys_statctrl_base &= ~(PAGE_SIZE-1);
 
                info->bus_type = MGSL_BUS_TYPE_PCI;
-               info->irq_flags = SA_SHIRQ;
+               info->irq_flags = IRQF_SHARED;
 
-               init_timer(&info->tx_timer);
-               info->tx_timer.data = (unsigned long)info;
-               info->tx_timer.function = tx_timeout;
-
-               init_timer(&info->status_timer);
-               info->status_timer.data = (unsigned long)info;
-               info->status_timer.function = status_timeout;
+               setup_timer(&info->tx_timer, tx_timeout, (unsigned long)info);
+               setup_timer(&info->status_timer, status_timeout,
+                               (unsigned long)info);
 
                /* Store the PCI9050 misc control register value because a flaw
                 * in the PCI9050 prevents LCR registers from being read if
@@ -3896,7 +3854,7 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev)
        return info;
 }
 
-void device_init(int adapter_num, struct pci_dev *pdev)
+static void device_init(int adapter_num, struct pci_dev *pdev)
 {
        SLMP_INFO *port_array[SCA_MAX_PORTS];
        int port;
@@ -3945,13 +3903,13 @@ void device_init(int adapter_num, struct pci_dev *pdev)
                                port_array[0]->irq_level );
                }
                else {
-                       port_array[0]->irq_requested = 1;
+                       port_array[0]->irq_requested = true;
                        adapter_test(port_array[0]);
                }
        }
 }
 
-static struct tty_operations ops = {
+static const struct tty_operations ops = {
        .open = open,
        .close = close,
        .write = write,
@@ -4000,7 +3958,7 @@ static void synclinkmp_cleanup(void)
        /* release devices */
        info = synclinkmp_device_list;
        while(info) {
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                hdlcdev_exit(info);
 #endif
                free_dma_bufs(info);
@@ -4055,6 +4013,8 @@ static int __init synclinkmp_init(void)
        serial_driver->init_termios = tty_std_termios;
        serial_driver->init_termios.c_cflag =
                B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       serial_driver->init_termios.c_ispeed = 9600;
+       serial_driver->init_termios.c_ospeed = 9600;
        serial_driver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(serial_driver, &ops);
        if ((rc = tty_register_driver(serial_driver)) < 0) {
@@ -4088,7 +4048,7 @@ module_exit(synclinkmp_exit);
  * The TxCLK and RxCLK signals are generated from the BRG and
  * the TxD is looped back to the RxD internally.
  */
-void enable_loopback(SLMP_INFO *info, int enable)
+static void enable_loopback(SLMP_INFO *info, int enable)
 {
        if (enable) {
                /* MD2 (Mode Register 2)
@@ -4135,7 +4095,7 @@ void enable_loopback(SLMP_INFO *info, int enable)
  *     data_rate       data rate of clock in bits per second
  *                     A data rate of 0 disables the AUX clock.
  */
-void set_rate( SLMP_INFO *info, u32 data_rate )
+static void set_rate( SLMP_INFO *info, u32 data_rate )
 {
                u32 TMCValue;
                unsigned char BRValue;
@@ -4181,7 +4141,7 @@ void set_rate( SLMP_INFO *info, u32 data_rate )
 
 /* Disable receiver
  */
-void rx_stop(SLMP_INFO *info)
+static void rx_stop(SLMP_INFO *info)
 {
        if (debug_level >= DEBUG_LEVEL_ISR)
                printk("%s(%d):%s rx_stop()\n",
@@ -4196,13 +4156,13 @@ void rx_stop(SLMP_INFO *info)
        write_reg(info, RXDMA + DCMD, SWABORT); /* reset/init Rx DMA */
        write_reg(info, RXDMA + DIR, 0);        /* disable Rx DMA interrupts */
 
-       info->rx_enabled = 0;
-       info->rx_overflow = 0;
+       info->rx_enabled = false;
+       info->rx_overflow = false;
 }
 
 /* enable the receiver
  */
-void rx_start(SLMP_INFO *info)
+static void rx_start(SLMP_INFO *info)
 {
        int i;
 
@@ -4252,14 +4212,14 @@ void rx_start(SLMP_INFO *info)
 
        write_reg(info, CMD, RXENABLE);
 
-       info->rx_overflow = FALSE;
-       info->rx_enabled = 1;
+       info->rx_overflow = false;
+       info->rx_enabled = true;
 }
 
 /* Enable the transmitter and send a transmit frame if
  * one is loaded in the DMA buffers.
  */
-void tx_start(SLMP_INFO *info)
+static void tx_start(SLMP_INFO *info)
 {
        if (debug_level >= DEBUG_LEVEL_ISR)
                printk("%s(%d):%s tx_start() tx_count=%d\n",
@@ -4268,7 +4228,7 @@ void tx_start(SLMP_INFO *info)
        if (!info->tx_enabled ) {
                write_reg(info, CMD, TXRESET);
                write_reg(info, CMD, TXENABLE);
-               info->tx_enabled = TRUE;
+               info->tx_enabled = true;
        }
 
        if ( info->tx_count ) {
@@ -4277,7 +4237,7 @@ void tx_start(SLMP_INFO *info)
                /* RTS and set a flag indicating that the driver should */
                /* negate RTS when the transmission completes. */
 
-               info->drop_rts_on_tx_done = 0;
+               info->drop_rts_on_tx_done = false;
 
                if (info->params.mode != MGSL_MODE_ASYNC) {
 
@@ -4286,7 +4246,7 @@ void tx_start(SLMP_INFO *info)
                                if ( !(info->serial_signals & SerialSignal_RTS) ) {
                                        info->serial_signals |= SerialSignal_RTS;
                                        set_signals( info );
-                                       info->drop_rts_on_tx_done = 1;
+                                       info->drop_rts_on_tx_done = true;
                                }
                        }
 
@@ -4313,8 +4273,8 @@ void tx_start(SLMP_INFO *info)
                        write_reg(info, TXDMA + DIR, 0x40);             /* enable Tx DMA interrupts (EOM) */
                        write_reg(info, TXDMA + DSR, 0xf2);             /* clear Tx DMA IRQs, enable Tx DMA */
        
-                       info->tx_timer.expires = jiffies + msecs_to_jiffies(5000);
-                       add_timer(&info->tx_timer);
+                       mod_timer(&info->tx_timer, jiffies +
+                                       msecs_to_jiffies(5000));
                }
                else {
                        tx_load_fifo(info);
@@ -4323,13 +4283,13 @@ void tx_start(SLMP_INFO *info)
                        write_reg(info, IE0, info->ie0_value);
                }
 
-               info->tx_active = 1;
+               info->tx_active = true;
        }
 }
 
 /* stop the transmitter and DMA
  */
-void tx_stop( SLMP_INFO *info )
+static void tx_stop( SLMP_INFO *info )
 {
        if (debug_level >= DEBUG_LEVEL_ISR)
                printk("%s(%d):%s tx_stop()\n",
@@ -4349,14 +4309,14 @@ void tx_stop( SLMP_INFO *info )
        info->ie0_value &= ~TXRDYE;
        write_reg(info, IE0, info->ie0_value);  /* disable tx data interrupts */
 
-       info->tx_enabled = 0;
-       info->tx_active  = 0;
+       info->tx_enabled = false;
+       info->tx_active = false;
 }
 
 /* Fill the transmit FIFO until the FIFO is full or
  * there is no more data to load.
  */
-void tx_load_fifo(SLMP_INFO *info)
+static void tx_load_fifo(SLMP_INFO *info)
 {
        u8 TwoBytes[2];
 
@@ -4405,7 +4365,7 @@ void tx_load_fifo(SLMP_INFO *info)
 
 /* Reset a port to a known state
  */
-void reset_port(SLMP_INFO *info)
+static void reset_port(SLMP_INFO *info)
 {
        if (info->sca_base) {
 
@@ -4429,7 +4389,7 @@ void reset_port(SLMP_INFO *info)
 
 /* Reset all the ports to a known state.
  */
-void reset_adapter(SLMP_INFO *info)
+static void reset_adapter(SLMP_INFO *info)
 {
        int i;
 
@@ -4441,7 +4401,7 @@ void reset_adapter(SLMP_INFO *info)
 
 /* Program port for asynchronous communications.
  */
-void async_mode(SLMP_INFO *info)
+static void async_mode(SLMP_INFO *info)
 {
 
        unsigned char RegValue;
@@ -4489,11 +4449,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,14 +4536,11 @@ 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.
  */
-void hdlc_mode(SLMP_INFO *info)
+static void hdlc_mode(SLMP_INFO *info)
 {
        unsigned char RegValue;
        u32 DpllDivisor;
@@ -4783,7 +4742,7 @@ void hdlc_mode(SLMP_INFO *info)
 
 /* Set the transmit HDLC idle mode
  */
-void tx_set_idle(SLMP_INFO *info)
+static void tx_set_idle(SLMP_INFO *info)
 {
        unsigned char RegValue = 0xff;
 
@@ -4803,7 +4762,7 @@ void tx_set_idle(SLMP_INFO *info)
 
 /* Query the adapter for the state of the V24 status (input) signals.
  */
-void get_signals(SLMP_INFO *info)
+static void get_signals(SLMP_INFO *info)
 {
        u16 status = read_reg(info, SR3);
        u16 gpstatus = read_status_reg(info);
@@ -4832,7 +4791,7 @@ void get_signals(SLMP_INFO *info)
 /* Set the state of DTR and RTS based on contents of
  * serial_signals member of device context.
  */
-void set_signals(SLMP_INFO *info)
+static void set_signals(SLMP_INFO *info)
 {
        unsigned char RegValue;
        u16 EnableBit;
@@ -4861,7 +4820,7 @@ void set_signals(SLMP_INFO *info)
  * and set the current buffer to the first buffer. This effectively
  * makes all buffers free and discards any data in buffers.
  */
-void rx_reset_buffers(SLMP_INFO *info)
+static void rx_reset_buffers(SLMP_INFO *info)
 {
        rx_free_frame_buffers(info, 0, info->rx_buf_count - 1);
 }
@@ -4872,16 +4831,16 @@ void rx_reset_buffers(SLMP_INFO *info)
  * first  index of 1st receive buffer of frame
  * last   index of last receive buffer of frame
  */
-void rx_free_frame_buffers(SLMP_INFO *info, unsigned int first, unsigned int last)
+static void rx_free_frame_buffers(SLMP_INFO *info, unsigned int first, unsigned int last)
 {
-       int done = 0;
+       bool done = false;
 
        while(!done) {
                /* reset current buffer for reuse */
                info->rx_buf_list[first].status = 0xff;
 
                if (first == last) {
-                       done = 1;
+                       done = true;
                        /* set new last rx descriptor address */
                        write_reg16(info, RXDMA + EDA, info->rx_buf_list_ex[first].phys_entry);
                }
@@ -4898,14 +4857,14 @@ void rx_free_frame_buffers(SLMP_INFO *info, unsigned int first, unsigned int las
 /* Return a received frame from the receive DMA buffers.
  * Only frames received without errors are returned.
  *
- * Return Value:       1 if frame returned, otherwise 0
+ * Return Value:       true if frame returned, otherwise false
  */
-int rx_get_frame(SLMP_INFO *info)
+static bool rx_get_frame(SLMP_INFO *info)
 {
        unsigned int StartIndex, EndIndex;      /* index of 1st and last buffers of Rx frame */
        unsigned short status;
        unsigned int framesize = 0;
-       int ReturnCode = 0;
+       bool ReturnCode = false;
        unsigned long flags;
        struct tty_struct *tty = info->tty;
        unsigned char addr_field = 0xff;
@@ -5003,7 +4962,7 @@ CheckAgain:
                        info->icount.rxcrc++;
 
                framesize = 0;
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                {
                        struct net_device_stats *stats = hdlc_stats(info->netdev);
                        stats->rx_errors++;
@@ -5044,7 +5003,7 @@ CheckAgain:
                                        index = 0;
                        }
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
                        if (info->netcount)
                                hdlcdev_rx(info,info->tmp_rx_buf,framesize);
                        else
@@ -5056,7 +5015,7 @@ CheckAgain:
        /* Free the buffers used by this frame. */
        rx_free_frame_buffers( info, StartIndex, EndIndex );
 
-       ReturnCode = 1;
+       ReturnCode = true;
 
 Cleanup:
        if ( info->rx_enabled && info->rx_overflow ) {
@@ -5075,7 +5034,7 @@ Cleanup:
 
 /* load the transmit DMA buffer with data
  */
-void tx_load_dma_buffer(SLMP_INFO *info, const char *buf, unsigned int count)
+static void tx_load_dma_buffer(SLMP_INFO *info, const char *buf, unsigned int count)
 {
        unsigned short copy_count;
        unsigned int i = 0;
@@ -5115,12 +5074,12 @@ void tx_load_dma_buffer(SLMP_INFO *info, const char *buf, unsigned int count)
        info->last_tx_buf = ++i;
 }
 
-int register_test(SLMP_INFO *info)
+static bool 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;
+       bool rc = true;
        unsigned long flags;
 
        spin_lock_irqsave(&info->lock,flags);
@@ -5143,7 +5102,7 @@ int register_test(SLMP_INFO *info)
                          (read_reg(info, SA0) != testval[(i+2)%count]) ||
                          (read_reg(info, SA1) != testval[(i+3)%count]) )
                {
-                       rc = FALSE;
+                       rc = false;
                        break;
                }
        }
@@ -5154,7 +5113,7 @@ int register_test(SLMP_INFO *info)
        return rc;
 }
 
-int irq_test(SLMP_INFO *info)
+static bool irq_test(SLMP_INFO *info)
 {
        unsigned long timeout;
        unsigned long flags;
@@ -5166,7 +5125,7 @@ int irq_test(SLMP_INFO *info)
 
        /* assume failure */
        info->init_error = DiagStatus_IrqFailure;
-       info->irq_occurred = FALSE;
+       info->irq_occurred = false;
 
        /* setup timer0 on SCA0 to interrupt */
 
@@ -5205,7 +5164,7 @@ int irq_test(SLMP_INFO *info)
 
 /* initialize individual SCA device (2 ports)
  */
-static int sca_init(SLMP_INFO *info)
+static bool sca_init(SLMP_INFO *info)
 {
        /* set wait controller to single mem partition (low), no wait states */
        write_reg(info, PABR0, 0);      /* wait controller addr boundary 0 */
@@ -5241,12 +5200,12 @@ static int sca_init(SLMP_INFO *info)
         */
        write_reg(info, ITCR, 0);
 
-       return TRUE;
+       return true;
 }
 
 /* initialize adapter hardware
  */
-int init_adapter(SLMP_INFO *info)
+static bool init_adapter(SLMP_INFO *info)
 {
        int i;
 
@@ -5299,20 +5258,20 @@ int init_adapter(SLMP_INFO *info)
        sca_init(info->port_array[0]);
        sca_init(info->port_array[2]);
 
-       return TRUE;
+       return true;
 }
 
 /* Loopback an HDLC frame to test the hardware
  * interrupt and DMA functions.
  */
-int loopback_test(SLMP_INFO *info)
+static bool loopback_test(SLMP_INFO *info)
 {
 #define TESTFRAMESIZE 20
 
        unsigned long timeout;
        u16 count = TESTFRAMESIZE;
        unsigned char buf[TESTFRAMESIZE];
-       int rc = FALSE;
+       bool rc = false;
        unsigned long flags;
 
        struct tty_struct *oldtty = info->tty;
@@ -5346,16 +5305,16 @@ int loopback_test(SLMP_INFO *info)
                msleep_interruptible(10);
 
                if (rx_get_frame(info)) {
-                       rc = TRUE;
+                       rc = true;
                        break;
                }
        }
 
        /* verify received frame length and contents */
-       if (rc == TRUE &&
-               ( info->tmp_rx_buf_count != count ||
-                 memcmp(buf, info->tmp_rx_buf,count))) {
-               rc = FALSE;
+       if (rc &&
+           ( info->tmp_rx_buf_count != count ||
+             memcmp(buf, info->tmp_rx_buf,count))) {
+               rc = false;
        }
 
        spin_lock_irqsave(&info->lock,flags);
@@ -5370,7 +5329,7 @@ int loopback_test(SLMP_INFO *info)
 
 /* Perform diagnostics on hardware
  */
-int adapter_test( SLMP_INFO *info )
+static int adapter_test( SLMP_INFO *info )
 {
        unsigned long flags;
        if ( debug_level >= DEBUG_LEVEL_INFO )
@@ -5432,11 +5391,11 @@ int adapter_test( SLMP_INFO *info )
 
 /* Test the shared memory on a PCI adapter.
  */
-int memory_test(SLMP_INFO *info)
+static bool 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;
@@ -5446,7 +5405,7 @@ int memory_test(SLMP_INFO *info)
        for ( i = 0 ; i < count ; i++ ) {
                *addr = testval[i];
                if ( *addr != testval[i] )
-                       return FALSE;
+                       return false;
        }
 
        /* Test address lines with incrementing pattern over */
@@ -5461,12 +5420,12 @@ int memory_test(SLMP_INFO *info)
 
        for ( i = 0 ; i < limit ; i++ ) {
                if ( *addr != i * 4 )
-                       return FALSE;
+                       return false;
                addr++;
        }
 
        memset( info->memory_base, 0, SCA_MEM_SIZE );
-       return TRUE;
+       return true;
 }
 
 /* Load data into PCI adapter shared memory.
@@ -5484,7 +5443,7 @@ int memory_test(SLMP_INFO *info)
  * the write transation. This allows any pending DMA request to gain control
  * of the local bus in a timely fasion.
  */
-void load_pci_memory(SLMP_INFO *info, char* dest, const char* src, unsigned short count)
+static void load_pci_memory(SLMP_INFO *info, char* dest, const char* src, unsigned short count)
 {
        /* A load interval of 16 allows for 4 32-bit writes at */
        /* 136ns each for a maximum latency of 542ns on the local bus.*/
@@ -5503,7 +5462,7 @@ void load_pci_memory(SLMP_INFO *info, char* dest, const char* src, unsigned shor
        memcpy(dest, src, count % sca_pci_load_interval);
 }
 
-void trace_block(SLMP_INFO *info,const char* data, int count, int xmit)
+static void trace_block(SLMP_INFO *info,const char* data, int count, int xmit)
 {
        int i;
        int linecount;
@@ -5538,7 +5497,7 @@ void trace_block(SLMP_INFO *info,const char* data, int count, int xmit)
 /* called when HDLC frame times out
  * update stats and do tx completion processing
  */
-void tx_timeout(unsigned long context)
+static void tx_timeout(unsigned long context)
 {
        SLMP_INFO *info = (SLMP_INFO*)context;
        unsigned long flags;
@@ -5550,12 +5509,12 @@ void tx_timeout(unsigned long context)
                info->icount.txtimeout++;
        }
        spin_lock_irqsave(&info->lock,flags);
-       info->tx_active = 0;
+       info->tx_active = false;
        info->tx_count = info->tx_put = info->tx_get = 0;
 
        spin_unlock_irqrestore(&info->lock,flags);
 
-#ifdef CONFIG_HDLC
+#if SYNCLINK_GENERIC_HDLC
        if (info->netcount)
                hdlcdev_tx_done(info);
        else
@@ -5565,7 +5524,7 @@ void tx_timeout(unsigned long context)
 
 /* called to periodically check the DSR/RI modem signal input status
  */
-void status_timeout(unsigned long context)
+static void status_timeout(unsigned long context)
 {
        u16 status = 0;
        SLMP_INFO *info = (SLMP_INFO*)context;
@@ -5597,10 +5556,7 @@ void status_timeout(unsigned long context)
        if (status)
                isr_io_pin(info,status);
 
-       info->status_timer.data = (unsigned long)info;
-       info->status_timer.function = status_timeout;
-       info->status_timer.expires = jiffies + msecs_to_jiffies(10);
-       add_timer(&info->status_timer);
+       mod_timer(&info->status_timer, jiffies + msecs_to_jiffies(10));
 }
 
 
@@ -5619,36 +5575,36 @@ void status_timeout(unsigned long context)
        }
 
 
-unsigned char read_reg(SLMP_INFO * info, unsigned char Addr)
+static unsigned char read_reg(SLMP_INFO * info, unsigned char Addr)
 {
        CALC_REGADDR();
        return *RegAddr;
 }
-void write_reg(SLMP_INFO * info, unsigned char Addr, unsigned char Value)
+static void write_reg(SLMP_INFO * info, unsigned char Addr, unsigned char Value)
 {
        CALC_REGADDR();
        *RegAddr = Value;
 }
 
-u16 read_reg16(SLMP_INFO * info, unsigned char Addr)
+static u16 read_reg16(SLMP_INFO * info, unsigned char Addr)
 {
        CALC_REGADDR();
        return *((u16 *)RegAddr);
 }
 
-void write_reg16(SLMP_INFO * info, unsigned char Addr, u16 Value)
+static void write_reg16(SLMP_INFO * info, unsigned char Addr, u16 Value)
 {
        CALC_REGADDR();
        *((u16 *)RegAddr) = Value;
 }
 
-unsigned char read_status_reg(SLMP_INFO * info)
+static unsigned char read_status_reg(SLMP_INFO * info)
 {
        unsigned char *RegAddr = (unsigned char *)info->statctrl_base;
        return *RegAddr;
 }
 
-void write_control_reg(SLMP_INFO * info)
+static void write_control_reg(SLMP_INFO * info)
 {
        unsigned char *RegAddr = (unsigned char *)info->statctrl_base;
        *RegAddr = info->port_array[0]->ctrlreg_value;