};
struct moxa_port {
+ struct moxa_board_conf *board;
int type;
- int port;
int close_delay;
unsigned short closing_wait;
int count;
/*
* 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 MoxaPortsOfCard(int);
static int MoxaPortIsValid(int);
-static void MoxaPortEnable(int);
-static void MoxaPortDisable(int);
-static long MoxaPortGetMaxBaud(int);
-static long MoxaPortSetBaud(int, long);
-static int MoxaPortSetTermio(int, struct ktermios *, speed_t);
-static int MoxaPortGetLineOut(int, int *, int *);
-static void MoxaPortLineCtrl(int, int, int);
-static void MoxaPortFlowCtrl(int, int, int, int, int, int);
-static int MoxaPortLineStatus(int);
-static int MoxaPortDCDChange(int);
-static int MoxaPortDCDON(int);
-static void MoxaPortFlushData(int, int);
-static int MoxaPortWriteData(int, unsigned char *, int);
-static int MoxaPortReadData(int, struct tty_struct *tty);
-static int MoxaPortTxQueue(int);
-static int MoxaPortRxQueue(int);
-static int MoxaPortTxFree(int);
-static void MoxaPortTxDisable(int);
-static void MoxaPortTxEnable(int);
-static int MoxaPortResetBrkCnt(int);
-static void MoxaPortSendBreak(int, int);
+static void MoxaPortEnable(struct moxa_port *);
+static void MoxaPortDisable(struct moxa_port *);
+static int MoxaPortSetTermio(struct moxa_port *, struct ktermios *, speed_t);
+static int MoxaPortGetLineOut(struct moxa_port *, int *, int *);
+static void MoxaPortLineCtrl(struct moxa_port *, int, int);
+static void MoxaPortFlowCtrl(struct moxa_port *, int, int, int, int, int);
+static int MoxaPortLineStatus(struct moxa_port *);
+static int MoxaPortDCDChange(struct moxa_port *);
+static int MoxaPortDCDON(struct moxa_port *);
+static void MoxaPortFlushData(struct moxa_port *, int);
+static int MoxaPortWriteData(struct moxa_port *, unsigned char *, int);
+static int MoxaPortReadData(struct moxa_port *, struct tty_struct *tty);
+static int MoxaPortTxQueue(struct moxa_port *);
+static int MoxaPortRxQueue(struct moxa_port *);
+static int MoxaPortTxFree(struct moxa_port *);
+static void MoxaPortTxDisable(struct moxa_port *);
+static void MoxaPortTxEnable(struct moxa_port *);
+static int MoxaPortResetBrkCnt(struct moxa_port *);
+static void MoxaPortSendBreak(struct moxa_port *, int);
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 void MoxaSetFifo(int port, int enable);
+static void MoxaSetFifo(struct moxa_port *port, int enable);
static const struct tty_operations moxa_ops = {
.open = moxa_open,
case MOXA_BOARD_CP204J:
port = brd->ports;
for (i = 0; i < brd->numPorts; i++, port++) {
+ port->board = brd;
port->chkPort = 1;
port->curBaud = 9600L;
port->DCDState = 0;
default:
port = brd->ports;
for (i = 0; i < brd->numPorts; i++, port++) {
+ port->board = brd;
port->chkPort = 1;
port->curBaud = 9600L;
port->DCDState = 0;
for (i = 0, ch = moxa_ports; i < MAX_PORTS; i++, ch++) {
ch->type = PORT_16550A;
- ch->port = i;
ch->close_delay = 5 * HZ / 10;
ch->closing_wait = 30 * HZ;
ch->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
if (!(ch->asyncflags & ASYNC_INITIALIZED)) {
ch->statusflags = 0;
moxa_set_tty_param(tty, tty->termios);
- MoxaPortLineCtrl(ch->port, 1, 1);
- MoxaPortEnable(ch->port);
+ MoxaPortLineCtrl(ch, 1, 1);
+ MoxaPortEnable(ch);
ch->asyncflags |= ASYNC_INITIALIZED;
}
retval = moxa_block_till_ready(tty, filp, ch);
moxa_unthrottle(tty);
if (ch->type == PORT_16550A) {
- MoxaSetFifo(ch->port, 1);
+ MoxaSetFifo(ch, 1);
} else {
- MoxaSetFifo(ch->port, 0);
+ MoxaSetFifo(ch, 0);
}
return (retval);
if (ch->asyncflags & ASYNC_INITIALIZED) {
moxa_setup_empty_event(tty);
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);
- MoxaPortFlushData(port, 2);
+ MoxaPortFlushData(ch, 2);
if (tty->driver->flush_buffer)
tty->driver->flush_buffer(tty);
static int moxa_write(struct tty_struct *tty,
const unsigned char *buf, int count)
{
- struct moxa_port *ch;
- int len, port;
+ struct moxa_port *ch = tty->driver_data;
unsigned long flags;
+ int len;
- ch = (struct moxa_port *) tty->driver_data;
if (ch == NULL)
- return (0);
- port = ch->port;
+ return 0;
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);
/*********************************************
if (tty->stopped)
return (0);
- ch = (struct moxa_port *) tty->driver_data;
+ ch = tty->driver_data;
if (ch == NULL)
return (0);
- return (MoxaPortTxFree(ch->port));
+ return MoxaPortTxFree(ch);
}
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)
return;
- MoxaPortFlushData(ch->port, 1);
+ MoxaPortFlushData(ch, 1);
tty_wakeup(tty);
}
static int moxa_chars_in_buffer(struct tty_struct *tty)
{
+ struct moxa_port *ch = tty->driver_data;
int chars;
- struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
/*
* Sigh...I have to check if driver_data is NULL here, because
*/
if (ch == NULL)
return (0);
- chars = MoxaPortTxQueue(ch->port);
+ chars = MoxaPortTxQueue(ch);
if (chars) {
/*
* Make it possible to wakeup anything waiting for output
static void moxa_put_char(struct tty_struct *tty, unsigned char c)
{
- struct moxa_port *ch;
- int port;
+ struct moxa_port *ch = tty->driver_data;
unsigned long flags;
- ch = (struct moxa_port *) tty->driver_data;
if (ch == NULL)
return;
- port = ch->port;
spin_lock_irqsave(&moxa_lock, flags);
- MoxaPortWriteData(port, &c, 1);
+ MoxaPortWriteData(ch, &c, 1);
spin_unlock_irqrestore(&moxa_lock, flags);
/************************************************
if ( !(ch->statusflags & LOWWAIT) && (MoxaPortTxFree(port) <= 100) )
static int moxa_tiocmget(struct tty_struct *tty, struct file *file)
{
- struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
- int port;
+ struct moxa_port *ch = tty->driver_data;
int flag = 0, dtr, rts;
- port = tty->index;
- if ((port != MAX_PORTS) && (!ch))
+ if ((tty->index != MAX_PORTS) && (!ch))
return (-EINVAL);
- MoxaPortGetLineOut(ch->port, &dtr, &rts);
+ MoxaPortGetLineOut(ch, &dtr, &rts);
if (dtr)
flag |= TIOCM_DTR;
if (rts)
flag |= TIOCM_RTS;
- dtr = MoxaPortLineStatus(ch->port);
+ dtr = MoxaPortLineStatus(ch);
if (dtr & 1)
flag |= TIOCM_CTS;
if (dtr & 2)
static int moxa_tiocmset(struct tty_struct *tty, struct file *file,
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 dtr, rts;
if ((port != MAX_PORTS) && (!ch))
return (-EINVAL);
- MoxaPortGetLineOut(ch->port, &dtr, &rts);
+ MoxaPortGetLineOut(ch, &dtr, &rts);
if (set & TIOCM_RTS)
rts = 1;
if (set & TIOCM_DTR)
rts = 0;
if (clear & TIOCM_DTR)
dtr = 0;
- MoxaPortLineCtrl(ch->port, dtr, rts);
+ MoxaPortLineCtrl(ch, dtr, rts);
return 0;
}
static int moxa_ioctl(struct tty_struct *tty, struct file *file,
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;
void __user *argp = (void __user *)arg;
int retval;
moxa_setup_empty_event(tty);
tty_wait_until_sent(tty, 0);
if (!arg)
- MoxaPortSendBreak(ch->port, 0);
+ MoxaPortSendBreak(ch, 0);
return (0);
case TCSBRKP: /* support for POSIX tcsendbreak() */
retval = tty_check_change(tty);
return (retval);
moxa_setup_empty_event(tty);
tty_wait_until_sent(tty, 0);
- MoxaPortSendBreak(ch->port, arg);
+ MoxaPortSendBreak(ch, arg);
return (0);
case TIOCGSOFTCAR:
return put_user(C_CLOCAL(tty) ? 1 : 0, (int __user *)argp);
case TIOCSSERIAL:
return moxa_set_serial_info(ch, argp);
default:
- retval = MoxaDriverIoctl(cmd, arg, port);
+ retval = MoxaDriverIoctl(tty, cmd, arg);
}
return (retval);
}
if (ch == NULL)
return;
- MoxaPortTxDisable(ch->port);
+ MoxaPortTxDisable(ch);
ch->statusflags |= TXSTOPPED;
}
if (!(ch->statusflags & TXSTOPPED))
return;
- MoxaPortTxEnable(ch->port);
+ MoxaPortTxEnable(ch);
ch->statusflags &= ~TXSTOPPED;
}
if ((ch->asyncflags & ASYNC_INITIALIZED) == 0)
continue;
if (!(ch->statusflags & THROTTLE) &&
- (MoxaPortRxQueue(ch->port) > 0))
+ (MoxaPortRxQueue(ch) > 0))
moxa_receive_data(ch);
if ((tp = ch->tty) == 0)
continue;
if (ch->statusflags & LOWWAIT) {
- if (MoxaPortTxQueue(ch->port) <= WAKEUP_CHARS) {
+ if (MoxaPortTxQueue(ch) <= WAKEUP_CHARS) {
if (!tp->stopped) {
ch->statusflags &= ~LOWWAIT;
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_schedule_flip(tp);
}
- if (MoxaPortDCDChange(ch->port)) {
+ if (MoxaPortDCDChange(ch)) {
if (ch->asyncflags & ASYNC_CHECK_CD) {
- if (MoxaPortDCDON(ch->port))
+ if (MoxaPortDCDON(ch))
wake_up_interruptible(&ch->open_wait);
else {
tty_hangup(tp);
/* Clear the features we don't support */
ts->c_cflag &= ~CMSPAR;
- MoxaPortFlowCtrl(ch->port, rts, cts, txflow, rxflow, xany);
- baud = MoxaPortSetTermio(ch->port, ts, tty_get_baud_rate(tty));
+ MoxaPortFlowCtrl(ch, rts, cts, txflow, rxflow, xany);
+ baud = MoxaPortSetTermio(ch, ts, tty_get_baud_rate(tty));
if (baud == -1)
baud = tty_termios_baud_rate(old_termios);
/* Not put the baud rate into the termios data */
retval = 0;
add_wait_queue(&ch->open_wait, &wait);
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);
if (!tty_hung_up_p(filp))
ch->count--;
break;
}
if (!(ch->asyncflags & ASYNC_CLOSING) && (do_clocal ||
- MoxaPortDCDON(ch->port)))
+ MoxaPortDCDON(ch)))
break;
if (signal_pending(current)) {
ch->blocked_open--;
spin_unlock_irqrestore(&moxa_lock, flags);
pr_debug("block_til_ready after blocking: ttys%d, count = %d\n",
- ch->port, ch->count);
+ tty->index, ch->count);
if (retval)
return (retval);
/* FIXME: review to see if we need to use set_bit on these */
spin_lock_irqsave(&moxa_lock, flags);
ch->statusflags |= EMPTYWAIT;
- mod_timer(&moxa_ports[ch->port].emptyTimer, jiffies + HZ);
+ mod_timer(&ch->emptyTimer, jiffies + HZ);
spin_unlock_irqrestore(&moxa_lock, flags);
}
ch = (struct moxa_port *) data;
if (ch->tty && (ch->statusflags & EMPTYWAIT)) {
- if (MoxaPortTxQueue(ch->port) == 0) {
+ if (MoxaPortTxQueue(ch) == 0) {
ch->statusflags &= ~EMPTYWAIT;
tty_wakeup(ch->tty);
return;
}
- mod_timer(&moxa_ports[ch->port].emptyTimer,
- round_jiffies(jiffies + HZ));
+ mod_timer(&ch->emptyTimer, round_jiffies(jiffies + HZ));
} else
ch->statusflags &= ~EMPTYWAIT;
}
tp = ch->tty;
- MoxaPortDisable(ch->port);
+ MoxaPortDisable(ch);
/*
* If we're a modem control device and HUPCL is on, drop RTS & DTR.
*/
if (tp->termios->c_cflag & HUPCL)
- MoxaPortLineCtrl(ch->port, 0, 0);
+ MoxaPortLineCtrl(ch, 0, 0);
ch->asyncflags &= ~ASYNC_INITIALIZED;
}
if ( !tp || !ts || !(ts->c_cflag & CREAD) ) {
*****************************************************/
if (!tp || !ts) {
- MoxaPortFlushData(ch->port, 0);
+ MoxaPortFlushData(ch, 0);
return;
}
spin_lock_irqsave(&moxa_lock, flags);
- MoxaPortReadData(ch->port, tp);
+ MoxaPortReadData(ch, tp);
spin_unlock_irqrestore(&moxa_lock, flags);
tty_schedule_flip(tp);
}
#define MOXA_GET_CUMAJOR (MOXA + 64)
#define MOXA_GETMSTATUS (MOXA + 65)
-void MoxaPortFlushData(int port, int mode)
+static void MoxaPortFlushData(struct moxa_port *port, int mode)
{
void __iomem *ofsAddr;
if ((mode < 0) || (mode > 2))
return;
- ofsAddr = moxa_ports[port].tableAddr;
+ ofsAddr = port->tableAddr;
moxafunc(ofsAddr, FC_FlushQueue, mode);
if (mode != 1) {
- moxa_ports[port].lowChkFlag = 0;
+ port->lowChkFlag = 0;
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 status;
- int MoxaPortTxQueue(int), MoxaPortRxQueue(int);
void __user *argp = (void __user *)arg;
- if (port == MAX_PORTS) {
+ if (tty->index == MAX_PORTS) {
if ((cmd != MOXA_GET_CONF) && (cmd != MOXA_GETDATACOUNT) &&
(cmd != MOXA_GET_IOQUEUE) && (cmd != MOXA_GET_MAJOR) &&
(cmd != MOXA_GET_CUMAJOR) && (cmd != MOXA_GETMSTATUS))
for (i = 0; i < MAX_PORTS; i++, argm++) {
memset(&tmp, 0, sizeof(tmp));
if (moxa_ports[i].chkPort) {
- tmp.inq = MoxaPortRxQueue(i);
- tmp.outq = MoxaPortTxQueue(i);
+ tmp.inq = MoxaPortRxQueue(&moxa_ports[i]);
+ tmp.outq = MoxaPortTxQueue(&moxa_ports[i]);
}
if (copy_to_user(argm, &tmp, sizeof(tmp)))
return -EFAULT;
if (!p->chkPort) {
goto copy;
} else {
- status = MoxaPortLineStatus(p->port);
+ status = MoxaPortLineStatus(p);
if (status & 1)
tmp.cts = 1;
if (status & 2)
* send out a about 250 ms BREAK signal.
*
*/
-int MoxaPortIsValid(int port)
+static int MoxaPortIsValid(int port)
{
if (moxaCard == 0)
return (0);
return (1);
}
-void MoxaPortEnable(int port)
+static void MoxaPortEnable(struct moxa_port *port)
{
void __iomem *ofsAddr;
- int MoxaPortLineStatus(int);
short lowwater = 512;
- ofsAddr = moxa_ports[port].tableAddr;
+ ofsAddr = port->tableAddr;
writew(lowwater, ofsAddr + Low_water);
- moxa_ports[port].breakCnt = 0;
- if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) ||
- (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) {
+ port->breakCnt = 0;
+ if (port->board->boardType == MOXA_BOARD_C320_ISA ||
+ port->board->boardType == MOXA_BOARD_C320_PCI) {
moxafunc(ofsAddr, FC_SetBreakIrq, 0);
} else {
writew(readw(ofsAddr + HostStat) | WakeupBreak, ofsAddr + HostStat);
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_ClrLineIrq, 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) ||
- (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI))
+ if (port->board->boardType == MOXA_BOARD_C320_ISA ||
+ port->board->boardType == MOXA_BOARD_C320_PCI)
return (460800L);
else
return (921600L);
}
-long MoxaPortSetBaud(int port, long baud)
+static long MoxaPortSetBaud(struct moxa_port *port, long baud)
{
void __iomem *ofsAddr;
long max, clock;
if ((baud < 50L) || ((max = MoxaPortGetMaxBaud(port)) == 0))
return (0);
- ofsAddr = moxa_ports[port].tableAddr;
+ ofsAddr = port->tableAddr;
if (baud > max)
baud = max;
if (max == 38400L)
val = clock / baud;
moxafunc(ofsAddr, FC_SetBaud, val);
baud = clock / val;
- moxa_ports[port].curBaud = baud;
+ port->curBaud = 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;
tcflag_t cflag;
tcflag_t mode = 0;
- if (moxa_ports[port].chkPort == 0 || termio == 0)
+ if (port->chkPort == 0 || termio == 0)
return (-1);
- ofsAddr = moxa_ports[port].tableAddr;
+ ofsAddr = port->tableAddr;
cflag = termio->c_cflag; /* termio->c_cflag */
mode = termio->c_cflag & CSIZE;
moxafunc(ofsAddr, FC_SetDataMode, (ushort) mode);
- if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) ||
- (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) {
+ if (port->board->boardType == MOXA_BOARD_C320_ISA ||
+ port->board->boardType == MOXA_BOARD_C320_PCI) {
if (baud >= 921600L)
return (-1);
}
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);
- if (dtrState) {
- if (moxa_ports[port].lineCtrl & DTR_ON)
- *dtrState = 1;
- else
- *dtrState = 0;
- }
- if (rtsState) {
- if (moxa_ports[port].lineCtrl & RTS_ON)
- *rtsState = 1;
- else
- *rtsState = 0;
- }
+ if (dtrState)
+ *dtrState = !!(port->lineCtrl & DTR_ON);
+ if (rtsState)
+ *rtsState = !!(port->lineCtrl & RTS_ON);
+
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;
+ int mode = 0;
- ofsAddr = moxa_ports[port].tableAddr;
- mode = 0;
if (dtr)
mode |= DTR_ON;
if (rts)
mode |= RTS_ON;
- moxa_ports[port].lineCtrl = mode;
- moxafunc(ofsAddr, FC_LineControl, mode);
+ port->lineCtrl = 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;
+ int mode = 0;
- ofsAddr = moxa_ports[port].tableAddr;
- mode = 0;
if (rts)
mode |= RTS_FlowCtl;
if (cts)
mode |= Rx_FlowCtl;
if (txany)
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;
int val;
- ofsAddr = moxa_ports[port].tableAddr;
- if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) ||
- (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) {
+ ofsAddr = port->tableAddr;
+ if (port->board->boardType == MOXA_BOARD_C320_ISA ||
+ port->board->boardType == MOXA_BOARD_C320_PCI) {
moxafunc(ofsAddr, FC_LineStatus, 0);
val = readw(ofsAddr + FuncArg);
} else {
val &= 0x0B;
if (val & 8) {
val |= 4;
- if ((moxa_ports[port].DCDState & DCD_oldstate) == 0)
- moxa_ports[port].DCDState = (DCD_oldstate | DCD_changed);
+ if ((port->DCDState & DCD_oldstate) == 0)
+ port->DCDState = (DCD_oldstate | DCD_changed);
} else {
- if (moxa_ports[port].DCDState & DCD_oldstate)
- moxa_ports[port].DCDState = DCD_changed;
+ if (port->DCDState & DCD_oldstate)
+ port->DCDState = DCD_changed;
}
val &= 7;
return (val);
}
-int MoxaPortDCDChange(int port)
+static int MoxaPortDCDChange(struct moxa_port *port)
{
int n;
- if (moxa_ports[port].chkPort == 0)
+ if (port->chkPort == 0)
return (0);
- n = moxa_ports[port].DCDState;
- moxa_ports[port].DCDState &= ~DCD_changed;
+ n = port->DCDState;
+ port->DCDState &= ~DCD_changed;
n &= DCD_changed;
return (n);
}
-int MoxaPortDCDON(int port)
+static int MoxaPortDCDON(struct moxa_port *port)
{
int n;
- if (moxa_ports[port].chkPort == 0)
+ if (port->chkPort == 0)
return (0);
- if (moxa_ports[port].DCDState & DCD_oldstate)
+ if (port->DCDState & DCD_oldstate)
n = 1;
else
n = 0;
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;
ushort tail;
ushort pageno, pageofs, bufhead;
void __iomem *baseAddr, *ofsAddr, *ofs;
- ofsAddr = moxa_ports[port].tableAddr;
- baseAddr = moxa_boards[port / MAX_PORTS_PER_BOARD].basemem;
+ ofsAddr = port->tableAddr;
+ baseAddr = port->board->basemem;
tx_mask = readw(ofsAddr + TX_mask);
spage = readw(ofsAddr + Page_txb);
epage = readw(ofsAddr + EndPage_txb);
: (head - tail + tx_mask);
if (c > len)
c = len;
- moxaLog.txcnt[port] += c;
+ moxaLog.txcnt[port->tty->index] += c;
total = c;
if (spage == epage) {
bufhead = readw(ofsAddr + Ofs_txb);
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;
int i, count, cnt, len, total, remain;
ushort pageno, bufhead;
void __iomem *baseAddr, *ofsAddr, *ofs;
- ofsAddr = moxa_ports[port].tableAddr;
- baseAddr = moxa_boards[port / MAX_PORTS_PER_BOARD].basemem;
+ ofsAddr = port->tableAddr;
+ baseAddr = port->board->basemem;
head = readw(ofsAddr + RXrptr);
tail = readw(ofsAddr + RXwptr);
rx_mask = readw(ofsAddr + RX_mask);
total = count;
remain = count - total;
- moxaLog.rxcnt[port] += total;
+ moxaLog.rxcnt[port->tty->index] += total;
count = total;
if (spage == epage) {
bufhead = readw(ofsAddr + Ofs_rxb);
}
if ((readb(ofsAddr + FlagStat) & Xoff_state) && (remain < LowWater)) {
moxaLowWaterChk = 1;
- moxa_ports[port].lowChkFlag = 1;
+ port->lowChkFlag = 1;
}
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;
int len;
- ofsAddr = moxa_ports[port].tableAddr;
rptr = readw(ofsAddr + TXrptr);
wptr = readw(ofsAddr + TXwptr);
mask = readw(ofsAddr + TX_mask);
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;
int len;
- ofsAddr = moxa_ports[port].tableAddr;
rptr = readw(ofsAddr + TXrptr);
wptr = readw(ofsAddr + TXwptr);
mask = readw(ofsAddr + TX_mask);
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;
int len;
- ofsAddr = moxa_ports[port].tableAddr;
rptr = readw(ofsAddr + RXrptr);
wptr = readw(ofsAddr + RXwptr);
mask = readw(ofsAddr + RX_mask);
}
-void MoxaPortTxDisable(int port)
+static void MoxaPortTxDisable(struct moxa_port *port)
{
- void __iomem *ofsAddr;
-
- ofsAddr = moxa_ports[port].tableAddr;
- moxafunc(ofsAddr, FC_SetXoffState, Magic_code);
+ moxafunc(port->tableAddr, FC_SetXoffState, Magic_code);
}
-void MoxaPortTxEnable(int port)
+static void MoxaPortTxEnable(struct moxa_port *port)
{
- void __iomem *ofsAddr;
-
- ofsAddr = moxa_ports[port].tableAddr;
- moxafunc(ofsAddr, FC_SetXonState, Magic_code);
+ moxafunc(port->tableAddr, FC_SetXonState, Magic_code);
}
-int MoxaPortResetBrkCnt(int port)
+static int MoxaPortResetBrkCnt(struct moxa_port *port)
{
ushort cnt;
- cnt = moxa_ports[port].breakCnt;
- moxa_ports[port].breakCnt = 0;
+ cnt = port->breakCnt;
+ port->breakCnt = 0;
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) {
moxafunc(ofsAddr, FC_SendBreak, Magic_code);
msleep(ms100 * 10);
memset(&tmp, 0, sizeof(tmp));
tmp.type = info->type;
- tmp.line = info->port;
+ tmp.line = info->tty->index;
tmp.port = 0;
tmp.irq = 0;
tmp.flags = info->asyncflags;
new_serial.flags |= (info->asyncflags & ASYNC_FLAGS);
if (new_serial.type == PORT_16550A) {
- MoxaSetFifo(info->port, 1);
+ MoxaSetFifo(info, 1);
} else {
- MoxaSetFifo(info->port, 0);
+ MoxaSetFifo(info, 0);
}
info->type = new_serial.type;
}
}
-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) {
moxafunc(ofsAddr, FC_SetRxFIFOTrig, 0);