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 / moxa.c
index 0e75a0d..f43c2e0 100644 (file)
 #include <linux/delay.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
-#include <asm/bitops.h>
 #include <asm/uaccess.h>
 
 #define                MOXA_VERSION            "5.1k"
@@ -142,7 +142,7 @@ typedef struct _moxa_board_conf {
 } moxa_board_conf;
 
 static moxa_board_conf moxa_boards[MAX_BOARDS];
-static unsigned long moxaBaseAddr[MAX_BOARDS];
+static void __iomem *moxaBaseAddr[MAX_BOARDS];
 
 struct moxa_str {
        int type;
@@ -201,11 +201,13 @@ static int numports[]     =       {0, 0, 0, 0};
 MODULE_AUTHOR("William Chen");
 MODULE_DESCRIPTION("MOXA Intellio Family Multiport Board Device Driver");
 MODULE_LICENSE("GPL");
-MODULE_PARM(type, "1-4i");
-MODULE_PARM(baseaddr, "1-4i");
-MODULE_PARM(numports, "1-4i");
-MODULE_PARM(ttymajor, "i");
-MODULE_PARM(verbose, "i");
+#ifdef MODULE
+module_param_array(type, int, NULL, 0);
+module_param_array(baseaddr, int, NULL, 0);
+module_param_array(numports, int, NULL, 0);
+#endif
+module_param(ttymajor, int, 0);
+module_param(verbose, bool, 0644);
 
 static struct tty_driver *moxaDriver;
 static struct moxa_str moxaChannels[MAX_PORTS];
@@ -222,7 +224,7 @@ static struct semaphore moxaBuffSem;
 static void do_moxa_softint(void *);
 static int moxa_open(struct tty_struct *, struct file *);
 static void moxa_close(struct tty_struct *, struct file *);
-static int moxa_write(struct tty_struct *, int, const unsigned char *, int);
+static int moxa_write(struct tty_struct *, const unsigned char *, int);
 static int moxa_write_room(struct tty_struct *);
 static void moxa_flush_buffer(struct tty_struct *);
 static int moxa_chars_in_buffer(struct tty_struct *);
@@ -267,7 +269,7 @@ static int MoxaPortDCDChange(int);
 static int MoxaPortDCDON(int);
 static void MoxaPortFlushData(int, int);
 static int MoxaPortWriteData(int, unsigned char *, int);
-static int MoxaPortReadData(int, unsigned char *, int);
+static int MoxaPortReadData(int, struct tty_struct *tty);
 static int MoxaPortTxQueue(int);
 static int MoxaPortRxQueue(int);
 static int MoxaPortTxFree(int);
@@ -299,6 +301,8 @@ static struct tty_operations moxa_ops = {
        .tiocmset = moxa_tiocmset,
 };
 
+static spinlock_t moxa_lock = SPIN_LOCK_UNLOCKED;
+
 #ifdef CONFIG_PCI
 static int moxa_get_PCI_conf(struct pci_dev *p, int board_type, moxa_board_conf * board)
 {
@@ -337,7 +341,7 @@ static int __init moxa_init(void)
 
        init_MUTEX(&moxaBuffSem);
        moxaDriver->owner = THIS_MODULE;
-       moxaDriver->name = "ttya";
+       moxaDriver->name = "ttyMX";
        moxaDriver->devfs_name = "tts/a";
        moxaDriver->major = ttymajor;
        moxaDriver->minor_start = 0;
@@ -446,10 +450,10 @@ static int __init moxa_init(void)
 #ifdef CONFIG_PCI
        {
                struct pci_dev *p = NULL;
-               int n = (sizeof(moxa_pcibrds) / sizeof(moxa_pcibrds[0])) - 1;
+               int n = ARRAY_SIZE(moxa_pcibrds) - 1;
                i = 0;
                while (i < n) {
-                       while ((p = pci_find_device(moxa_pcibrds[i].vendor, moxa_pcibrds[i].device, p))!=NULL)
+                       while ((p = pci_get_device(moxa_pcibrds[i].vendor, moxa_pcibrds[i].device, p))!=NULL)
                        {
                                if (pci_enable_device(p))
                                        continue;
@@ -467,7 +471,7 @@ static int __init moxa_init(void)
        }
 #endif
        for (i = 0; i < numBoards; i++) {
-               moxaBaseAddr[i] = (unsigned long) ioremap((unsigned long) moxa_boards[i].baseAddr, 0x4000);
+               moxaBaseAddr[i] = ioremap((unsigned long) moxa_boards[i].baseAddr, 0x4000);
        }
 
        return (0);
@@ -492,7 +496,6 @@ static void __exit moxa_exit(void)
        put_tty_driver(moxaDriver);
        if (verbose)
                printk("Done\n");
-
 }
 
 module_init(moxa_init);
@@ -618,15 +621,14 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
 
        if (tty->driver->flush_buffer)
                tty->driver->flush_buffer(tty);
-       if (tty->ldisc.flush_buffer)
-               tty->ldisc.flush_buffer(tty);
+       tty_ldisc_flush(tty);
+                       
        tty->closing = 0;
        ch->event = 0;
        ch->tty = NULL;
        if (ch->blocked_open) {
                if (ch->close_delay) {
-                       set_current_state(TASK_INTERRUPTIBLE);
-                       schedule_timeout(ch->close_delay);
+                       msleep_interruptible(jiffies_to_msecs(ch->close_delay));
                }
                wake_up_interruptible(&ch->open_wait);
        }
@@ -634,7 +636,7 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
        wake_up_interruptible(&ch->close_wait);
 }
 
-static int moxa_write(struct tty_struct *tty, int from_user,
+static int moxa_write(struct tty_struct *tty,
                      const unsigned char *buf, int count)
 {
        struct moxa_str *ch;
@@ -645,26 +647,10 @@ static int moxa_write(struct tty_struct *tty, int from_user,
        if (ch == NULL)
                return (0);
        port = ch->port;
-       save_flags(flags);
-       if (from_user) {
-               if (count > PAGE_SIZE)
-                       count = PAGE_SIZE;
-               down(&moxaBuffSem);
-               if (copy_from_user(moxaXmitBuff, buf, count)) {
-                       len = -EFAULT;
-               } else {
-                       cli();
-                       len = MoxaPortWriteData(port, moxaXmitBuff, count);
-                       restore_flags(flags);
-               }
-               up(&moxaBuffSem);
-               if (len < 0)
-                       return len;
-       } else {
-               cli();
-               len = MoxaPortWriteData(port, (unsigned char *) buf, count);
-               restore_flags(flags);
-       }
+
+       spin_lock_irqsave(&moxa_lock, flags);
+       len = MoxaPortWriteData(port, (unsigned char *) buf, count);
+       spin_unlock_irqrestore(&moxa_lock, flags);
 
        /*********************************************
        if ( !(ch->statusflags & LOWWAIT) &&
@@ -693,10 +679,7 @@ static void moxa_flush_buffer(struct tty_struct *tty)
        if (ch == NULL)
                return;
        MoxaPortFlushData(ch->port, 1);
-       if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-           tty->ldisc.write_wakeup)
-               (tty->ldisc.write_wakeup) (tty);
-       wake_up_interruptible(&tty->write_wait);
+       tty_wakeup(tty);
 }
 
 static int moxa_chars_in_buffer(struct tty_struct *tty)
@@ -742,11 +725,10 @@ static void moxa_put_char(struct tty_struct *tty, unsigned char c)
        if (ch == NULL)
                return;
        port = ch->port;
-       save_flags(flags);
-       cli();
+       spin_lock_irqsave(&moxa_lock, flags);
        moxaXmitBuff[0] = c;
        MoxaPortWriteData(port, moxaXmitBuff, 1);
-       restore_flags(flags);
+       spin_unlock_irqrestore(&moxa_lock, flags);
        /************************************************
        if ( !(ch->statusflags & LOWWAIT) && (MoxaPortTxFree(port) <= 100) )
        *************************************************/
@@ -954,10 +936,7 @@ static void moxa_poll(unsigned long ignored)
                                if (MoxaPortTxQueue(ch->port) <= WAKEUP_CHARS) {
                                        if (!tp->stopped) {
                                                ch->statusflags &= ~LOWWAIT;
-                                               if ((tp->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-                                                 tp->ldisc.write_wakeup)
-                                                       (tp->ldisc.write_wakeup) (tp);
-                                               wake_up_interruptible(&tp->write_wait);
+                                               tty_wakeup(tp);
                                        }
                                }
                        }
@@ -1052,12 +1031,12 @@ static int block_till_ready(struct tty_struct *tty, struct file *filp,
        printk("block_til_ready before block: ttys%d, count = %d\n",
               ch->line, ch->count);
 #endif
-       save_flags(flags);
-       cli();
+       spin_lock_irqsave(&moxa_lock, flags);
        if (!tty_hung_up_p(filp))
                ch->count--;
-       restore_flags(flags);
        ch->blocked_open++;
+       spin_unlock_irqrestore(&moxa_lock, flags);
+
        while (1) {
                set_current_state(TASK_INTERRUPTIBLE);
                if (tty_hung_up_p(filp) ||
@@ -1084,17 +1063,21 @@ static int block_till_ready(struct tty_struct *tty, struct file *filp,
        }
        set_current_state(TASK_RUNNING);
        remove_wait_queue(&ch->open_wait, &wait);
+
+       spin_lock_irqsave(&moxa_lock, flags);
        if (!tty_hung_up_p(filp))
                ch->count++;
        ch->blocked_open--;
+       spin_unlock_irqrestore(&moxa_lock, flags);
 #ifdef SERIAL_DEBUG_OPEN
        printk("block_til_ready after blocking: ttys%d, count = %d\n",
               ch->line, ch->count);
 #endif
        if (retval)
                return (retval);
+       /* FIXME: review to see if we need to use set_bit on these */
        ch->asyncflags |= ASYNC_NORMAL_ACTIVE;
-       return (0);
+       return 0;
 }
 
 static void setup_empty_event(struct tty_struct *tty)
@@ -1102,15 +1085,14 @@ static void setup_empty_event(struct tty_struct *tty)
        struct moxa_str *ch = tty->driver_data;
        unsigned long flags;
 
-       save_flags(flags);
-       cli();
+       spin_lock_irqsave(&moxa_lock, flags);
        ch->statusflags |= EMPTYWAIT;
        moxaEmptyTimer_on[ch->port] = 0;
        del_timer(&moxaEmptyTimer[ch->port]);
        moxaEmptyTimer[ch->port].expires = jiffies + HZ;
        moxaEmptyTimer_on[ch->port] = 1;
        add_timer(&moxaEmptyTimer[ch->port]);
-       restore_flags(flags);
+       spin_unlock_irqrestore(&moxa_lock, flags);
 }
 
 static void check_xmit_empty(unsigned long data)
@@ -1123,10 +1105,7 @@ static void check_xmit_empty(unsigned long data)
        if (ch->tty && (ch->statusflags & EMPTYWAIT)) {
                if (MoxaPortTxQueue(ch->port) == 0) {
                        ch->statusflags &= ~EMPTYWAIT;
-                       if ((ch->tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-                           ch->tty->ldisc.write_wakeup)
-                               (ch->tty->ldisc.write_wakeup) (ch->tty);
-                       wake_up_interruptible(&ch->tty->write_wait);
+                       tty_wakeup(ch->tty);
                        return;
                }
                moxaEmptyTimer[ch->port].expires = jiffies + HZ;
@@ -1160,8 +1139,6 @@ static void receive_data(struct moxa_str *ch)
 {
        struct tty_struct *tp;
        struct termios *ts;
-       int i, count, rc, space;
-       unsigned char *charptr, *flagptr;
        unsigned long flags;
 
        ts = NULL;
@@ -1175,24 +1152,10 @@ static void receive_data(struct moxa_str *ch)
                MoxaPortFlushData(ch->port, 0);
                return;
        }
-       space = TTY_FLIPBUF_SIZE - tp->flip.count;
-       if (space <= 0)
-               return;
-       charptr = tp->flip.char_buf_ptr;
-       flagptr = tp->flip.flag_buf_ptr;
-       rc = tp->flip.count;
-       save_flags(flags);
-       cli();
-       count = MoxaPortReadData(ch->port, charptr, space);
-       restore_flags(flags);
-       for (i = 0; i < count; i++)
-               *flagptr++ = 0;
-       charptr += count;
-       rc += count;
-       tp->flip.count = rc;
-       tp->flip.char_buf_ptr = charptr;
-       tp->flip.flag_buf_ptr = flagptr;
-       tty_schedule_flip(ch->tty);
+       spin_lock_irqsave(&moxa_lock, flags);
+       MoxaPortReadData(ch->port, tp);
+       spin_unlock_irqrestore(&moxa_lock, flags);
+       tty_schedule_flip(tp);
 }
 
 #define Magic_code     0x404
@@ -1504,12 +1467,12 @@ typedef struct mon_str mon_st;
 #define        DCD_oldstate    0x80
 
 static unsigned char moxaBuff[10240];
-static unsigned long moxaIntNdx[MAX_BOARDS];
-static unsigned long moxaIntPend[MAX_BOARDS];
-static unsigned long moxaIntTable[MAX_BOARDS];
+static void __iomem *moxaIntNdx[MAX_BOARDS];
+static void __iomem *moxaIntPend[MAX_BOARDS];
+static void __iomem *moxaIntTable[MAX_BOARDS];
 static char moxaChkPort[MAX_PORTS];
 static char moxaLineCtrl[MAX_PORTS];
-static unsigned long moxaTableAddr[MAX_PORTS];
+static void __iomem *moxaTableAddr[MAX_PORTS];
 static long moxaCurBaud[MAX_PORTS];
 static char moxaDCDState[MAX_PORTS];
 static char moxaLowChkFlag[MAX_PORTS];
@@ -1520,15 +1483,15 @@ static int moxaFuncTout;
 static ushort moxaBreakCnt[MAX_PORTS];
 
 static void moxadelay(int);
-static void moxafunc(unsigned long, int, ushort);
-static void wait_finish(unsigned long);
-static void low_water_check(unsigned long);
+static void moxafunc(void __iomem *, int, ushort);
+static void wait_finish(void __iomem *);
+static void low_water_check(void __iomem *);
 static int moxaloadbios(int, unsigned char __user *, int);
 static int moxafindcard(int);
 static int moxaload320b(int, unsigned char __user *, int);
 static int moxaloadcode(int, unsigned char __user *, int);
-static int moxaloadc218(int, unsigned long, int);
-static int moxaloadc320(int, unsigned long, int, int *);
+static int moxaloadc218(int, void __iomem *, int);
+static int moxaloadc320(int, void __iomem *, int, int *);
 
 /*****************************************************************************
  *     Driver level functions:                                              *
@@ -1586,7 +1549,7 @@ static struct dl_str dltmp;
 
 void MoxaPortFlushData(int port, int mode)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
        if ((mode < 0) || (mode > 2))
                return;
        ofsAddr = moxaTableAddr[port];
@@ -1686,6 +1649,8 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
        case MOXA_FIND_BOARD:
        case MOXA_LOAD_C320B:
        case MOXA_LOAD_CODE:
+               if (!capable(CAP_SYS_RAWIO))
+                       return -EPERM;
                break;
        }
 
@@ -1718,7 +1683,8 @@ int MoxaDriverPoll(void)
 {
        register ushort temp;
        register int card;
-       unsigned long ip, ofsAddr;
+       void __iomem *ofsAddr;
+       void __iomem *ip;
        int port, p, ports;
 
        if (moxaCard == 0)
@@ -1798,7 +1764,7 @@ int MoxaPortsOfCard(int cardno)
  *     14. MoxaPortDCDON(int port);                                         *
  *     15. MoxaPortFlushData(int port, int mode);                           *
  *     16. MoxaPortWriteData(int port, unsigned char * buffer, int length); *
- *     17. MoxaPortReadData(int port, unsigned char * buffer, int length);  *
+ *     17. MoxaPortReadData(int port, struct tty_struct *tty);              *
  *     18. MoxaPortTxBufSize(int port);                                     *
  *     19. MoxaPortRxBufSize(int port);                                     *
  *     20. MoxaPortTxQueue(int port);                                       *
@@ -2027,10 +1993,9 @@ int MoxaPortsOfCard(int cardno)
  *
  *      Function 21:    Read data.
  *      Syntax:
- *      int  MoxaPortReadData(int port, unsigned char * buffer, int length);
+ *      int  MoxaPortReadData(int port, struct tty_struct *tty);
  *           int port           : port number (0 - 127)
- *           unsigned char * buffer     : pointer to read data buffer.
- *           int length         : read data buffer length
+ *          struct tty_struct *tty : tty for data
  *
  *           return:    0 - length      : real read data length
  *
@@ -2151,7 +2116,7 @@ int MoxaPortIsValid(int port)
 
 void MoxaPortEnable(int port)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
        int MoxaPortLineStatus(int);
        short lowwater = 512;
 
@@ -2174,9 +2139,8 @@ void MoxaPortEnable(int port)
 
 void MoxaPortDisable(int port)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr = moxaTableAddr[port];
 
-       ofsAddr = moxaTableAddr[port];
        moxafunc(ofsAddr, FC_SetFlowCtl, 0);    /* disable flow control */
        moxafunc(ofsAddr, FC_ClrLineIrq, Magic_code);
        writew(0, ofsAddr + HostStat);
@@ -2195,7 +2159,7 @@ long MoxaPortGetMaxBaud(int port)
 
 long MoxaPortSetBaud(int port, long baud)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
        long max, clock;
        unsigned int val;
 
@@ -2219,7 +2183,7 @@ long MoxaPortSetBaud(int port, long baud)
 
 int MoxaPortSetTermio(int port, struct termios *termio)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
        tcflag_t cflag;
        long baud;
        tcflag_t mode = 0;
@@ -2364,7 +2328,7 @@ int MoxaPortGetLineOut(int port, int *dtrState, int *rtsState)
 
 void MoxaPortLineCtrl(int port, int dtr, int rts)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
        int mode;
 
        ofsAddr = moxaTableAddr[port];
@@ -2379,7 +2343,7 @@ void MoxaPortLineCtrl(int port, int dtr, int rts)
 
 void MoxaPortFlowCtrl(int port, int rts, int cts, int txflow, int rxflow, int txany)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
        int mode;
 
        ofsAddr = moxaTableAddr[port];
@@ -2399,7 +2363,7 @@ void MoxaPortFlowCtrl(int port, int rts, int cts, int txflow, int rxflow, int tx
 
 int MoxaPortLineStatus(int port)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
        int val;
 
        ofsAddr = moxaTableAddr[port];
@@ -2472,7 +2436,7 @@ int MoxaPortWriteData(int port, unsigned char * buffer, int len)
        int cnt;
        ushort head, tx_mask, spage, epage;
        ushort pageno, pageofs, bufhead;
-       unsigned long baseAddr, ofsAddr, ofs;
+       void __iomem *baseAddr, *ofsAddr, *ofs;
 
        ofsAddr = moxaTableAddr[port];
        baseAddr = moxaBaseAddr[port / MAX_PORTS_PER_BOARD];
@@ -2529,13 +2493,13 @@ int MoxaPortWriteData(int port, unsigned char * buffer, int len)
        return (total);
 }
 
-int MoxaPortReadData(int port, unsigned char * buffer, int space)
+int MoxaPortReadData(int port, struct tty_struct *tty)
 {
        register ushort head, pageofs;
        int i, count, cnt, len, total, remain;
        ushort tail, rx_mask, spage, epage;
        ushort pageno, bufhead;
-       unsigned long baseAddr, ofsAddr, ofs;
+       void __iomem *baseAddr, *ofsAddr, *ofs;
 
        ofsAddr = moxaTableAddr[port];
        baseAddr = moxaBaseAddr[port / MAX_PORTS_PER_BOARD];
@@ -2547,9 +2511,9 @@ int MoxaPortReadData(int port, unsigned char * buffer, int space)
        count = (tail >= head) ? (tail - head)
            : (tail - head + rx_mask + 1);
        if (count == 0)
-               return (0);
+               return 0;
 
-       total = (space > count) ? count : space;
+       total = count;
        remain = count - total;
        moxaLog.rxcnt[port] += total;
        count = total;
@@ -2564,7 +2528,7 @@ int MoxaPortReadData(int port, unsigned char * buffer, int space)
                        len = (count > len) ? len : count;
                        ofs = baseAddr + DynPage_addr + bufhead + head;
                        for (i = 0; i < len; i++)
-                               *buffer++ = readb(ofs + i);
+                               tty_insert_flip_char(tty, readb(ofs + i), TTY_NORMAL);
                        head = (head + len) & rx_mask;
                        count -= len;
                }
@@ -2581,7 +2545,7 @@ int MoxaPortReadData(int port, unsigned char * buffer, int space)
                        writew(pageno, baseAddr + Control_reg);
                        ofs = baseAddr + DynPage_addr + pageofs;
                        for (i = 0; i < cnt; i++)
-                               *buffer++ = readb(ofs + i);
+                               tty_insert_flip_char(tty, readb(ofs + i), TTY_NORMAL);
                        if (count == 0) {
                                writew((head + len) & rx_mask, ofsAddr + RXrptr);
                                break;
@@ -2601,7 +2565,7 @@ int MoxaPortReadData(int port, unsigned char * buffer, int space)
 
 int MoxaPortTxQueue(int port)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
        ushort rptr, wptr, mask;
        int len;
 
@@ -2615,7 +2579,7 @@ int MoxaPortTxQueue(int port)
 
 int MoxaPortTxFree(int port)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
        ushort rptr, wptr, mask;
        int len;
 
@@ -2629,7 +2593,7 @@ int MoxaPortTxFree(int port)
 
 int MoxaPortRxQueue(int port)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
        ushort rptr, wptr, mask;
        int len;
 
@@ -2644,7 +2608,7 @@ int MoxaPortRxQueue(int port)
 
 void MoxaPortTxDisable(int port)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
 
        ofsAddr = moxaTableAddr[port];
        moxafunc(ofsAddr, FC_SetXoffState, Magic_code);
@@ -2652,7 +2616,7 @@ void MoxaPortTxDisable(int port)
 
 void MoxaPortTxEnable(int port)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
 
        ofsAddr = moxaTableAddr[port];
        moxafunc(ofsAddr, FC_SetXonState, Magic_code);
@@ -2670,7 +2634,7 @@ int MoxaPortResetBrkCnt(int port)
 
 void MoxaPortSendBreak(int port, int ms100)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
 
        ofsAddr = moxaTableAddr[port];
        if (ms100) {
@@ -2759,7 +2723,7 @@ static void moxadelay(int tick)
        while (time_before(jiffies, et));
 }
 
-static void moxafunc(unsigned long ofsAddr, int cmd, ushort arg)
+static void moxafunc(void __iomem *ofsAddr, int cmd, ushort arg)
 {
 
        writew(arg, ofsAddr + FuncArg);
@@ -2767,7 +2731,7 @@ static void moxafunc(unsigned long ofsAddr, int cmd, ushort arg)
        wait_finish(ofsAddr);
 }
 
-static void wait_finish(unsigned long ofsAddr)
+static void wait_finish(void __iomem *ofsAddr)
 {
        unsigned long i, j;
 
@@ -2780,7 +2744,7 @@ static void wait_finish(unsigned long ofsAddr)
        }
 }
 
-static void low_water_check(unsigned long ofsAddr)
+static void low_water_check(void __iomem *ofsAddr)
 {
        int len;
        ushort rptr, wptr, mask;
@@ -2797,7 +2761,7 @@ static void low_water_check(unsigned long ofsAddr)
 
 static int moxaloadbios(int cardno, unsigned char __user *tmp, int len)
 {
-       unsigned long baseAddr;
+       void __iomem *baseAddr;
        int i;
 
        if(copy_from_user(moxaBuff, tmp, len))
@@ -2815,7 +2779,7 @@ static int moxaloadbios(int cardno, unsigned char __user *tmp, int len)
 
 static int moxafindcard(int cardno)
 {
-       unsigned long baseAddr;
+       void __iomem *baseAddr;
        ushort tmp;
 
        baseAddr = moxaBaseAddr[cardno];
@@ -2844,7 +2808,7 @@ static int moxafindcard(int cardno)
 
 static int moxaload320b(int cardno, unsigned char __user *tmp, int len)
 {
-       unsigned long baseAddr;
+       void __iomem *baseAddr;
        int i;
 
        if(len > sizeof(moxaBuff))
@@ -2864,7 +2828,7 @@ static int moxaload320b(int cardno, unsigned char __user *tmp, int len)
 
 static int moxaloadcode(int cardno, unsigned char __user *tmp, int len)
 {
-       unsigned long baseAddr, ofsAddr;
+       void __iomem *baseAddr, *ofsAddr;
        int retval, port, i;
 
        if(copy_from_user(moxaBuff, tmp, len))
@@ -2944,7 +2908,7 @@ static int moxaloadcode(int cardno, unsigned char __user *tmp, int len)
        return (0);
 }
 
-static int moxaloadc218(int cardno, unsigned long baseAddr, int len)
+static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)
 {
        char retry;
        int i, j, len1, len2;
@@ -3020,7 +2984,7 @@ static int moxaloadc218(int cardno, unsigned long baseAddr, int len)
        return (0);
 }
 
-static int moxaloadc320(int cardno, unsigned long baseAddr, int len, int *numPorts)
+static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPorts)
 {
        ushort usum;
        int i, j, wlen, len2, retry;
@@ -3115,6 +3079,7 @@ static int moxaloadc320(int cardno, unsigned long baseAddr, int len, int *numPor
        return (0);
 }
 
+#if 0
 long MoxaPortGetCurBaud(int port)
 {
 
@@ -3122,10 +3087,11 @@ long MoxaPortGetCurBaud(int port)
                return (0);
        return (moxaCurBaud[port]);
 }
+#endif  /*  0  */
 
 static void MoxaSetFifo(int port, int enable)
 {
-       unsigned long ofsAddr = moxaTableAddr[port];
+       void __iomem *ofsAddr = moxaTableAddr[port];
 
        if (!enable) {
                moxafunc(ofsAddr, FC_SetRxFIFOTrig, 0);
@@ -3139,7 +3105,7 @@ static void MoxaSetFifo(int port, int enable)
 #if 0
 int MoxaPortSetMode(int port, int databits, int stopbits, int parity)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
        int val;
 
        val = 0;
@@ -3198,7 +3164,7 @@ int MoxaPortSetMode(int port, int databits, int stopbits, int parity)
 
 int MoxaPortTxBufSize(int port)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
        int size;
 
        ofsAddr = moxaTableAddr[port];
@@ -3208,7 +3174,7 @@ int MoxaPortTxBufSize(int port)
 
 int MoxaPortRxBufSize(int port)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
        int size;
 
        ofsAddr = moxaTableAddr[port];
@@ -3218,7 +3184,7 @@ int MoxaPortRxBufSize(int port)
 
 int MoxaPortRxFree(int port)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
        ushort rptr, wptr, mask;
        int len;
 
@@ -3236,7 +3202,7 @@ int MoxaPortGetBrkCnt(int port)
 
 void MoxaPortSetXonXoff(int port, int xonValue, int xoffValue)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
 
        ofsAddr = moxaTableAddr[port];
        writew(xonValue, ofsAddr + FuncArg);
@@ -3247,7 +3213,7 @@ void MoxaPortSetXonXoff(int port, int xonValue, int xoffValue)
 
 int MoxaPortIsTxHold(int port)
 {
-       unsigned long ofsAddr;
+       void __iomem *ofsAddr;
        int val;
 
        ofsAddr = moxaTableAddr[port];