Commit b4173f45 authored by Jiri Slaby's avatar Jiri Slaby Committed by Linus Torvalds

Char: moxa, remove port->port

We don't need to hold a reference to port index.  In most cases we need port
structure anyway and index is available in port->tty->index.
Signed-off-by: default avatarJiri Slaby <jirislaby@gmail.com>
Tested-by: default avatarOyvind Aabling <Oyvind.Aabling@uni-c.dk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5292bcd3
...@@ -128,8 +128,8 @@ struct moxaq_str { ...@@ -128,8 +128,8 @@ struct moxaq_str {
}; };
struct moxa_port { struct moxa_port {
struct moxa_board_conf *board;
int type; int type;
int port;
int close_delay; int close_delay;
unsigned short closing_wait; unsigned short closing_wait;
int count; int count;
...@@ -218,34 +218,32 @@ static void moxa_receive_data(struct moxa_port *); ...@@ -218,34 +218,32 @@ static void moxa_receive_data(struct moxa_port *);
/* /*
* moxa board interface functions: * moxa board interface functions:
*/ */
static int MoxaDriverIoctl(unsigned int, unsigned long, int); static int MoxaDriverIoctl(struct tty_struct *, unsigned int, unsigned long);
static int MoxaDriverPoll(void); static int MoxaDriverPoll(void);
static int MoxaPortsOfCard(int); static int MoxaPortsOfCard(int);
static int MoxaPortIsValid(int); static int MoxaPortIsValid(int);
static void MoxaPortEnable(int); static void MoxaPortEnable(struct moxa_port *);
static void MoxaPortDisable(int); static void MoxaPortDisable(struct moxa_port *);
static long MoxaPortGetMaxBaud(int); static int MoxaPortSetTermio(struct moxa_port *, struct ktermios *, speed_t);
static long MoxaPortSetBaud(int, long); static int MoxaPortGetLineOut(struct moxa_port *, int *, int *);
static int MoxaPortSetTermio(int, struct ktermios *, speed_t); static void MoxaPortLineCtrl(struct moxa_port *, int, int);
static int MoxaPortGetLineOut(int, int *, int *); static void MoxaPortFlowCtrl(struct moxa_port *, int, int, int, int, int);
static void MoxaPortLineCtrl(int, int, int); static int MoxaPortLineStatus(struct moxa_port *);
static void MoxaPortFlowCtrl(int, int, int, int, int, int); static int MoxaPortDCDChange(struct moxa_port *);
static int MoxaPortLineStatus(int); static int MoxaPortDCDON(struct moxa_port *);
static int MoxaPortDCDChange(int); static void MoxaPortFlushData(struct moxa_port *, int);
static int MoxaPortDCDON(int); static int MoxaPortWriteData(struct moxa_port *, unsigned char *, int);
static void MoxaPortFlushData(int, int); static int MoxaPortReadData(struct moxa_port *, struct tty_struct *tty);
static int MoxaPortWriteData(int, unsigned char *, int); static int MoxaPortTxQueue(struct moxa_port *);
static int MoxaPortReadData(int, struct tty_struct *tty); static int MoxaPortRxQueue(struct moxa_port *);
static int MoxaPortTxQueue(int); static int MoxaPortTxFree(struct moxa_port *);
static int MoxaPortRxQueue(int); static void MoxaPortTxDisable(struct moxa_port *);
static int MoxaPortTxFree(int); static void MoxaPortTxEnable(struct moxa_port *);
static void MoxaPortTxDisable(int); static int MoxaPortResetBrkCnt(struct moxa_port *);
static void MoxaPortTxEnable(int); static void MoxaPortSendBreak(struct moxa_port *, int);
static int MoxaPortResetBrkCnt(int);
static void MoxaPortSendBreak(int, int);
static int moxa_get_serial_info(struct moxa_port *, struct serial_struct __user *); static int moxa_get_serial_info(struct moxa_port *, struct serial_struct __user *);
static int moxa_set_serial_info(struct moxa_port *, struct serial_struct __user *); static int moxa_set_serial_info(struct moxa_port *, struct serial_struct __user *);
static void MoxaSetFifo(int port, int enable); static void MoxaSetFifo(struct moxa_port *port, int enable);
static const struct tty_operations moxa_ops = { static const struct tty_operations moxa_ops = {
.open = moxa_open, .open = moxa_open,
...@@ -515,6 +513,7 @@ static int moxa_load_code(struct moxa_board_conf *brd, const void *ptr, ...@@ -515,6 +513,7 @@ static int moxa_load_code(struct moxa_board_conf *brd, const void *ptr,
case MOXA_BOARD_CP204J: case MOXA_BOARD_CP204J:
port = brd->ports; port = brd->ports;
for (i = 0; i < brd->numPorts; i++, port++) { for (i = 0; i < brd->numPorts; i++, port++) {
port->board = brd;
port->chkPort = 1; port->chkPort = 1;
port->curBaud = 9600L; port->curBaud = 9600L;
port->DCDState = 0; port->DCDState = 0;
...@@ -534,6 +533,7 @@ static int moxa_load_code(struct moxa_board_conf *brd, const void *ptr, ...@@ -534,6 +533,7 @@ static int moxa_load_code(struct moxa_board_conf *brd, const void *ptr,
default: default:
port = brd->ports; port = brd->ports;
for (i = 0; i < brd->numPorts; i++, port++) { for (i = 0; i < brd->numPorts; i++, port++) {
port->board = brd;
port->chkPort = 1; port->chkPort = 1;
port->curBaud = 9600L; port->curBaud = 9600L;
port->DCDState = 0; port->DCDState = 0;
...@@ -822,7 +822,6 @@ static int __init moxa_init(void) ...@@ -822,7 +822,6 @@ static int __init moxa_init(void)
for (i = 0, ch = moxa_ports; i < MAX_PORTS; i++, ch++) { for (i = 0, ch = moxa_ports; i < MAX_PORTS; i++, ch++) {
ch->type = PORT_16550A; ch->type = PORT_16550A;
ch->port = i;
ch->close_delay = 5 * HZ / 10; ch->close_delay = 5 * HZ / 10;
ch->closing_wait = 30 * HZ; ch->closing_wait = 30 * HZ;
ch->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL; ch->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
...@@ -939,8 +938,8 @@ static int moxa_open(struct tty_struct *tty, struct file *filp) ...@@ -939,8 +938,8 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
if (!(ch->asyncflags & ASYNC_INITIALIZED)) { if (!(ch->asyncflags & ASYNC_INITIALIZED)) {
ch->statusflags = 0; ch->statusflags = 0;
moxa_set_tty_param(tty, tty->termios); moxa_set_tty_param(tty, tty->termios);
MoxaPortLineCtrl(ch->port, 1, 1); MoxaPortLineCtrl(ch, 1, 1);
MoxaPortEnable(ch->port); MoxaPortEnable(ch);
ch->asyncflags |= ASYNC_INITIALIZED; ch->asyncflags |= ASYNC_INITIALIZED;
} }
retval = moxa_block_till_ready(tty, filp, ch); retval = moxa_block_till_ready(tty, filp, ch);
...@@ -948,9 +947,9 @@ static int moxa_open(struct tty_struct *tty, struct file *filp) ...@@ -948,9 +947,9 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
moxa_unthrottle(tty); moxa_unthrottle(tty);
if (ch->type == PORT_16550A) { if (ch->type == PORT_16550A) {
MoxaSetFifo(ch->port, 1); MoxaSetFifo(ch, 1);
} else { } else {
MoxaSetFifo(ch->port, 0); MoxaSetFifo(ch, 0);
} }
return (retval); return (retval);
...@@ -997,10 +996,10 @@ static void moxa_close(struct tty_struct *tty, struct file *filp) ...@@ -997,10 +996,10 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
if (ch->asyncflags & ASYNC_INITIALIZED) { if (ch->asyncflags & ASYNC_INITIALIZED) {
moxa_setup_empty_event(tty); moxa_setup_empty_event(tty);
tty_wait_until_sent(tty, 30 * HZ); /* 30 seconds timeout */ tty_wait_until_sent(tty, 30 * HZ); /* 30 seconds timeout */
del_timer_sync(&moxa_ports[ch->port].emptyTimer); del_timer_sync(&ch->emptyTimer);
} }
moxa_shut_down(ch); moxa_shut_down(ch);
MoxaPortFlushData(port, 2); MoxaPortFlushData(ch, 2);
if (tty->driver->flush_buffer) if (tty->driver->flush_buffer)
tty->driver->flush_buffer(tty); tty->driver->flush_buffer(tty);
...@@ -1022,17 +1021,15 @@ static void moxa_close(struct tty_struct *tty, struct file *filp) ...@@ -1022,17 +1021,15 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
static int moxa_write(struct tty_struct *tty, static int moxa_write(struct tty_struct *tty,
const unsigned char *buf, int count) const unsigned char *buf, int count)
{ {
struct moxa_port *ch; struct moxa_port *ch = tty->driver_data;
int len, port;
unsigned long flags; unsigned long flags;
int len;
ch = (struct moxa_port *) tty->driver_data;
if (ch == NULL) if (ch == NULL)
return (0); return 0;
port = ch->port;
spin_lock_irqsave(&moxa_lock, flags); spin_lock_irqsave(&moxa_lock, flags);
len = MoxaPortWriteData(port, (unsigned char *) buf, count); len = MoxaPortWriteData(ch, (unsigned char *) buf, count);
spin_unlock_irqrestore(&moxa_lock, flags); spin_unlock_irqrestore(&moxa_lock, flags);
/********************************************* /*********************************************
...@@ -1049,26 +1046,26 @@ static int moxa_write_room(struct tty_struct *tty) ...@@ -1049,26 +1046,26 @@ static int moxa_write_room(struct tty_struct *tty)
if (tty->stopped) if (tty->stopped)
return (0); return (0);
ch = (struct moxa_port *) tty->driver_data; ch = tty->driver_data;
if (ch == NULL) if (ch == NULL)
return (0); return (0);
return (MoxaPortTxFree(ch->port)); return MoxaPortTxFree(ch);
} }
static void moxa_flush_buffer(struct tty_struct *tty) static void moxa_flush_buffer(struct tty_struct *tty)
{ {
struct moxa_port *ch = (struct moxa_port *) tty->driver_data; struct moxa_port *ch = tty->driver_data;
if (ch == NULL) if (ch == NULL)
return; return;
MoxaPortFlushData(ch->port, 1); MoxaPortFlushData(ch, 1);
tty_wakeup(tty); tty_wakeup(tty);
} }
static int moxa_chars_in_buffer(struct tty_struct *tty) static int moxa_chars_in_buffer(struct tty_struct *tty)
{ {
struct moxa_port *ch = tty->driver_data;
int chars; int chars;
struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
/* /*
* Sigh...I have to check if driver_data is NULL here, because * Sigh...I have to check if driver_data is NULL here, because
...@@ -1078,7 +1075,7 @@ static int moxa_chars_in_buffer(struct tty_struct *tty) ...@@ -1078,7 +1075,7 @@ static int moxa_chars_in_buffer(struct tty_struct *tty)
*/ */
if (ch == NULL) if (ch == NULL)
return (0); return (0);
chars = MoxaPortTxQueue(ch->port); chars = MoxaPortTxQueue(ch);
if (chars) { if (chars) {
/* /*
* Make it possible to wakeup anything waiting for output * Make it possible to wakeup anything waiting for output
...@@ -1100,16 +1097,13 @@ static void moxa_flush_chars(struct tty_struct *tty) ...@@ -1100,16 +1097,13 @@ static void moxa_flush_chars(struct tty_struct *tty)
static void moxa_put_char(struct tty_struct *tty, unsigned char c) static void moxa_put_char(struct tty_struct *tty, unsigned char c)
{ {
struct moxa_port *ch; struct moxa_port *ch = tty->driver_data;
int port;
unsigned long flags; unsigned long flags;
ch = (struct moxa_port *) tty->driver_data;
if (ch == NULL) if (ch == NULL)
return; return;
port = ch->port;
spin_lock_irqsave(&moxa_lock, flags); spin_lock_irqsave(&moxa_lock, flags);
MoxaPortWriteData(port, &c, 1); MoxaPortWriteData(ch, &c, 1);
spin_unlock_irqrestore(&moxa_lock, flags); spin_unlock_irqrestore(&moxa_lock, flags);
/************************************************ /************************************************
if ( !(ch->statusflags & LOWWAIT) && (MoxaPortTxFree(port) <= 100) ) if ( !(ch->statusflags & LOWWAIT) && (MoxaPortTxFree(port) <= 100) )
...@@ -1119,20 +1113,18 @@ static void moxa_put_char(struct tty_struct *tty, unsigned char c) ...@@ -1119,20 +1113,18 @@ static void moxa_put_char(struct tty_struct *tty, unsigned char c)
static int moxa_tiocmget(struct tty_struct *tty, struct file *file) static int moxa_tiocmget(struct tty_struct *tty, struct file *file)
{ {
struct moxa_port *ch = (struct moxa_port *) tty->driver_data; struct moxa_port *ch = tty->driver_data;
int port;
int flag = 0, dtr, rts; int flag = 0, dtr, rts;
port = tty->index; if ((tty->index != MAX_PORTS) && (!ch))
if ((port != MAX_PORTS) && (!ch))
return (-EINVAL); return (-EINVAL);
MoxaPortGetLineOut(ch->port, &dtr, &rts); MoxaPortGetLineOut(ch, &dtr, &rts);
if (dtr) if (dtr)
flag |= TIOCM_DTR; flag |= TIOCM_DTR;
if (rts) if (rts)
flag |= TIOCM_RTS; flag |= TIOCM_RTS;
dtr = MoxaPortLineStatus(ch->port); dtr = MoxaPortLineStatus(ch);
if (dtr & 1) if (dtr & 1)
flag |= TIOCM_CTS; flag |= TIOCM_CTS;
if (dtr & 2) if (dtr & 2)
...@@ -1145,7 +1137,7 @@ static int moxa_tiocmget(struct tty_struct *tty, struct file *file) ...@@ -1145,7 +1137,7 @@ static int moxa_tiocmget(struct tty_struct *tty, struct file *file)
static int moxa_tiocmset(struct tty_struct *tty, struct file *file, static int moxa_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear) unsigned int set, unsigned int clear)
{ {
struct moxa_port *ch = (struct moxa_port *) tty->driver_data; struct moxa_port *ch = tty->driver_data;
int port; int port;
int dtr, rts; int dtr, rts;
...@@ -1153,7 +1145,7 @@ static int moxa_tiocmset(struct tty_struct *tty, struct file *file, ...@@ -1153,7 +1145,7 @@ static int moxa_tiocmset(struct tty_struct *tty, struct file *file,
if ((port != MAX_PORTS) && (!ch)) if ((port != MAX_PORTS) && (!ch))
return (-EINVAL); return (-EINVAL);
MoxaPortGetLineOut(ch->port, &dtr, &rts); MoxaPortGetLineOut(ch, &dtr, &rts);
if (set & TIOCM_RTS) if (set & TIOCM_RTS)
rts = 1; rts = 1;
if (set & TIOCM_DTR) if (set & TIOCM_DTR)
...@@ -1162,14 +1154,14 @@ static int moxa_tiocmset(struct tty_struct *tty, struct file *file, ...@@ -1162,14 +1154,14 @@ static int moxa_tiocmset(struct tty_struct *tty, struct file *file,
rts = 0; rts = 0;
if (clear & TIOCM_DTR) if (clear & TIOCM_DTR)
dtr = 0; dtr = 0;
MoxaPortLineCtrl(ch->port, dtr, rts); MoxaPortLineCtrl(ch, dtr, rts);
return 0; return 0;
} }
static int moxa_ioctl(struct tty_struct *tty, struct file *file, static int moxa_ioctl(struct tty_struct *tty, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct moxa_port *ch = (struct moxa_port *) tty->driver_data; struct moxa_port *ch = tty->driver_data;
register int port; register int port;
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
int retval; int retval;
...@@ -1186,7 +1178,7 @@ static int moxa_ioctl(struct tty_struct *tty, struct file *file, ...@@ -1186,7 +1178,7 @@ static int moxa_ioctl(struct tty_struct *tty, struct file *file,
moxa_setup_empty_event(tty); moxa_setup_empty_event(tty);
tty_wait_until_sent(tty, 0); tty_wait_until_sent(tty, 0);
if (!arg) if (!arg)
MoxaPortSendBreak(ch->port, 0); MoxaPortSendBreak(ch, 0);
return (0); return (0);
case TCSBRKP: /* support for POSIX tcsendbreak() */ case TCSBRKP: /* support for POSIX tcsendbreak() */
retval = tty_check_change(tty); retval = tty_check_change(tty);
...@@ -1194,7 +1186,7 @@ static int moxa_ioctl(struct tty_struct *tty, struct file *file, ...@@ -1194,7 +1186,7 @@ static int moxa_ioctl(struct tty_struct *tty, struct file *file,
return (retval); return (retval);
moxa_setup_empty_event(tty); moxa_setup_empty_event(tty);
tty_wait_until_sent(tty, 0); tty_wait_until_sent(tty, 0);
MoxaPortSendBreak(ch->port, arg); MoxaPortSendBreak(ch, arg);
return (0); return (0);
case TIOCGSOFTCAR: case TIOCGSOFTCAR:
return put_user(C_CLOCAL(tty) ? 1 : 0, (int __user *)argp); return put_user(C_CLOCAL(tty) ? 1 : 0, (int __user *)argp);
...@@ -1215,7 +1207,7 @@ static int moxa_ioctl(struct tty_struct *tty, struct file *file, ...@@ -1215,7 +1207,7 @@ static int moxa_ioctl(struct tty_struct *tty, struct file *file,
case TIOCSSERIAL: case TIOCSSERIAL:
return moxa_set_serial_info(ch, argp); return moxa_set_serial_info(ch, argp);
default: default:
retval = MoxaDriverIoctl(cmd, arg, port); retval = MoxaDriverIoctl(tty, cmd, arg);
} }
return (retval); return (retval);
} }
...@@ -1253,7 +1245,7 @@ static void moxa_stop(struct tty_struct *tty) ...@@ -1253,7 +1245,7 @@ static void moxa_stop(struct tty_struct *tty)
if (ch == NULL) if (ch == NULL)
return; return;
MoxaPortTxDisable(ch->port); MoxaPortTxDisable(ch);
ch->statusflags |= TXSTOPPED; ch->statusflags |= TXSTOPPED;
} }
...@@ -1268,7 +1260,7 @@ static void moxa_start(struct tty_struct *tty) ...@@ -1268,7 +1260,7 @@ static void moxa_start(struct tty_struct *tty)
if (!(ch->statusflags & TXSTOPPED)) if (!(ch->statusflags & TXSTOPPED))
return; return;
MoxaPortTxEnable(ch->port); MoxaPortTxEnable(ch);
ch->statusflags &= ~TXSTOPPED; ch->statusflags &= ~TXSTOPPED;
} }
...@@ -1306,25 +1298,25 @@ static void moxa_poll(unsigned long ignored) ...@@ -1306,25 +1298,25 @@ static void moxa_poll(unsigned long ignored)
if ((ch->asyncflags & ASYNC_INITIALIZED) == 0) if ((ch->asyncflags & ASYNC_INITIALIZED) == 0)
continue; continue;
if (!(ch->statusflags & THROTTLE) && if (!(ch->statusflags & THROTTLE) &&
(MoxaPortRxQueue(ch->port) > 0)) (MoxaPortRxQueue(ch) > 0))
moxa_receive_data(ch); moxa_receive_data(ch);
if ((tp = ch->tty) == 0) if ((tp = ch->tty) == 0)
continue; continue;
if (ch->statusflags & LOWWAIT) { if (ch->statusflags & LOWWAIT) {
if (MoxaPortTxQueue(ch->port) <= WAKEUP_CHARS) { if (MoxaPortTxQueue(ch) <= WAKEUP_CHARS) {
if (!tp->stopped) { if (!tp->stopped) {
ch->statusflags &= ~LOWWAIT; ch->statusflags &= ~LOWWAIT;
tty_wakeup(tp); tty_wakeup(tp);
} }
} }
} }
if (!I_IGNBRK(tp) && (MoxaPortResetBrkCnt(ch->port) > 0)) { if (!I_IGNBRK(tp) && (MoxaPortResetBrkCnt(ch) > 0)) {
tty_insert_flip_char(tp, 0, TTY_BREAK); tty_insert_flip_char(tp, 0, TTY_BREAK);
tty_schedule_flip(tp); tty_schedule_flip(tp);
} }
if (MoxaPortDCDChange(ch->port)) { if (MoxaPortDCDChange(ch)) {
if (ch->asyncflags & ASYNC_CHECK_CD) { if (ch->asyncflags & ASYNC_CHECK_CD) {
if (MoxaPortDCDON(ch->port)) if (MoxaPortDCDON(ch))
wake_up_interruptible(&ch->open_wait); wake_up_interruptible(&ch->open_wait);
else { else {
tty_hangup(tp); tty_hangup(tp);
...@@ -1365,8 +1357,8 @@ static void moxa_set_tty_param(struct tty_struct *tty, struct ktermios *old_term ...@@ -1365,8 +1357,8 @@ static void moxa_set_tty_param(struct tty_struct *tty, struct ktermios *old_term
/* Clear the features we don't support */ /* Clear the features we don't support */
ts->c_cflag &= ~CMSPAR; ts->c_cflag &= ~CMSPAR;
MoxaPortFlowCtrl(ch->port, rts, cts, txflow, rxflow, xany); MoxaPortFlowCtrl(ch, rts, cts, txflow, rxflow, xany);
baud = MoxaPortSetTermio(ch->port, ts, tty_get_baud_rate(tty)); baud = MoxaPortSetTermio(ch, ts, tty_get_baud_rate(tty));
if (baud == -1) if (baud == -1)
baud = tty_termios_baud_rate(old_termios); baud = tty_termios_baud_rate(old_termios);
/* Not put the baud rate into the termios data */ /* Not put the baud rate into the termios data */
...@@ -1411,7 +1403,7 @@ static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp, ...@@ -1411,7 +1403,7 @@ static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp,
retval = 0; retval = 0;
add_wait_queue(&ch->open_wait, &wait); add_wait_queue(&ch->open_wait, &wait);
pr_debug("block_til_ready before block: ttys%d, count = %d\n", pr_debug("block_til_ready before block: ttys%d, count = %d\n",
ch->port, ch->count); tty->index, ch->count);
spin_lock_irqsave(&moxa_lock, flags); spin_lock_irqsave(&moxa_lock, flags);
if (!tty_hung_up_p(filp)) if (!tty_hung_up_p(filp))
ch->count--; ch->count--;
...@@ -1433,7 +1425,7 @@ static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp, ...@@ -1433,7 +1425,7 @@ static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp,
break; break;
} }
if (!(ch->asyncflags & ASYNC_CLOSING) && (do_clocal || if (!(ch->asyncflags & ASYNC_CLOSING) && (do_clocal ||
MoxaPortDCDON(ch->port))) MoxaPortDCDON(ch)))
break; break;
if (signal_pending(current)) { if (signal_pending(current)) {
...@@ -1451,7 +1443,7 @@ static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp, ...@@ -1451,7 +1443,7 @@ static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp,
ch->blocked_open--; ch->blocked_open--;
spin_unlock_irqrestore(&moxa_lock, flags); spin_unlock_irqrestore(&moxa_lock, flags);
pr_debug("block_til_ready after blocking: ttys%d, count = %d\n", pr_debug("block_til_ready after blocking: ttys%d, count = %d\n",
ch->port, ch->count); tty->index, ch->count);
if (retval) if (retval)
return (retval); return (retval);
/* FIXME: review to see if we need to use set_bit on these */ /* FIXME: review to see if we need to use set_bit on these */
...@@ -1466,7 +1458,7 @@ static void moxa_setup_empty_event(struct tty_struct *tty) ...@@ -1466,7 +1458,7 @@ static void moxa_setup_empty_event(struct tty_struct *tty)
spin_lock_irqsave(&moxa_lock, flags); spin_lock_irqsave(&moxa_lock, flags);
ch->statusflags |= EMPTYWAIT; ch->statusflags |= EMPTYWAIT;
mod_timer(&moxa_ports[ch->port].emptyTimer, jiffies + HZ); mod_timer(&ch->emptyTimer, jiffies + HZ);
spin_unlock_irqrestore(&moxa_lock, flags); spin_unlock_irqrestore(&moxa_lock, flags);
} }
...@@ -1476,13 +1468,12 @@ static void moxa_check_xmit_empty(unsigned long data) ...@@ -1476,13 +1468,12 @@ static void moxa_check_xmit_empty(unsigned long data)
ch = (struct moxa_port *) data; ch = (struct moxa_port *) data;
if (ch->tty && (ch->statusflags & EMPTYWAIT)) { if (ch->tty && (ch->statusflags & EMPTYWAIT)) {
if (MoxaPortTxQueue(ch->port) == 0) { if (MoxaPortTxQueue(ch) == 0) {
ch->statusflags &= ~EMPTYWAIT; ch->statusflags &= ~EMPTYWAIT;
tty_wakeup(ch->tty); tty_wakeup(ch->tty);
return; return;
} }
mod_timer(&moxa_ports[ch->port].emptyTimer, mod_timer(&ch->emptyTimer, round_jiffies(jiffies + HZ));
round_jiffies(jiffies + HZ));
} else } else
ch->statusflags &= ~EMPTYWAIT; ch->statusflags &= ~EMPTYWAIT;
} }
...@@ -1496,13 +1487,13 @@ static void moxa_shut_down(struct moxa_port *ch) ...@@ -1496,13 +1487,13 @@ static void moxa_shut_down(struct moxa_port *ch)
tp = ch->tty; tp = ch->tty;
MoxaPortDisable(ch->port); MoxaPortDisable(ch);
/* /*
* If we're a modem control device and HUPCL is on, drop RTS & DTR. * If we're a modem control device and HUPCL is on, drop RTS & DTR.
*/ */
if (tp->termios->c_cflag & HUPCL) if (tp->termios->c_cflag & HUPCL)
MoxaPortLineCtrl(ch->port, 0, 0); MoxaPortLineCtrl(ch, 0, 0);
ch->asyncflags &= ~ASYNC_INITIALIZED; ch->asyncflags &= ~ASYNC_INITIALIZED;
} }
...@@ -1521,11 +1512,11 @@ static void moxa_receive_data(struct moxa_port *ch) ...@@ -1521,11 +1512,11 @@ static void moxa_receive_data(struct moxa_port *ch)
if ( !tp || !ts || !(ts->c_cflag & CREAD) ) { if ( !tp || !ts || !(ts->c_cflag & CREAD) ) {
*****************************************************/ *****************************************************/
if (!tp || !ts) { if (!tp || !ts) {
MoxaPortFlushData(ch->port, 0); MoxaPortFlushData(ch, 0);
return; return;
} }
spin_lock_irqsave(&moxa_lock, flags); spin_lock_irqsave(&moxa_lock, flags);
MoxaPortReadData(ch->port, tp); MoxaPortReadData(ch, tp);
spin_unlock_irqrestore(&moxa_lock, flags); spin_unlock_irqrestore(&moxa_lock, flags);
tty_schedule_flip(tp); tty_schedule_flip(tp);
} }
...@@ -1567,27 +1558,28 @@ static void moxa_low_water_check(void __iomem *); ...@@ -1567,27 +1558,28 @@ static void moxa_low_water_check(void __iomem *);
#define MOXA_GET_CUMAJOR (MOXA + 64) #define MOXA_GET_CUMAJOR (MOXA + 64)
#define MOXA_GETMSTATUS (MOXA + 65) #define MOXA_GETMSTATUS (MOXA + 65)
void MoxaPortFlushData(int port, int mode) static void MoxaPortFlushData(struct moxa_port *port, int mode)
{ {
void __iomem *ofsAddr; void __iomem *ofsAddr;
if ((mode < 0) || (mode > 2)) if ((mode < 0) || (mode > 2))
return; return;
ofsAddr = moxa_ports[port].tableAddr; ofsAddr = port->tableAddr;
moxafunc(ofsAddr, FC_FlushQueue, mode); moxafunc(ofsAddr, FC_FlushQueue, mode);
if (mode != 1) { if (mode != 1) {
moxa_ports[port].lowChkFlag = 0; port->lowChkFlag = 0;
moxa_low_water_check(ofsAddr); moxa_low_water_check(ofsAddr);
} }
} }
int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port) static int MoxaDriverIoctl(struct tty_struct *tty, unsigned int cmd,
unsigned long arg)
{ {
struct moxa_port *port = tty->driver_data;
int i; int i;
int status; int status;
int MoxaPortTxQueue(int), MoxaPortRxQueue(int);
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
if (port == MAX_PORTS) { if (tty->index == MAX_PORTS) {
if ((cmd != MOXA_GET_CONF) && (cmd != MOXA_GETDATACOUNT) && if ((cmd != MOXA_GET_CONF) && (cmd != MOXA_GETDATACOUNT) &&
(cmd != MOXA_GET_IOQUEUE) && (cmd != MOXA_GET_MAJOR) && (cmd != MOXA_GET_IOQUEUE) && (cmd != MOXA_GET_MAJOR) &&
(cmd != MOXA_GET_CUMAJOR) && (cmd != MOXA_GETMSTATUS)) (cmd != MOXA_GET_CUMAJOR) && (cmd != MOXA_GETMSTATUS))
...@@ -1609,8 +1601,8 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port) ...@@ -1609,8 +1601,8 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
for (i = 0; i < MAX_PORTS; i++, argm++) { for (i = 0; i < MAX_PORTS; i++, argm++) {
memset(&tmp, 0, sizeof(tmp)); memset(&tmp, 0, sizeof(tmp));
if (moxa_ports[i].chkPort) { if (moxa_ports[i].chkPort) {
tmp.inq = MoxaPortRxQueue(i); tmp.inq = MoxaPortRxQueue(&moxa_ports[i]);
tmp.outq = MoxaPortTxQueue(i); tmp.outq = MoxaPortTxQueue(&moxa_ports[i]);
} }
if (copy_to_user(argm, &tmp, sizeof(tmp))) if (copy_to_user(argm, &tmp, sizeof(tmp)))
return -EFAULT; return -EFAULT;
...@@ -1642,7 +1634,7 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port) ...@@ -1642,7 +1634,7 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
if (!p->chkPort) { if (!p->chkPort) {
goto copy; goto copy;
} else { } else {
status = MoxaPortLineStatus(p->port); status = MoxaPortLineStatus(p);
if (status & 1) if (status & 1)
tmp.cts = 1; tmp.cts = 1;
if (status & 2) if (status & 2)
...@@ -2016,7 +2008,7 @@ int MoxaPortsOfCard(int cardno) ...@@ -2016,7 +2008,7 @@ int MoxaPortsOfCard(int cardno)
* send out a about 250 ms BREAK signal. * send out a about 250 ms BREAK signal.
* *
*/ */
int MoxaPortIsValid(int port) static int MoxaPortIsValid(int port)
{ {
if (moxaCard == 0) if (moxaCard == 0)
return (0); return (0);
...@@ -2025,17 +2017,16 @@ int MoxaPortIsValid(int port) ...@@ -2025,17 +2017,16 @@ int MoxaPortIsValid(int port)
return (1); return (1);
} }
void MoxaPortEnable(int port) static void MoxaPortEnable(struct moxa_port *port)
{ {
void __iomem *ofsAddr; void __iomem *ofsAddr;
int MoxaPortLineStatus(int);
short lowwater = 512; short lowwater = 512;
ofsAddr = moxa_ports[port].tableAddr; ofsAddr = port->tableAddr;
writew(lowwater, ofsAddr + Low_water); writew(lowwater, ofsAddr + Low_water);
moxa_ports[port].breakCnt = 0; port->breakCnt = 0;
if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) || if (port->board->boardType == MOXA_BOARD_C320_ISA ||
(moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) { port->board->boardType == MOXA_BOARD_C320_PCI) {
moxafunc(ofsAddr, FC_SetBreakIrq, 0); moxafunc(ofsAddr, FC_SetBreakIrq, 0);
} else { } else {
writew(readw(ofsAddr + HostStat) | WakeupBreak, ofsAddr + HostStat); writew(readw(ofsAddr + HostStat) | WakeupBreak, ofsAddr + HostStat);
...@@ -2048,9 +2039,9 @@ void MoxaPortEnable(int port) ...@@ -2048,9 +2039,9 @@ void MoxaPortEnable(int port)
MoxaPortLineStatus(port); MoxaPortLineStatus(port);
} }
void MoxaPortDisable(int port) static void MoxaPortDisable(struct moxa_port *port)
{ {
void __iomem *ofsAddr = moxa_ports[port].tableAddr; void __iomem *ofsAddr = port->tableAddr;
moxafunc(ofsAddr, FC_SetFlowCtl, 0); /* disable flow control */ moxafunc(ofsAddr, FC_SetFlowCtl, 0); /* disable flow control */
moxafunc(ofsAddr, FC_ClrLineIrq, Magic_code); moxafunc(ofsAddr, FC_ClrLineIrq, Magic_code);
...@@ -2058,17 +2049,17 @@ void MoxaPortDisable(int port) ...@@ -2058,17 +2049,17 @@ void MoxaPortDisable(int port)
moxafunc(ofsAddr, FC_DisableCH, Magic_code); moxafunc(ofsAddr, FC_DisableCH, Magic_code);
} }
long MoxaPortGetMaxBaud(int port) static long MoxaPortGetMaxBaud(struct moxa_port *port)
{ {
if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) || if (port->board->boardType == MOXA_BOARD_C320_ISA ||
(moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) port->board->boardType == MOXA_BOARD_C320_PCI)
return (460800L); return (460800L);
else else
return (921600L); return (921600L);
} }
long MoxaPortSetBaud(int port, long baud) static long MoxaPortSetBaud(struct moxa_port *port, long baud)
{ {
void __iomem *ofsAddr; void __iomem *ofsAddr;
long max, clock; long max, clock;
...@@ -2076,7 +2067,7 @@ long MoxaPortSetBaud(int port, long baud) ...@@ -2076,7 +2067,7 @@ long MoxaPortSetBaud(int port, long baud)
if ((baud < 50L) || ((max = MoxaPortGetMaxBaud(port)) == 0)) if ((baud < 50L) || ((max = MoxaPortGetMaxBaud(port)) == 0))
return (0); return (0);
ofsAddr = moxa_ports[port].tableAddr; ofsAddr = port->tableAddr;
if (baud > max) if (baud > max)
baud = max; baud = max;
if (max == 38400L) if (max == 38400L)
...@@ -2088,19 +2079,20 @@ long MoxaPortSetBaud(int port, long baud) ...@@ -2088,19 +2079,20 @@ long MoxaPortSetBaud(int port, long baud)
val = clock / baud; val = clock / baud;
moxafunc(ofsAddr, FC_SetBaud, val); moxafunc(ofsAddr, FC_SetBaud, val);
baud = clock / val; baud = clock / val;
moxa_ports[port].curBaud = baud; port->curBaud = baud;
return (baud); return (baud);
} }
int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud) static int MoxaPortSetTermio(struct moxa_port *port, struct ktermios *termio,
speed_t baud)
{ {
void __iomem *ofsAddr; void __iomem *ofsAddr;
tcflag_t cflag; tcflag_t cflag;
tcflag_t mode = 0; tcflag_t mode = 0;
if (moxa_ports[port].chkPort == 0 || termio == 0) if (port->chkPort == 0 || termio == 0)
return (-1); return (-1);
ofsAddr = moxa_ports[port].tableAddr; ofsAddr = port->tableAddr;
cflag = termio->c_cflag; /* termio->c_cflag */ cflag = termio->c_cflag; /* termio->c_cflag */
mode = termio->c_cflag & CSIZE; mode = termio->c_cflag & CSIZE;
...@@ -2131,8 +2123,8 @@ int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud) ...@@ -2131,8 +2123,8 @@ int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud)
moxafunc(ofsAddr, FC_SetDataMode, (ushort) mode); moxafunc(ofsAddr, FC_SetDataMode, (ushort) mode);
if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) || if (port->board->boardType == MOXA_BOARD_C320_ISA ||
(moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) { port->board->boardType == MOXA_BOARD_C320_PCI) {
if (baud >= 921600L) if (baud >= 921600L)
return (-1); return (-1);
} }
...@@ -2148,48 +2140,37 @@ int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud) ...@@ -2148,48 +2140,37 @@ int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud)
return (baud); return (baud);
} }
int MoxaPortGetLineOut(int port, int *dtrState, int *rtsState) static int MoxaPortGetLineOut(struct moxa_port *port, int *dtrState,
int *rtsState)
{ {
if (!MoxaPortIsValid(port)) if (!MoxaPortIsValid(port->tty->index))
return (-1); return (-1);
if (dtrState) { if (dtrState)
if (moxa_ports[port].lineCtrl & DTR_ON) *dtrState = !!(port->lineCtrl & DTR_ON);
*dtrState = 1; if (rtsState)
else *rtsState = !!(port->lineCtrl & RTS_ON);
*dtrState = 0;
}
if (rtsState) {
if (moxa_ports[port].lineCtrl & RTS_ON)
*rtsState = 1;
else
*rtsState = 0;
}
return (0); return (0);
} }
void MoxaPortLineCtrl(int port, int dtr, int rts) static void MoxaPortLineCtrl(struct moxa_port *port, int dtr, int rts)
{ {
void __iomem *ofsAddr; int mode = 0;
int mode;
ofsAddr = moxa_ports[port].tableAddr;
mode = 0;
if (dtr) if (dtr)
mode |= DTR_ON; mode |= DTR_ON;
if (rts) if (rts)
mode |= RTS_ON; mode |= RTS_ON;
moxa_ports[port].lineCtrl = mode; port->lineCtrl = mode;
moxafunc(ofsAddr, FC_LineControl, mode); moxafunc(port->tableAddr, FC_LineControl, mode);
} }
void MoxaPortFlowCtrl(int port, int rts, int cts, int txflow, int rxflow, int txany) static void MoxaPortFlowCtrl(struct moxa_port *port, int rts, int cts,
int txflow, int rxflow, int txany)
{ {
void __iomem *ofsAddr; int mode = 0;
int mode;
ofsAddr = moxa_ports[port].tableAddr;
mode = 0;
if (rts) if (rts)
mode |= RTS_FlowCtl; mode |= RTS_FlowCtl;
if (cts) if (cts)
...@@ -2200,17 +2181,17 @@ void MoxaPortFlowCtrl(int port, int rts, int cts, int txflow, int rxflow, int tx ...@@ -2200,17 +2181,17 @@ void MoxaPortFlowCtrl(int port, int rts, int cts, int txflow, int rxflow, int tx
mode |= Rx_FlowCtl; mode |= Rx_FlowCtl;
if (txany) if (txany)
mode |= IXM_IXANY; mode |= IXM_IXANY;
moxafunc(ofsAddr, FC_SetFlowCtl, mode); moxafunc(port->tableAddr, FC_SetFlowCtl, mode);
} }
int MoxaPortLineStatus(int port) static int MoxaPortLineStatus(struct moxa_port *port)
{ {
void __iomem *ofsAddr; void __iomem *ofsAddr;
int val; int val;
ofsAddr = moxa_ports[port].tableAddr; ofsAddr = port->tableAddr;
if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) || if (port->board->boardType == MOXA_BOARD_C320_ISA ||
(moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) { port->board->boardType == MOXA_BOARD_C320_PCI) {
moxafunc(ofsAddr, FC_LineStatus, 0); moxafunc(ofsAddr, FC_LineStatus, 0);
val = readw(ofsAddr + FuncArg); val = readw(ofsAddr + FuncArg);
} else { } else {
...@@ -2219,42 +2200,43 @@ int MoxaPortLineStatus(int port) ...@@ -2219,42 +2200,43 @@ int MoxaPortLineStatus(int port)
val &= 0x0B; val &= 0x0B;
if (val & 8) { if (val & 8) {
val |= 4; val |= 4;
if ((moxa_ports[port].DCDState & DCD_oldstate) == 0) if ((port->DCDState & DCD_oldstate) == 0)
moxa_ports[port].DCDState = (DCD_oldstate | DCD_changed); port->DCDState = (DCD_oldstate | DCD_changed);
} else { } else {
if (moxa_ports[port].DCDState & DCD_oldstate) if (port->DCDState & DCD_oldstate)
moxa_ports[port].DCDState = DCD_changed; port->DCDState = DCD_changed;
} }
val &= 7; val &= 7;
return (val); return (val);
} }
int MoxaPortDCDChange(int port) static int MoxaPortDCDChange(struct moxa_port *port)
{ {
int n; int n;
if (moxa_ports[port].chkPort == 0) if (port->chkPort == 0)
return (0); return (0);
n = moxa_ports[port].DCDState; n = port->DCDState;
moxa_ports[port].DCDState &= ~DCD_changed; port->DCDState &= ~DCD_changed;
n &= DCD_changed; n &= DCD_changed;
return (n); return (n);
} }
int MoxaPortDCDON(int port) static int MoxaPortDCDON(struct moxa_port *port)
{ {
int n; int n;
if (moxa_ports[port].chkPort == 0) if (port->chkPort == 0)
return (0); return (0);
if (moxa_ports[port].DCDState & DCD_oldstate) if (port->DCDState & DCD_oldstate)
n = 1; n = 1;
else else
n = 0; n = 0;
return (n); return (n);
} }
int MoxaPortWriteData(int port, unsigned char * buffer, int len) static int MoxaPortWriteData(struct moxa_port *port, unsigned char *buffer,
int len)
{ {
int c, total, i; int c, total, i;
ushort tail; ushort tail;
...@@ -2263,8 +2245,8 @@ int MoxaPortWriteData(int port, unsigned char * buffer, int len) ...@@ -2263,8 +2245,8 @@ int MoxaPortWriteData(int port, unsigned char * buffer, int len)
ushort pageno, pageofs, bufhead; ushort pageno, pageofs, bufhead;
void __iomem *baseAddr, *ofsAddr, *ofs; void __iomem *baseAddr, *ofsAddr, *ofs;
ofsAddr = moxa_ports[port].tableAddr; ofsAddr = port->tableAddr;
baseAddr = moxa_boards[port / MAX_PORTS_PER_BOARD].basemem; baseAddr = port->board->basemem;
tx_mask = readw(ofsAddr + TX_mask); tx_mask = readw(ofsAddr + TX_mask);
spage = readw(ofsAddr + Page_txb); spage = readw(ofsAddr + Page_txb);
epage = readw(ofsAddr + EndPage_txb); epage = readw(ofsAddr + EndPage_txb);
...@@ -2274,7 +2256,7 @@ int MoxaPortWriteData(int port, unsigned char * buffer, int len) ...@@ -2274,7 +2256,7 @@ int MoxaPortWriteData(int port, unsigned char * buffer, int len)
: (head - tail + tx_mask); : (head - tail + tx_mask);
if (c > len) if (c > len)
c = len; c = len;
moxaLog.txcnt[port] += c; moxaLog.txcnt[port->tty->index] += c;
total = c; total = c;
if (spage == epage) { if (spage == epage) {
bufhead = readw(ofsAddr + Ofs_txb); bufhead = readw(ofsAddr + Ofs_txb);
...@@ -2318,7 +2300,7 @@ int MoxaPortWriteData(int port, unsigned char * buffer, int len) ...@@ -2318,7 +2300,7 @@ int MoxaPortWriteData(int port, unsigned char * buffer, int len)
return (total); return (total);
} }
int MoxaPortReadData(int port, struct tty_struct *tty) static int MoxaPortReadData(struct moxa_port *port, struct tty_struct *tty)
{ {
register ushort head, pageofs; register ushort head, pageofs;
int i, count, cnt, len, total, remain; int i, count, cnt, len, total, remain;
...@@ -2326,8 +2308,8 @@ int MoxaPortReadData(int port, struct tty_struct *tty) ...@@ -2326,8 +2308,8 @@ int MoxaPortReadData(int port, struct tty_struct *tty)
ushort pageno, bufhead; ushort pageno, bufhead;
void __iomem *baseAddr, *ofsAddr, *ofs; void __iomem *baseAddr, *ofsAddr, *ofs;
ofsAddr = moxa_ports[port].tableAddr; ofsAddr = port->tableAddr;
baseAddr = moxa_boards[port / MAX_PORTS_PER_BOARD].basemem; baseAddr = port->board->basemem;
head = readw(ofsAddr + RXrptr); head = readw(ofsAddr + RXrptr);
tail = readw(ofsAddr + RXwptr); tail = readw(ofsAddr + RXwptr);
rx_mask = readw(ofsAddr + RX_mask); rx_mask = readw(ofsAddr + RX_mask);
...@@ -2340,7 +2322,7 @@ int MoxaPortReadData(int port, struct tty_struct *tty) ...@@ -2340,7 +2322,7 @@ int MoxaPortReadData(int port, struct tty_struct *tty)
total = count; total = count;
remain = count - total; remain = count - total;
moxaLog.rxcnt[port] += total; moxaLog.rxcnt[port->tty->index] += total;
count = total; count = total;
if (spage == epage) { if (spage == epage) {
bufhead = readw(ofsAddr + Ofs_rxb); bufhead = readw(ofsAddr + Ofs_rxb);
...@@ -2382,19 +2364,18 @@ int MoxaPortReadData(int port, struct tty_struct *tty) ...@@ -2382,19 +2364,18 @@ int MoxaPortReadData(int port, struct tty_struct *tty)
} }
if ((readb(ofsAddr + FlagStat) & Xoff_state) && (remain < LowWater)) { if ((readb(ofsAddr + FlagStat) & Xoff_state) && (remain < LowWater)) {
moxaLowWaterChk = 1; moxaLowWaterChk = 1;
moxa_ports[port].lowChkFlag = 1; port->lowChkFlag = 1;
} }
return (total); return (total);
} }
int MoxaPortTxQueue(int port) static int MoxaPortTxQueue(struct moxa_port *port)
{ {
void __iomem *ofsAddr; void __iomem *ofsAddr = port->tableAddr;
ushort rptr, wptr, mask; ushort rptr, wptr, mask;
int len; int len;
ofsAddr = moxa_ports[port].tableAddr;
rptr = readw(ofsAddr + TXrptr); rptr = readw(ofsAddr + TXrptr);
wptr = readw(ofsAddr + TXwptr); wptr = readw(ofsAddr + TXwptr);
mask = readw(ofsAddr + TX_mask); mask = readw(ofsAddr + TX_mask);
...@@ -2402,13 +2383,12 @@ int MoxaPortTxQueue(int port) ...@@ -2402,13 +2383,12 @@ int MoxaPortTxQueue(int port)
return (len); return (len);
} }
int MoxaPortTxFree(int port) static int MoxaPortTxFree(struct moxa_port *port)
{ {
void __iomem *ofsAddr; void __iomem *ofsAddr = port->tableAddr;
ushort rptr, wptr, mask; ushort rptr, wptr, mask;
int len; int len;
ofsAddr = moxa_ports[port].tableAddr;
rptr = readw(ofsAddr + TXrptr); rptr = readw(ofsAddr + TXrptr);
wptr = readw(ofsAddr + TXwptr); wptr = readw(ofsAddr + TXwptr);
mask = readw(ofsAddr + TX_mask); mask = readw(ofsAddr + TX_mask);
...@@ -2416,13 +2396,12 @@ int MoxaPortTxFree(int port) ...@@ -2416,13 +2396,12 @@ int MoxaPortTxFree(int port)
return (len); return (len);
} }
int MoxaPortRxQueue(int port) static int MoxaPortRxQueue(struct moxa_port *port)
{ {
void __iomem *ofsAddr; void __iomem *ofsAddr = port->tableAddr;
ushort rptr, wptr, mask; ushort rptr, wptr, mask;
int len; int len;
ofsAddr = moxa_ports[port].tableAddr;
rptr = readw(ofsAddr + RXrptr); rptr = readw(ofsAddr + RXrptr);
wptr = readw(ofsAddr + RXwptr); wptr = readw(ofsAddr + RXwptr);
mask = readw(ofsAddr + RX_mask); mask = readw(ofsAddr + RX_mask);
...@@ -2431,37 +2410,30 @@ int MoxaPortRxQueue(int port) ...@@ -2431,37 +2410,30 @@ int MoxaPortRxQueue(int port)
} }
void MoxaPortTxDisable(int port) static void MoxaPortTxDisable(struct moxa_port *port)
{ {
void __iomem *ofsAddr; moxafunc(port->tableAddr, FC_SetXoffState, Magic_code);
ofsAddr = moxa_ports[port].tableAddr;
moxafunc(ofsAddr, FC_SetXoffState, Magic_code);
} }
void MoxaPortTxEnable(int port) static void MoxaPortTxEnable(struct moxa_port *port)
{ {
void __iomem *ofsAddr; moxafunc(port->tableAddr, FC_SetXonState, Magic_code);
ofsAddr = moxa_ports[port].tableAddr;
moxafunc(ofsAddr, FC_SetXonState, Magic_code);
} }
int MoxaPortResetBrkCnt(int port) static int MoxaPortResetBrkCnt(struct moxa_port *port)
{ {
ushort cnt; ushort cnt;
cnt = moxa_ports[port].breakCnt; cnt = port->breakCnt;
moxa_ports[port].breakCnt = 0; port->breakCnt = 0;
return (cnt); return (cnt);
} }
void MoxaPortSendBreak(int port, int ms100) static void MoxaPortSendBreak(struct moxa_port *port, int ms100)
{ {
void __iomem *ofsAddr; void __iomem *ofsAddr = port->tableAddr;
ofsAddr = moxa_ports[port].tableAddr;
if (ms100) { if (ms100) {
moxafunc(ofsAddr, FC_SendBreak, Magic_code); moxafunc(ofsAddr, FC_SendBreak, Magic_code);
msleep(ms100 * 10); msleep(ms100 * 10);
...@@ -2479,7 +2451,7 @@ static int moxa_get_serial_info(struct moxa_port *info, ...@@ -2479,7 +2451,7 @@ static int moxa_get_serial_info(struct moxa_port *info,
memset(&tmp, 0, sizeof(tmp)); memset(&tmp, 0, sizeof(tmp));
tmp.type = info->type; tmp.type = info->type;
tmp.line = info->port; tmp.line = info->tty->index;
tmp.port = 0; tmp.port = 0;
tmp.irq = 0; tmp.irq = 0;
tmp.flags = info->asyncflags; tmp.flags = info->asyncflags;
...@@ -2522,9 +2494,9 @@ static int moxa_set_serial_info(struct moxa_port *info, ...@@ -2522,9 +2494,9 @@ static int moxa_set_serial_info(struct moxa_port *info,
new_serial.flags |= (info->asyncflags & ASYNC_FLAGS); new_serial.flags |= (info->asyncflags & ASYNC_FLAGS);
if (new_serial.type == PORT_16550A) { if (new_serial.type == PORT_16550A) {
MoxaSetFifo(info->port, 1); MoxaSetFifo(info, 1);
} else { } else {
MoxaSetFifo(info->port, 0); MoxaSetFifo(info, 0);
} }
info->type = new_serial.type; info->type = new_serial.type;
...@@ -2572,9 +2544,9 @@ static void moxa_low_water_check(void __iomem *ofsAddr) ...@@ -2572,9 +2544,9 @@ static void moxa_low_water_check(void __iomem *ofsAddr)
} }
} }
static void MoxaSetFifo(int port, int enable) static void MoxaSetFifo(struct moxa_port *port, int enable)
{ {
void __iomem *ofsAddr = moxa_ports[port].tableAddr; void __iomem *ofsAddr = port->tableAddr;
if (!enable) { if (!enable) {
moxafunc(ofsAddr, FC_SetRxFIFOTrig, 0); moxafunc(ofsAddr, FC_SetRxFIFOTrig, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment