diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2008-04-30 03:53:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-30 11:29:42 -0400 |
commit | b4173f45758a5b5185acb302c507289e661d9419 (patch) | |
tree | b1aa5c97946790af7c39686bc16b394e8e76ebcd /drivers/char | |
parent | 5292bcd38e4bcd147905941b5e37b5b0da1a5577 (diff) |
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: Jiri Slaby <jirislaby@gmail.com>
Tested-by: Oyvind Aabling <Oyvind.Aabling@uni-c.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/moxa.c | 354 |
1 files changed, 163 insertions, 191 deletions
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index fa58fa14b4cf..ae5433c58161 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c | |||
@@ -128,8 +128,8 @@ struct moxaq_str { | |||
128 | }; | 128 | }; |
129 | 129 | ||
130 | struct moxa_port { | 130 | struct moxa_port { |
131 | struct moxa_board_conf *board; | ||
131 | int type; | 132 | int type; |
132 | int port; | ||
133 | int close_delay; | 133 | int close_delay; |
134 | unsigned short closing_wait; | 134 | unsigned short closing_wait; |
135 | int count; | 135 | int count; |
@@ -218,34 +218,32 @@ static void moxa_receive_data(struct moxa_port *); | |||
218 | /* | 218 | /* |
219 | * moxa board interface functions: | 219 | * moxa board interface functions: |
220 | */ | 220 | */ |
221 | static int MoxaDriverIoctl(unsigned int, unsigned long, int); | 221 | static int MoxaDriverIoctl(struct tty_struct *, unsigned int, unsigned long); |
222 | static int MoxaDriverPoll(void); | 222 | static int MoxaDriverPoll(void); |
223 | static int MoxaPortsOfCard(int); | 223 | static int MoxaPortsOfCard(int); |
224 | static int MoxaPortIsValid(int); | 224 | static int MoxaPortIsValid(int); |
225 | static void MoxaPortEnable(int); | 225 | static void MoxaPortEnable(struct moxa_port *); |
226 | static void MoxaPortDisable(int); | 226 | static void MoxaPortDisable(struct moxa_port *); |
227 | static long MoxaPortGetMaxBaud(int); | 227 | static int MoxaPortSetTermio(struct moxa_port *, struct ktermios *, speed_t); |
228 | static long MoxaPortSetBaud(int, long); | 228 | static int MoxaPortGetLineOut(struct moxa_port *, int *, int *); |
229 | static int MoxaPortSetTermio(int, struct ktermios *, speed_t); | 229 | static void MoxaPortLineCtrl(struct moxa_port *, int, int); |
230 | static int MoxaPortGetLineOut(int, int *, int *); | 230 | static void MoxaPortFlowCtrl(struct moxa_port *, int, int, int, int, int); |
231 | static void MoxaPortLineCtrl(int, int, int); | 231 | static int MoxaPortLineStatus(struct moxa_port *); |
232 | static void MoxaPortFlowCtrl(int, int, int, int, int, int); | 232 | static int MoxaPortDCDChange(struct moxa_port *); |
233 | static int MoxaPortLineStatus(int); | 233 | static int MoxaPortDCDON(struct moxa_port *); |
234 | static int MoxaPortDCDChange(int); | 234 | static void MoxaPortFlushData(struct moxa_port *, int); |
235 | static int MoxaPortDCDON(int); | 235 | static int MoxaPortWriteData(struct moxa_port *, unsigned char *, int); |
236 | static void MoxaPortFlushData(int, int); | 236 | static int MoxaPortReadData(struct moxa_port *, struct tty_struct *tty); |
237 | static int MoxaPortWriteData(int, unsigned char *, int); | 237 | static int MoxaPortTxQueue(struct moxa_port *); |
238 | static int MoxaPortReadData(int, struct tty_struct *tty); | 238 | static int MoxaPortRxQueue(struct moxa_port *); |
239 | static int MoxaPortTxQueue(int); | 239 | static int MoxaPortTxFree(struct moxa_port *); |
240 | static int MoxaPortRxQueue(int); | 240 | static void MoxaPortTxDisable(struct moxa_port *); |
241 | static int MoxaPortTxFree(int); | 241 | static void MoxaPortTxEnable(struct moxa_port *); |
242 | static void MoxaPortTxDisable(int); | 242 | static int MoxaPortResetBrkCnt(struct moxa_port *); |
243 | static void MoxaPortTxEnable(int); | 243 | static void MoxaPortSendBreak(struct moxa_port *, int); |
244 | static int MoxaPortResetBrkCnt(int); | ||
245 | static void MoxaPortSendBreak(int, int); | ||
246 | static int moxa_get_serial_info(struct moxa_port *, struct serial_struct __user *); | 244 | static int moxa_get_serial_info(struct moxa_port *, struct serial_struct __user *); |
247 | static int moxa_set_serial_info(struct moxa_port *, struct serial_struct __user *); | 245 | static int moxa_set_serial_info(struct moxa_port *, struct serial_struct __user *); |
248 | static void MoxaSetFifo(int port, int enable); | 246 | static void MoxaSetFifo(struct moxa_port *port, int enable); |
249 | 247 | ||
250 | static const struct tty_operations moxa_ops = { | 248 | static const struct tty_operations moxa_ops = { |
251 | .open = moxa_open, | 249 | .open = moxa_open, |
@@ -515,6 +513,7 @@ static int moxa_load_code(struct moxa_board_conf *brd, const void *ptr, | |||
515 | case MOXA_BOARD_CP204J: | 513 | case MOXA_BOARD_CP204J: |
516 | port = brd->ports; | 514 | port = brd->ports; |
517 | for (i = 0; i < brd->numPorts; i++, port++) { | 515 | for (i = 0; i < brd->numPorts; i++, port++) { |
516 | port->board = brd; | ||
518 | port->chkPort = 1; | 517 | port->chkPort = 1; |
519 | port->curBaud = 9600L; | 518 | port->curBaud = 9600L; |
520 | port->DCDState = 0; | 519 | port->DCDState = 0; |
@@ -534,6 +533,7 @@ static int moxa_load_code(struct moxa_board_conf *brd, const void *ptr, | |||
534 | default: | 533 | default: |
535 | port = brd->ports; | 534 | port = brd->ports; |
536 | for (i = 0; i < brd->numPorts; i++, port++) { | 535 | for (i = 0; i < brd->numPorts; i++, port++) { |
536 | port->board = brd; | ||
537 | port->chkPort = 1; | 537 | port->chkPort = 1; |
538 | port->curBaud = 9600L; | 538 | port->curBaud = 9600L; |
539 | port->DCDState = 0; | 539 | port->DCDState = 0; |
@@ -822,7 +822,6 @@ static int __init moxa_init(void) | |||
822 | 822 | ||
823 | for (i = 0, ch = moxa_ports; i < MAX_PORTS; i++, ch++) { | 823 | for (i = 0, ch = moxa_ports; i < MAX_PORTS; i++, ch++) { |
824 | ch->type = PORT_16550A; | 824 | ch->type = PORT_16550A; |
825 | ch->port = i; | ||
826 | ch->close_delay = 5 * HZ / 10; | 825 | ch->close_delay = 5 * HZ / 10; |
827 | ch->closing_wait = 30 * HZ; | 826 | ch->closing_wait = 30 * HZ; |
828 | ch->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL; | 827 | ch->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL; |
@@ -939,8 +938,8 @@ static int moxa_open(struct tty_struct *tty, struct file *filp) | |||
939 | if (!(ch->asyncflags & ASYNC_INITIALIZED)) { | 938 | if (!(ch->asyncflags & ASYNC_INITIALIZED)) { |
940 | ch->statusflags = 0; | 939 | ch->statusflags = 0; |
941 | moxa_set_tty_param(tty, tty->termios); | 940 | moxa_set_tty_param(tty, tty->termios); |
942 | MoxaPortLineCtrl(ch->port, 1, 1); | 941 | MoxaPortLineCtrl(ch, 1, 1); |
943 | MoxaPortEnable(ch->port); | 942 | MoxaPortEnable(ch); |
944 | ch->asyncflags |= ASYNC_INITIALIZED; | 943 | ch->asyncflags |= ASYNC_INITIALIZED; |
945 | } | 944 | } |
946 | retval = moxa_block_till_ready(tty, filp, ch); | 945 | retval = moxa_block_till_ready(tty, filp, ch); |
@@ -948,9 +947,9 @@ static int moxa_open(struct tty_struct *tty, struct file *filp) | |||
948 | moxa_unthrottle(tty); | 947 | moxa_unthrottle(tty); |
949 | 948 | ||
950 | if (ch->type == PORT_16550A) { | 949 | if (ch->type == PORT_16550A) { |
951 | MoxaSetFifo(ch->port, 1); | 950 | MoxaSetFifo(ch, 1); |
952 | } else { | 951 | } else { |
953 | MoxaSetFifo(ch->port, 0); | 952 | MoxaSetFifo(ch, 0); |
954 | } | 953 | } |
955 | 954 | ||
956 | return (retval); | 955 | return (retval); |
@@ -997,10 +996,10 @@ static void moxa_close(struct tty_struct *tty, struct file *filp) | |||
997 | if (ch->asyncflags & ASYNC_INITIALIZED) { | 996 | if (ch->asyncflags & ASYNC_INITIALIZED) { |
998 | moxa_setup_empty_event(tty); | 997 | moxa_setup_empty_event(tty); |
999 | tty_wait_until_sent(tty, 30 * HZ); /* 30 seconds timeout */ | 998 | tty_wait_until_sent(tty, 30 * HZ); /* 30 seconds timeout */ |
1000 | del_timer_sync(&moxa_ports[ch->port].emptyTimer); | 999 | del_timer_sync(&ch->emptyTimer); |
1001 | } | 1000 | } |
1002 | moxa_shut_down(ch); | 1001 | moxa_shut_down(ch); |
1003 | MoxaPortFlushData(port, 2); | 1002 | MoxaPortFlushData(ch, 2); |
1004 | 1003 | ||
1005 | if (tty->driver->flush_buffer) | 1004 | if (tty->driver->flush_buffer) |
1006 | tty->driver->flush_buffer(tty); | 1005 | tty->driver->flush_buffer(tty); |
@@ -1022,17 +1021,15 @@ static void moxa_close(struct tty_struct *tty, struct file *filp) | |||
1022 | static int moxa_write(struct tty_struct *tty, | 1021 | static int moxa_write(struct tty_struct *tty, |
1023 | const unsigned char *buf, int count) | 1022 | const unsigned char *buf, int count) |
1024 | { | 1023 | { |
1025 | struct moxa_port *ch; | 1024 | struct moxa_port *ch = tty->driver_data; |
1026 | int len, port; | ||
1027 | unsigned long flags; | 1025 | unsigned long flags; |
1026 | int len; | ||
1028 | 1027 | ||
1029 | ch = (struct moxa_port *) tty->driver_data; | ||
1030 | if (ch == NULL) | 1028 | if (ch == NULL) |
1031 | return (0); | 1029 | return 0; |
1032 | port = ch->port; | ||
1033 | 1030 | ||
1034 | spin_lock_irqsave(&moxa_lock, flags); | 1031 | spin_lock_irqsave(&moxa_lock, flags); |
1035 | len = MoxaPortWriteData(port, (unsigned char *) buf, count); | 1032 | len = MoxaPortWriteData(ch, (unsigned char *) buf, count); |
1036 | spin_unlock_irqrestore(&moxa_lock, flags); | 1033 | spin_unlock_irqrestore(&moxa_lock, flags); |
1037 | 1034 | ||
1038 | /********************************************* | 1035 | /********************************************* |
@@ -1049,26 +1046,26 @@ static int moxa_write_room(struct tty_struct *tty) | |||
1049 | 1046 | ||
1050 | if (tty->stopped) | 1047 | if (tty->stopped) |
1051 | return (0); | 1048 | return (0); |
1052 | ch = (struct moxa_port *) tty->driver_data; | 1049 | ch = tty->driver_data; |
1053 | if (ch == NULL) | 1050 | if (ch == NULL) |
1054 | return (0); | 1051 | return (0); |
1055 | return (MoxaPortTxFree(ch->port)); | 1052 | return MoxaPortTxFree(ch); |
1056 | } | 1053 | } |
1057 | 1054 | ||
1058 | static void moxa_flush_buffer(struct tty_struct *tty) | 1055 | static void moxa_flush_buffer(struct tty_struct *tty) |
1059 | { | 1056 | { |
1060 | struct moxa_port *ch = (struct moxa_port *) tty->driver_data; | 1057 | struct moxa_port *ch = tty->driver_data; |
1061 | 1058 | ||
1062 | if (ch == NULL) | 1059 | if (ch == NULL) |
1063 | return; | 1060 | return; |
1064 | MoxaPortFlushData(ch->port, 1); | 1061 | MoxaPortFlushData(ch, 1); |
1065 | tty_wakeup(tty); | 1062 | tty_wakeup(tty); |
1066 | } | 1063 | } |
1067 | 1064 | ||
1068 | static int moxa_chars_in_buffer(struct tty_struct *tty) | 1065 | static int moxa_chars_in_buffer(struct tty_struct *tty) |
1069 | { | 1066 | { |
1067 | struct moxa_port *ch = tty->driver_data; | ||
1070 | int chars; | 1068 | int chars; |
1071 | struct moxa_port *ch = (struct moxa_port *) tty->driver_data; | ||
1072 | 1069 | ||
1073 | /* | 1070 | /* |
1074 | * Sigh...I have to check if driver_data is NULL here, because | 1071 | * 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 | */ | 1075 | */ |
1079 | if (ch == NULL) | 1076 | if (ch == NULL) |
1080 | return (0); | 1077 | return (0); |
1081 | chars = MoxaPortTxQueue(ch->port); | 1078 | chars = MoxaPortTxQueue(ch); |
1082 | if (chars) { | 1079 | if (chars) { |
1083 | /* | 1080 | /* |
1084 | * Make it possible to wakeup anything waiting for output | 1081 | * Make it possible to wakeup anything waiting for output |
@@ -1100,16 +1097,13 @@ static void moxa_flush_chars(struct tty_struct *tty) | |||
1100 | 1097 | ||
1101 | static void moxa_put_char(struct tty_struct *tty, unsigned char c) | 1098 | static void moxa_put_char(struct tty_struct *tty, unsigned char c) |
1102 | { | 1099 | { |
1103 | struct moxa_port *ch; | 1100 | struct moxa_port *ch = tty->driver_data; |
1104 | int port; | ||
1105 | unsigned long flags; | 1101 | unsigned long flags; |
1106 | 1102 | ||
1107 | ch = (struct moxa_port *) tty->driver_data; | ||
1108 | if (ch == NULL) | 1103 | if (ch == NULL) |
1109 | return; | 1104 | return; |
1110 | port = ch->port; | ||
1111 | spin_lock_irqsave(&moxa_lock, flags); | 1105 | spin_lock_irqsave(&moxa_lock, flags); |
1112 | MoxaPortWriteData(port, &c, 1); | 1106 | MoxaPortWriteData(ch, &c, 1); |
1113 | spin_unlock_irqrestore(&moxa_lock, flags); | 1107 | spin_unlock_irqrestore(&moxa_lock, flags); |
1114 | /************************************************ | 1108 | /************************************************ |
1115 | if ( !(ch->statusflags & LOWWAIT) && (MoxaPortTxFree(port) <= 100) ) | 1109 | if ( !(ch->statusflags & LOWWAIT) && (MoxaPortTxFree(port) <= 100) ) |
@@ -1119,20 +1113,18 @@ static void moxa_put_char(struct tty_struct *tty, unsigned char c) | |||
1119 | 1113 | ||
1120 | static int moxa_tiocmget(struct tty_struct *tty, struct file *file) | 1114 | static int moxa_tiocmget(struct tty_struct *tty, struct file *file) |
1121 | { | 1115 | { |
1122 | struct moxa_port *ch = (struct moxa_port *) tty->driver_data; | 1116 | struct moxa_port *ch = tty->driver_data; |
1123 | int port; | ||
1124 | int flag = 0, dtr, rts; | 1117 | int flag = 0, dtr, rts; |
1125 | 1118 | ||
1126 | port = tty->index; | 1119 | if ((tty->index != MAX_PORTS) && (!ch)) |
1127 | if ((port != MAX_PORTS) && (!ch)) | ||
1128 | return (-EINVAL); | 1120 | return (-EINVAL); |
1129 | 1121 | ||
1130 | MoxaPortGetLineOut(ch->port, &dtr, &rts); | 1122 | MoxaPortGetLineOut(ch, &dtr, &rts); |
1131 | if (dtr) | 1123 | if (dtr) |
1132 | flag |= TIOCM_DTR; | 1124 | flag |= TIOCM_DTR; |
1133 | if (rts) | 1125 | if (rts) |
1134 | flag |= TIOCM_RTS; | 1126 | flag |= TIOCM_RTS; |
1135 | dtr = MoxaPortLineStatus(ch->port); | 1127 | dtr = MoxaPortLineStatus(ch); |
1136 | if (dtr & 1) | 1128 | if (dtr & 1) |
1137 | flag |= TIOCM_CTS; | 1129 | flag |= TIOCM_CTS; |
1138 | if (dtr & 2) | 1130 | if (dtr & 2) |
@@ -1145,7 +1137,7 @@ static int moxa_tiocmget(struct tty_struct *tty, struct file *file) | |||
1145 | static int moxa_tiocmset(struct tty_struct *tty, struct file *file, | 1137 | static int moxa_tiocmset(struct tty_struct *tty, struct file *file, |
1146 | unsigned int set, unsigned int clear) | 1138 | unsigned int set, unsigned int clear) |
1147 | { | 1139 | { |
1148 | struct moxa_port *ch = (struct moxa_port *) tty->driver_data; | 1140 | struct moxa_port *ch = tty->driver_data; |
1149 | int port; | 1141 | int port; |
1150 | int dtr, rts; | 1142 | int dtr, rts; |
1151 | 1143 | ||
@@ -1153,7 +1145,7 @@ static int moxa_tiocmset(struct tty_struct *tty, struct file *file, | |||
1153 | if ((port != MAX_PORTS) && (!ch)) | 1145 | if ((port != MAX_PORTS) && (!ch)) |
1154 | return (-EINVAL); | 1146 | return (-EINVAL); |
1155 | 1147 | ||
1156 | MoxaPortGetLineOut(ch->port, &dtr, &rts); | 1148 | MoxaPortGetLineOut(ch, &dtr, &rts); |
1157 | if (set & TIOCM_RTS) | 1149 | if (set & TIOCM_RTS) |
1158 | rts = 1; | 1150 | rts = 1; |
1159 | if (set & TIOCM_DTR) | 1151 | if (set & TIOCM_DTR) |
@@ -1162,14 +1154,14 @@ static int moxa_tiocmset(struct tty_struct *tty, struct file *file, | |||
1162 | rts = 0; | 1154 | rts = 0; |
1163 | if (clear & TIOCM_DTR) | 1155 | if (clear & TIOCM_DTR) |
1164 | dtr = 0; | 1156 | dtr = 0; |
1165 | MoxaPortLineCtrl(ch->port, dtr, rts); | 1157 | MoxaPortLineCtrl(ch, dtr, rts); |
1166 | return 0; | 1158 | return 0; |
1167 | } | 1159 | } |
1168 | 1160 | ||
1169 | static int moxa_ioctl(struct tty_struct *tty, struct file *file, | 1161 | static int moxa_ioctl(struct tty_struct *tty, struct file *file, |
1170 | unsigned int cmd, unsigned long arg) | 1162 | unsigned int cmd, unsigned long arg) |
1171 | { | 1163 | { |
1172 | struct moxa_port *ch = (struct moxa_port *) tty->driver_data; | 1164 | struct moxa_port *ch = tty->driver_data; |
1173 | register int port; | 1165 | register int port; |
1174 | void __user *argp = (void __user *)arg; | 1166 | void __user *argp = (void __user *)arg; |
1175 | int retval; | 1167 | int retval; |
@@ -1186,7 +1178,7 @@ static int moxa_ioctl(struct tty_struct *tty, struct file *file, | |||
1186 | moxa_setup_empty_event(tty); | 1178 | moxa_setup_empty_event(tty); |
1187 | tty_wait_until_sent(tty, 0); | 1179 | tty_wait_until_sent(tty, 0); |
1188 | if (!arg) | 1180 | if (!arg) |
1189 | MoxaPortSendBreak(ch->port, 0); | 1181 | MoxaPortSendBreak(ch, 0); |
1190 | return (0); | 1182 | return (0); |
1191 | case TCSBRKP: /* support for POSIX tcsendbreak() */ | 1183 | case TCSBRKP: /* support for POSIX tcsendbreak() */ |
1192 | retval = tty_check_change(tty); | 1184 | retval = tty_check_change(tty); |
@@ -1194,7 +1186,7 @@ static int moxa_ioctl(struct tty_struct *tty, struct file *file, | |||
1194 | return (retval); | 1186 | return (retval); |
1195 | moxa_setup_empty_event(tty); | 1187 | moxa_setup_empty_event(tty); |
1196 | tty_wait_until_sent(tty, 0); | 1188 | tty_wait_until_sent(tty, 0); |
1197 | MoxaPortSendBreak(ch->port, arg); | 1189 | MoxaPortSendBreak(ch, arg); |
1198 | return (0); | 1190 | return (0); |
1199 | case TIOCGSOFTCAR: | 1191 | case TIOCGSOFTCAR: |
1200 | return put_user(C_CLOCAL(tty) ? 1 : 0, (int __user *)argp); | 1192 | 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 | case TIOCSSERIAL: | 1207 | case TIOCSSERIAL: |
1216 | return moxa_set_serial_info(ch, argp); | 1208 | return moxa_set_serial_info(ch, argp); |
1217 | default: | 1209 | default: |
1218 | retval = MoxaDriverIoctl(cmd, arg, port); | 1210 | retval = MoxaDriverIoctl(tty, cmd, arg); |
1219 | } | 1211 | } |
1220 | return (retval); | 1212 | return (retval); |
1221 | } | 1213 | } |
@@ -1253,7 +1245,7 @@ static void moxa_stop(struct tty_struct *tty) | |||
1253 | 1245 | ||
1254 | if (ch == NULL) | 1246 | if (ch == NULL) |
1255 | return; | 1247 | return; |
1256 | MoxaPortTxDisable(ch->port); | 1248 | MoxaPortTxDisable(ch); |
1257 | ch->statusflags |= TXSTOPPED; | 1249 | ch->statusflags |= TXSTOPPED; |
1258 | } | 1250 | } |
1259 | 1251 | ||
@@ -1268,7 +1260,7 @@ static void moxa_start(struct tty_struct *tty) | |||
1268 | if (!(ch->statusflags & TXSTOPPED)) | 1260 | if (!(ch->statusflags & TXSTOPPED)) |
1269 | return; | 1261 | return; |
1270 | 1262 | ||
1271 | MoxaPortTxEnable(ch->port); | 1263 | MoxaPortTxEnable(ch); |
1272 | ch->statusflags &= ~TXSTOPPED; | 1264 | ch->statusflags &= ~TXSTOPPED; |
1273 | } | 1265 | } |
1274 | 1266 | ||
@@ -1306,25 +1298,25 @@ static void moxa_poll(unsigned long ignored) | |||
1306 | if ((ch->asyncflags & ASYNC_INITIALIZED) == 0) | 1298 | if ((ch->asyncflags & ASYNC_INITIALIZED) == 0) |
1307 | continue; | 1299 | continue; |
1308 | if (!(ch->statusflags & THROTTLE) && | 1300 | if (!(ch->statusflags & THROTTLE) && |
1309 | (MoxaPortRxQueue(ch->port) > 0)) | 1301 | (MoxaPortRxQueue(ch) > 0)) |
1310 | moxa_receive_data(ch); | 1302 | moxa_receive_data(ch); |
1311 | if ((tp = ch->tty) == 0) | 1303 | if ((tp = ch->tty) == 0) |
1312 | continue; | 1304 | continue; |
1313 | if (ch->statusflags & LOWWAIT) { | 1305 | if (ch->statusflags & LOWWAIT) { |
1314 | if (MoxaPortTxQueue(ch->port) <= WAKEUP_CHARS) { | 1306 | if (MoxaPortTxQueue(ch) <= WAKEUP_CHARS) { |
1315 | if (!tp->stopped) { | 1307 | if (!tp->stopped) { |
1316 | ch->statusflags &= ~LOWWAIT; | 1308 | ch->statusflags &= ~LOWWAIT; |
1317 | tty_wakeup(tp); | 1309 | tty_wakeup(tp); |
1318 | } | 1310 | } |
1319 | } | 1311 | } |
1320 | } | 1312 | } |
1321 | if (!I_IGNBRK(tp) && (MoxaPortResetBrkCnt(ch->port) > 0)) { | 1313 | if (!I_IGNBRK(tp) && (MoxaPortResetBrkCnt(ch) > 0)) { |
1322 | tty_insert_flip_char(tp, 0, TTY_BREAK); | 1314 | tty_insert_flip_char(tp, 0, TTY_BREAK); |
1323 | tty_schedule_flip(tp); | 1315 | tty_schedule_flip(tp); |
1324 | } | 1316 | } |
1325 | if (MoxaPortDCDChange(ch->port)) { | 1317 | if (MoxaPortDCDChange(ch)) { |
1326 | if (ch->asyncflags & ASYNC_CHECK_CD) { | 1318 | if (ch->asyncflags & ASYNC_CHECK_CD) { |
1327 | if (MoxaPortDCDON(ch->port)) | 1319 | if (MoxaPortDCDON(ch)) |
1328 | wake_up_interruptible(&ch->open_wait); | 1320 | wake_up_interruptible(&ch->open_wait); |
1329 | else { | 1321 | else { |
1330 | tty_hangup(tp); | 1322 | tty_hangup(tp); |
@@ -1365,8 +1357,8 @@ static void moxa_set_tty_param(struct tty_struct *tty, struct ktermios *old_term | |||
1365 | 1357 | ||
1366 | /* Clear the features we don't support */ | 1358 | /* Clear the features we don't support */ |
1367 | ts->c_cflag &= ~CMSPAR; | 1359 | ts->c_cflag &= ~CMSPAR; |
1368 | MoxaPortFlowCtrl(ch->port, rts, cts, txflow, rxflow, xany); | 1360 | MoxaPortFlowCtrl(ch, rts, cts, txflow, rxflow, xany); |
1369 | baud = MoxaPortSetTermio(ch->port, ts, tty_get_baud_rate(tty)); | 1361 | baud = MoxaPortSetTermio(ch, ts, tty_get_baud_rate(tty)); |
1370 | if (baud == -1) | 1362 | if (baud == -1) |
1371 | baud = tty_termios_baud_rate(old_termios); | 1363 | baud = tty_termios_baud_rate(old_termios); |
1372 | /* Not put the baud rate into the termios data */ | 1364 | /* 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 | retval = 0; | 1403 | retval = 0; |
1412 | add_wait_queue(&ch->open_wait, &wait); | 1404 | add_wait_queue(&ch->open_wait, &wait); |
1413 | pr_debug("block_til_ready before block: ttys%d, count = %d\n", | 1405 | pr_debug("block_til_ready before block: ttys%d, count = %d\n", |
1414 | ch->port, ch->count); | 1406 | tty->index, ch->count); |
1415 | spin_lock_irqsave(&moxa_lock, flags); | 1407 | spin_lock_irqsave(&moxa_lock, flags); |
1416 | if (!tty_hung_up_p(filp)) | 1408 | if (!tty_hung_up_p(filp)) |
1417 | ch->count--; | 1409 | ch->count--; |
@@ -1433,7 +1425,7 @@ static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp, | |||
1433 | break; | 1425 | break; |
1434 | } | 1426 | } |
1435 | if (!(ch->asyncflags & ASYNC_CLOSING) && (do_clocal || | 1427 | if (!(ch->asyncflags & ASYNC_CLOSING) && (do_clocal || |
1436 | MoxaPortDCDON(ch->port))) | 1428 | MoxaPortDCDON(ch))) |
1437 | break; | 1429 | break; |
1438 | 1430 | ||
1439 | if (signal_pending(current)) { | 1431 | if (signal_pending(current)) { |
@@ -1451,7 +1443,7 @@ static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp, | |||
1451 | ch->blocked_open--; | 1443 | ch->blocked_open--; |
1452 | spin_unlock_irqrestore(&moxa_lock, flags); | 1444 | spin_unlock_irqrestore(&moxa_lock, flags); |
1453 | pr_debug("block_til_ready after blocking: ttys%d, count = %d\n", | 1445 | pr_debug("block_til_ready after blocking: ttys%d, count = %d\n", |
1454 | ch->port, ch->count); | 1446 | tty->index, ch->count); |
1455 | if (retval) | 1447 | if (retval) |
1456 | return (retval); | 1448 | return (retval); |
1457 | /* FIXME: review to see if we need to use set_bit on these */ | 1449 | /* 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 | 1458 | ||
1467 | spin_lock_irqsave(&moxa_lock, flags); | 1459 | spin_lock_irqsave(&moxa_lock, flags); |
1468 | ch->statusflags |= EMPTYWAIT; | 1460 | ch->statusflags |= EMPTYWAIT; |
1469 | mod_timer(&moxa_ports[ch->port].emptyTimer, jiffies + HZ); | 1461 | mod_timer(&ch->emptyTimer, jiffies + HZ); |
1470 | spin_unlock_irqrestore(&moxa_lock, flags); | 1462 | spin_unlock_irqrestore(&moxa_lock, flags); |
1471 | } | 1463 | } |
1472 | 1464 | ||
@@ -1476,13 +1468,12 @@ static void moxa_check_xmit_empty(unsigned long data) | |||
1476 | 1468 | ||
1477 | ch = (struct moxa_port *) data; | 1469 | ch = (struct moxa_port *) data; |
1478 | if (ch->tty && (ch->statusflags & EMPTYWAIT)) { | 1470 | if (ch->tty && (ch->statusflags & EMPTYWAIT)) { |
1479 | if (MoxaPortTxQueue(ch->port) == 0) { | 1471 | if (MoxaPortTxQueue(ch) == 0) { |
1480 | ch->statusflags &= ~EMPTYWAIT; | 1472 | ch->statusflags &= ~EMPTYWAIT; |
1481 | tty_wakeup(ch->tty); | 1473 | tty_wakeup(ch->tty); |
1482 | return; | 1474 | return; |
1483 | } | 1475 | } |
1484 | mod_timer(&moxa_ports[ch->port].emptyTimer, | 1476 | mod_timer(&ch->emptyTimer, round_jiffies(jiffies + HZ)); |
1485 | round_jiffies(jiffies + HZ)); | ||
1486 | } else | 1477 | } else |
1487 | ch->statusflags &= ~EMPTYWAIT; | 1478 | ch->statusflags &= ~EMPTYWAIT; |
1488 | } | 1479 | } |
@@ -1496,13 +1487,13 @@ static void moxa_shut_down(struct moxa_port *ch) | |||
1496 | 1487 | ||
1497 | tp = ch->tty; | 1488 | tp = ch->tty; |
1498 | 1489 | ||
1499 | MoxaPortDisable(ch->port); | 1490 | MoxaPortDisable(ch); |
1500 | 1491 | ||
1501 | /* | 1492 | /* |
1502 | * If we're a modem control device and HUPCL is on, drop RTS & DTR. | 1493 | * If we're a modem control device and HUPCL is on, drop RTS & DTR. |
1503 | */ | 1494 | */ |
1504 | if (tp->termios->c_cflag & HUPCL) | 1495 | if (tp->termios->c_cflag & HUPCL) |
1505 | MoxaPortLineCtrl(ch->port, 0, 0); | 1496 | MoxaPortLineCtrl(ch, 0, 0); |
1506 | 1497 | ||
1507 | ch->asyncflags &= ~ASYNC_INITIALIZED; | 1498 | ch->asyncflags &= ~ASYNC_INITIALIZED; |
1508 | } | 1499 | } |
@@ -1521,11 +1512,11 @@ static void moxa_receive_data(struct moxa_port *ch) | |||
1521 | if ( !tp || !ts || !(ts->c_cflag & CREAD) ) { | 1512 | if ( !tp || !ts || !(ts->c_cflag & CREAD) ) { |
1522 | *****************************************************/ | 1513 | *****************************************************/ |
1523 | if (!tp || !ts) { | 1514 | if (!tp || !ts) { |
1524 | MoxaPortFlushData(ch->port, 0); | 1515 | MoxaPortFlushData(ch, 0); |
1525 | return; | 1516 | return; |
1526 | } | 1517 | } |
1527 | spin_lock_irqsave(&moxa_lock, flags); | 1518 | spin_lock_irqsave(&moxa_lock, flags); |
1528 | MoxaPortReadData(ch->port, tp); | 1519 | MoxaPortReadData(ch, tp); |
1529 | spin_unlock_irqrestore(&moxa_lock, flags); | 1520 | spin_unlock_irqrestore(&moxa_lock, flags); |
1530 | tty_schedule_flip(tp); | 1521 | tty_schedule_flip(tp); |
1531 | } | 1522 | } |
@@ -1567,27 +1558,28 @@ static void moxa_low_water_check(void __iomem *); | |||
1567 | #define MOXA_GET_CUMAJOR (MOXA + 64) | 1558 | #define MOXA_GET_CUMAJOR (MOXA + 64) |
1568 | #define MOXA_GETMSTATUS (MOXA + 65) | 1559 | #define MOXA_GETMSTATUS (MOXA + 65) |
1569 | 1560 | ||
1570 | void MoxaPortFlushData(int port, int mode) | 1561 | static void MoxaPortFlushData(struct moxa_port *port, int mode) |
1571 | { | 1562 | { |
1572 | void __iomem *ofsAddr; | 1563 | void __iomem *ofsAddr; |
1573 | if ((mode < 0) || (mode > 2)) | 1564 | if ((mode < 0) || (mode > 2)) |
1574 | return; | 1565 | return; |
1575 | ofsAddr = moxa_ports[port].tableAddr; | 1566 | ofsAddr = port->tableAddr; |
1576 | moxafunc(ofsAddr, FC_FlushQueue, mode); | 1567 | moxafunc(ofsAddr, FC_FlushQueue, mode); |
1577 | if (mode != 1) { | 1568 | if (mode != 1) { |
1578 | moxa_ports[port].lowChkFlag = 0; | 1569 | port->lowChkFlag = 0; |
1579 | moxa_low_water_check(ofsAddr); | 1570 | moxa_low_water_check(ofsAddr); |
1580 | } | 1571 | } |
1581 | } | 1572 | } |
1582 | 1573 | ||
1583 | int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port) | 1574 | static int MoxaDriverIoctl(struct tty_struct *tty, unsigned int cmd, |
1575 | unsigned long arg) | ||
1584 | { | 1576 | { |
1577 | struct moxa_port *port = tty->driver_data; | ||
1585 | int i; | 1578 | int i; |
1586 | int status; | 1579 | int status; |
1587 | int MoxaPortTxQueue(int), MoxaPortRxQueue(int); | ||
1588 | void __user *argp = (void __user *)arg; | 1580 | void __user *argp = (void __user *)arg; |
1589 | 1581 | ||
1590 | if (port == MAX_PORTS) { | 1582 | if (tty->index == MAX_PORTS) { |
1591 | if ((cmd != MOXA_GET_CONF) && (cmd != MOXA_GETDATACOUNT) && | 1583 | if ((cmd != MOXA_GET_CONF) && (cmd != MOXA_GETDATACOUNT) && |
1592 | (cmd != MOXA_GET_IOQUEUE) && (cmd != MOXA_GET_MAJOR) && | 1584 | (cmd != MOXA_GET_IOQUEUE) && (cmd != MOXA_GET_MAJOR) && |
1593 | (cmd != MOXA_GET_CUMAJOR) && (cmd != MOXA_GETMSTATUS)) | 1585 | (cmd != MOXA_GET_CUMAJOR) && (cmd != MOXA_GETMSTATUS)) |
@@ -1609,8 +1601,8 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port) | |||
1609 | for (i = 0; i < MAX_PORTS; i++, argm++) { | 1601 | for (i = 0; i < MAX_PORTS; i++, argm++) { |
1610 | memset(&tmp, 0, sizeof(tmp)); | 1602 | memset(&tmp, 0, sizeof(tmp)); |
1611 | if (moxa_ports[i].chkPort) { | 1603 | if (moxa_ports[i].chkPort) { |
1612 | tmp.inq = MoxaPortRxQueue(i); | 1604 | tmp.inq = MoxaPortRxQueue(&moxa_ports[i]); |
1613 | tmp.outq = MoxaPortTxQueue(i); | 1605 | tmp.outq = MoxaPortTxQueue(&moxa_ports[i]); |
1614 | } | 1606 | } |
1615 | if (copy_to_user(argm, &tmp, sizeof(tmp))) | 1607 | if (copy_to_user(argm, &tmp, sizeof(tmp))) |
1616 | return -EFAULT; | 1608 | return -EFAULT; |
@@ -1642,7 +1634,7 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port) | |||
1642 | if (!p->chkPort) { | 1634 | if (!p->chkPort) { |
1643 | goto copy; | 1635 | goto copy; |
1644 | } else { | 1636 | } else { |
1645 | status = MoxaPortLineStatus(p->port); | 1637 | status = MoxaPortLineStatus(p); |
1646 | if (status & 1) | 1638 | if (status & 1) |
1647 | tmp.cts = 1; | 1639 | tmp.cts = 1; |
1648 | if (status & 2) | 1640 | if (status & 2) |
@@ -2016,7 +2008,7 @@ int MoxaPortsOfCard(int cardno) | |||
2016 | * send out a about 250 ms BREAK signal. | 2008 | * send out a about 250 ms BREAK signal. |
2017 | * | 2009 | * |
2018 | */ | 2010 | */ |
2019 | int MoxaPortIsValid(int port) | 2011 | static int MoxaPortIsValid(int port) |
2020 | { | 2012 | { |
2021 | if (moxaCard == 0) | 2013 | if (moxaCard == 0) |
2022 | return (0); | 2014 | return (0); |
@@ -2025,17 +2017,16 @@ int MoxaPortIsValid(int port) | |||
2025 | return (1); | 2017 | return (1); |
2026 | } | 2018 | } |
2027 | 2019 | ||
2028 | void MoxaPortEnable(int port) | 2020 | static void MoxaPortEnable(struct moxa_port *port) |
2029 | { | 2021 | { |
2030 | void __iomem *ofsAddr; | 2022 | void __iomem *ofsAddr; |
2031 | int MoxaPortLineStatus(int); | ||
2032 | short lowwater = 512; | 2023 | short lowwater = 512; |
2033 | 2024 | ||
2034 | ofsAddr = moxa_ports[port].tableAddr; | 2025 | ofsAddr = port->tableAddr; |
2035 | writew(lowwater, ofsAddr + Low_water); | 2026 | writew(lowwater, ofsAddr + Low_water); |
2036 | moxa_ports[port].breakCnt = 0; | 2027 | port->breakCnt = 0; |
2037 | if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) || | 2028 | if (port->board->boardType == MOXA_BOARD_C320_ISA || |
2038 | (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) { | 2029 | port->board->boardType == MOXA_BOARD_C320_PCI) { |
2039 | moxafunc(ofsAddr, FC_SetBreakIrq, 0); | 2030 | moxafunc(ofsAddr, FC_SetBreakIrq, 0); |
2040 | } else { | 2031 | } else { |
2041 | writew(readw(ofsAddr + HostStat) | WakeupBreak, ofsAddr + HostStat); | 2032 | writew(readw(ofsAddr + HostStat) | WakeupBreak, ofsAddr + HostStat); |
@@ -2048,9 +2039,9 @@ void MoxaPortEnable(int port) | |||
2048 | MoxaPortLineStatus(port); | 2039 | MoxaPortLineStatus(port); |
2049 | } | 2040 | } |
2050 | 2041 | ||
2051 | void MoxaPortDisable(int port) | 2042 | static void MoxaPortDisable(struct moxa_port *port) |
2052 | { | 2043 | { |
2053 | void __iomem *ofsAddr = moxa_ports[port].tableAddr; | 2044 | void __iomem *ofsAddr = port->tableAddr; |
2054 | 2045 | ||
2055 | moxafunc(ofsAddr, FC_SetFlowCtl, 0); /* disable flow control */ | 2046 | moxafunc(ofsAddr, FC_SetFlowCtl, 0); /* disable flow control */ |
2056 | moxafunc(ofsAddr, FC_ClrLineIrq, Magic_code); | 2047 | moxafunc(ofsAddr, FC_ClrLineIrq, Magic_code); |
@@ -2058,17 +2049,17 @@ void MoxaPortDisable(int port) | |||
2058 | moxafunc(ofsAddr, FC_DisableCH, Magic_code); | 2049 | moxafunc(ofsAddr, FC_DisableCH, Magic_code); |
2059 | } | 2050 | } |
2060 | 2051 | ||
2061 | long MoxaPortGetMaxBaud(int port) | 2052 | static long MoxaPortGetMaxBaud(struct moxa_port *port) |
2062 | { | 2053 | { |
2063 | if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) || | 2054 | if (port->board->boardType == MOXA_BOARD_C320_ISA || |
2064 | (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) | 2055 | port->board->boardType == MOXA_BOARD_C320_PCI) |
2065 | return (460800L); | 2056 | return (460800L); |
2066 | else | 2057 | else |
2067 | return (921600L); | 2058 | return (921600L); |
2068 | } | 2059 | } |
2069 | 2060 | ||
2070 | 2061 | ||
2071 | long MoxaPortSetBaud(int port, long baud) | 2062 | static long MoxaPortSetBaud(struct moxa_port *port, long baud) |
2072 | { | 2063 | { |
2073 | void __iomem *ofsAddr; | 2064 | void __iomem *ofsAddr; |
2074 | long max, clock; | 2065 | long max, clock; |
@@ -2076,7 +2067,7 @@ long MoxaPortSetBaud(int port, long baud) | |||
2076 | 2067 | ||
2077 | if ((baud < 50L) || ((max = MoxaPortGetMaxBaud(port)) == 0)) | 2068 | if ((baud < 50L) || ((max = MoxaPortGetMaxBaud(port)) == 0)) |
2078 | return (0); | 2069 | return (0); |
2079 | ofsAddr = moxa_ports[port].tableAddr; | 2070 | ofsAddr = port->tableAddr; |
2080 | if (baud > max) | 2071 | if (baud > max) |
2081 | baud = max; | 2072 | baud = max; |
2082 | if (max == 38400L) | 2073 | if (max == 38400L) |
@@ -2088,19 +2079,20 @@ long MoxaPortSetBaud(int port, long baud) | |||
2088 | val = clock / baud; | 2079 | val = clock / baud; |
2089 | moxafunc(ofsAddr, FC_SetBaud, val); | 2080 | moxafunc(ofsAddr, FC_SetBaud, val); |
2090 | baud = clock / val; | 2081 | baud = clock / val; |
2091 | moxa_ports[port].curBaud = baud; | 2082 | port->curBaud = baud; |
2092 | return (baud); | 2083 | return (baud); |
2093 | } | 2084 | } |
2094 | 2085 | ||
2095 | int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud) | 2086 | static int MoxaPortSetTermio(struct moxa_port *port, struct ktermios *termio, |
2087 | speed_t baud) | ||
2096 | { | 2088 | { |
2097 | void __iomem *ofsAddr; | 2089 | void __iomem *ofsAddr; |
2098 | tcflag_t cflag; | 2090 | tcflag_t cflag; |
2099 | tcflag_t mode = 0; | 2091 | tcflag_t mode = 0; |
2100 | 2092 | ||
2101 | if (moxa_ports[port].chkPort == 0 || termio == 0) | 2093 | if (port->chkPort == 0 || termio == 0) |
2102 | return (-1); | 2094 | return (-1); |
2103 | ofsAddr = moxa_ports[port].tableAddr; | 2095 | ofsAddr = port->tableAddr; |
2104 | cflag = termio->c_cflag; /* termio->c_cflag */ | 2096 | cflag = termio->c_cflag; /* termio->c_cflag */ |
2105 | 2097 | ||
2106 | mode = termio->c_cflag & CSIZE; | 2098 | mode = termio->c_cflag & CSIZE; |
@@ -2131,8 +2123,8 @@ int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud) | |||
2131 | 2123 | ||
2132 | moxafunc(ofsAddr, FC_SetDataMode, (ushort) mode); | 2124 | moxafunc(ofsAddr, FC_SetDataMode, (ushort) mode); |
2133 | 2125 | ||
2134 | if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) || | 2126 | if (port->board->boardType == MOXA_BOARD_C320_ISA || |
2135 | (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) { | 2127 | port->board->boardType == MOXA_BOARD_C320_PCI) { |
2136 | if (baud >= 921600L) | 2128 | if (baud >= 921600L) |
2137 | return (-1); | 2129 | return (-1); |
2138 | } | 2130 | } |
@@ -2148,48 +2140,37 @@ int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud) | |||
2148 | return (baud); | 2140 | return (baud); |
2149 | } | 2141 | } |
2150 | 2142 | ||
2151 | int MoxaPortGetLineOut(int port, int *dtrState, int *rtsState) | 2143 | static int MoxaPortGetLineOut(struct moxa_port *port, int *dtrState, |
2144 | int *rtsState) | ||
2152 | { | 2145 | { |
2153 | 2146 | ||
2154 | if (!MoxaPortIsValid(port)) | 2147 | if (!MoxaPortIsValid(port->tty->index)) |
2155 | return (-1); | 2148 | return (-1); |
2156 | if (dtrState) { | 2149 | if (dtrState) |
2157 | if (moxa_ports[port].lineCtrl & DTR_ON) | 2150 | *dtrState = !!(port->lineCtrl & DTR_ON); |
2158 | *dtrState = 1; | 2151 | if (rtsState) |
2159 | else | 2152 | *rtsState = !!(port->lineCtrl & RTS_ON); |
2160 | *dtrState = 0; | 2153 | |
2161 | } | ||
2162 | if (rtsState) { | ||
2163 | if (moxa_ports[port].lineCtrl & RTS_ON) | ||
2164 | *rtsState = 1; | ||
2165 | else | ||
2166 | *rtsState = 0; | ||
2167 | } | ||
2168 | return (0); | 2154 | return (0); |
2169 | } | 2155 | } |
2170 | 2156 | ||
2171 | void MoxaPortLineCtrl(int port, int dtr, int rts) | 2157 | static void MoxaPortLineCtrl(struct moxa_port *port, int dtr, int rts) |
2172 | { | 2158 | { |
2173 | void __iomem *ofsAddr; | 2159 | int mode = 0; |
2174 | int mode; | ||
2175 | 2160 | ||
2176 | ofsAddr = moxa_ports[port].tableAddr; | ||
2177 | mode = 0; | ||
2178 | if (dtr) | 2161 | if (dtr) |
2179 | mode |= DTR_ON; | 2162 | mode |= DTR_ON; |
2180 | if (rts) | 2163 | if (rts) |
2181 | mode |= RTS_ON; | 2164 | mode |= RTS_ON; |
2182 | moxa_ports[port].lineCtrl = mode; | 2165 | port->lineCtrl = mode; |
2183 | moxafunc(ofsAddr, FC_LineControl, mode); | 2166 | moxafunc(port->tableAddr, FC_LineControl, mode); |
2184 | } | 2167 | } |
2185 | 2168 | ||
2186 | void MoxaPortFlowCtrl(int port, int rts, int cts, int txflow, int rxflow, int txany) | 2169 | static void MoxaPortFlowCtrl(struct moxa_port *port, int rts, int cts, |
2170 | int txflow, int rxflow, int txany) | ||
2187 | { | 2171 | { |
2188 | void __iomem *ofsAddr; | 2172 | int mode = 0; |
2189 | int mode; | ||
2190 | 2173 | ||
2191 | ofsAddr = moxa_ports[port].tableAddr; | ||
2192 | mode = 0; | ||
2193 | if (rts) | 2174 | if (rts) |
2194 | mode |= RTS_FlowCtl; | 2175 | mode |= RTS_FlowCtl; |
2195 | if (cts) | 2176 | if (cts) |
@@ -2200,17 +2181,17 @@ void MoxaPortFlowCtrl(int port, int rts, int cts, int txflow, int rxflow, int tx | |||
2200 | mode |= Rx_FlowCtl; | 2181 | mode |= Rx_FlowCtl; |
2201 | if (txany) | 2182 | if (txany) |
2202 | mode |= IXM_IXANY; | 2183 | mode |= IXM_IXANY; |
2203 | moxafunc(ofsAddr, FC_SetFlowCtl, mode); | 2184 | moxafunc(port->tableAddr, FC_SetFlowCtl, mode); |
2204 | } | 2185 | } |
2205 | 2186 | ||
2206 | int MoxaPortLineStatus(int port) | 2187 | static int MoxaPortLineStatus(struct moxa_port *port) |
2207 | { | 2188 | { |
2208 | void __iomem *ofsAddr; | 2189 | void __iomem *ofsAddr; |
2209 | int val; | 2190 | int val; |
2210 | 2191 | ||
2211 | ofsAddr = moxa_ports[port].tableAddr; | 2192 | ofsAddr = port->tableAddr; |
2212 | if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) || | 2193 | if (port->board->boardType == MOXA_BOARD_C320_ISA || |
2213 | (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) { | 2194 | port->board->boardType == MOXA_BOARD_C320_PCI) { |
2214 | moxafunc(ofsAddr, FC_LineStatus, 0); | 2195 | moxafunc(ofsAddr, FC_LineStatus, 0); |
2215 | val = readw(ofsAddr + FuncArg); | 2196 | val = readw(ofsAddr + FuncArg); |
2216 | } else { | 2197 | } else { |
@@ -2219,42 +2200,43 @@ int MoxaPortLineStatus(int port) | |||
2219 | val &= 0x0B; | 2200 | val &= 0x0B; |
2220 | if (val & 8) { | 2201 | if (val & 8) { |
2221 | val |= 4; | 2202 | val |= 4; |
2222 | if ((moxa_ports[port].DCDState & DCD_oldstate) == 0) | 2203 | if ((port->DCDState & DCD_oldstate) == 0) |
2223 | moxa_ports[port].DCDState = (DCD_oldstate | DCD_changed); | 2204 | port->DCDState = (DCD_oldstate | DCD_changed); |
2224 | } else { | 2205 | } else { |
2225 | if (moxa_ports[port].DCDState & DCD_oldstate) | 2206 | if (port->DCDState & DCD_oldstate) |
2226 | moxa_ports[port].DCDState = DCD_changed; | 2207 | port->DCDState = DCD_changed; |
2227 | } | 2208 | } |
2228 | val &= 7; | 2209 | val &= 7; |
2229 | return (val); | 2210 | return (val); |
2230 | } | 2211 | } |
2231 | 2212 | ||
2232 | int MoxaPortDCDChange(int port) | 2213 | static int MoxaPortDCDChange(struct moxa_port *port) |
2233 | { | 2214 | { |
2234 | int n; | 2215 | int n; |
2235 | 2216 | ||
2236 | if (moxa_ports[port].chkPort == 0) | 2217 | if (port->chkPort == 0) |
2237 | return (0); | 2218 | return (0); |
2238 | n = moxa_ports[port].DCDState; | 2219 | n = port->DCDState; |
2239 | moxa_ports[port].DCDState &= ~DCD_changed; | 2220 | port->DCDState &= ~DCD_changed; |
2240 | n &= DCD_changed; | 2221 | n &= DCD_changed; |
2241 | return (n); | 2222 | return (n); |
2242 | } | 2223 | } |
2243 | 2224 | ||
2244 | int MoxaPortDCDON(int port) | 2225 | static int MoxaPortDCDON(struct moxa_port *port) |
2245 | { | 2226 | { |
2246 | int n; | 2227 | int n; |
2247 | 2228 | ||
2248 | if (moxa_ports[port].chkPort == 0) | 2229 | if (port->chkPort == 0) |
2249 | return (0); | 2230 | return (0); |
2250 | if (moxa_ports[port].DCDState & DCD_oldstate) | 2231 | if (port->DCDState & DCD_oldstate) |
2251 | n = 1; | 2232 | n = 1; |
2252 | else | 2233 | else |
2253 | n = 0; | 2234 | n = 0; |
2254 | return (n); | 2235 | return (n); |
2255 | } | 2236 | } |
2256 | 2237 | ||
2257 | int MoxaPortWriteData(int port, unsigned char * buffer, int len) | 2238 | static int MoxaPortWriteData(struct moxa_port *port, unsigned char *buffer, |
2239 | int len) | ||
2258 | { | 2240 | { |
2259 | int c, total, i; | 2241 | int c, total, i; |
2260 | ushort tail; | 2242 | ushort tail; |
@@ -2263,8 +2245,8 @@ int MoxaPortWriteData(int port, unsigned char * buffer, int len) | |||
2263 | ushort pageno, pageofs, bufhead; | 2245 | ushort pageno, pageofs, bufhead; |
2264 | void __iomem *baseAddr, *ofsAddr, *ofs; | 2246 | void __iomem *baseAddr, *ofsAddr, *ofs; |
2265 | 2247 | ||
2266 | ofsAddr = moxa_ports[port].tableAddr; | 2248 | ofsAddr = port->tableAddr; |
2267 | baseAddr = moxa_boards[port / MAX_PORTS_PER_BOARD].basemem; | 2249 | baseAddr = port->board->basemem; |
2268 | tx_mask = readw(ofsAddr + TX_mask); | 2250 | tx_mask = readw(ofsAddr + TX_mask); |
2269 | spage = readw(ofsAddr + Page_txb); | 2251 | spage = readw(ofsAddr + Page_txb); |
2270 | epage = readw(ofsAddr + EndPage_txb); | 2252 | epage = readw(ofsAddr + EndPage_txb); |
@@ -2274,7 +2256,7 @@ int MoxaPortWriteData(int port, unsigned char * buffer, int len) | |||
2274 | : (head - tail + tx_mask); | 2256 | : (head - tail + tx_mask); |
2275 | if (c > len) | 2257 | if (c > len) |
2276 | c = len; | 2258 | c = len; |
2277 | moxaLog.txcnt[port] += c; | 2259 | moxaLog.txcnt[port->tty->index] += c; |
2278 | total = c; | 2260 | total = c; |
2279 | if (spage == epage) { | 2261 | if (spage == epage) { |
2280 | bufhead = readw(ofsAddr + Ofs_txb); | 2262 | bufhead = readw(ofsAddr + Ofs_txb); |
@@ -2318,7 +2300,7 @@ int MoxaPortWriteData(int port, unsigned char * buffer, int len) | |||
2318 | return (total); | 2300 | return (total); |
2319 | } | 2301 | } |
2320 | 2302 | ||
2321 | int MoxaPortReadData(int port, struct tty_struct *tty) | 2303 | static int MoxaPortReadData(struct moxa_port *port, struct tty_struct *tty) |
2322 | { | 2304 | { |
2323 | register ushort head, pageofs; | 2305 | register ushort head, pageofs; |
2324 | int i, count, cnt, len, total, remain; | 2306 | int i, count, cnt, len, total, remain; |
@@ -2326,8 +2308,8 @@ int MoxaPortReadData(int port, struct tty_struct *tty) | |||
2326 | ushort pageno, bufhead; | 2308 | ushort pageno, bufhead; |
2327 | void __iomem *baseAddr, *ofsAddr, *ofs; | 2309 | void __iomem *baseAddr, *ofsAddr, *ofs; |
2328 | 2310 | ||
2329 | ofsAddr = moxa_ports[port].tableAddr; | 2311 | ofsAddr = port->tableAddr; |
2330 | baseAddr = moxa_boards[port / MAX_PORTS_PER_BOARD].basemem; | 2312 | baseAddr = port->board->basemem; |
2331 | head = readw(ofsAddr + RXrptr); | 2313 | head = readw(ofsAddr + RXrptr); |
2332 | tail = readw(ofsAddr + RXwptr); | 2314 | tail = readw(ofsAddr + RXwptr); |
2333 | rx_mask = readw(ofsAddr + RX_mask); | 2315 | rx_mask = readw(ofsAddr + RX_mask); |
@@ -2340,7 +2322,7 @@ int MoxaPortReadData(int port, struct tty_struct *tty) | |||
2340 | 2322 | ||
2341 | total = count; | 2323 | total = count; |
2342 | remain = count - total; | 2324 | remain = count - total; |
2343 | moxaLog.rxcnt[port] += total; | 2325 | moxaLog.rxcnt[port->tty->index] += total; |
2344 | count = total; | 2326 | count = total; |
2345 | if (spage == epage) { | 2327 | if (spage == epage) { |
2346 | bufhead = readw(ofsAddr + Ofs_rxb); | 2328 | bufhead = readw(ofsAddr + Ofs_rxb); |
@@ -2382,19 +2364,18 @@ int MoxaPortReadData(int port, struct tty_struct *tty) | |||
2382 | } | 2364 | } |
2383 | if ((readb(ofsAddr + FlagStat) & Xoff_state) && (remain < LowWater)) { | 2365 | if ((readb(ofsAddr + FlagStat) & Xoff_state) && (remain < LowWater)) { |
2384 | moxaLowWaterChk = 1; | 2366 | moxaLowWaterChk = 1; |
2385 | moxa_ports[port].lowChkFlag = 1; | 2367 | port->lowChkFlag = 1; |
2386 | } | 2368 | } |
2387 | return (total); | 2369 | return (total); |
2388 | } | 2370 | } |
2389 | 2371 | ||
2390 | 2372 | ||
2391 | int MoxaPortTxQueue(int port) | 2373 | static int MoxaPortTxQueue(struct moxa_port *port) |
2392 | { | 2374 | { |
2393 | void __iomem *ofsAddr; | 2375 | void __iomem *ofsAddr = port->tableAddr; |
2394 | ushort rptr, wptr, mask; | 2376 | ushort rptr, wptr, mask; |
2395 | int len; | 2377 | int len; |
2396 | 2378 | ||
2397 | ofsAddr = moxa_ports[port].tableAddr; | ||
2398 | rptr = readw(ofsAddr + TXrptr); | 2379 | rptr = readw(ofsAddr + TXrptr); |
2399 | wptr = readw(ofsAddr + TXwptr); | 2380 | wptr = readw(ofsAddr + TXwptr); |
2400 | mask = readw(ofsAddr + TX_mask); | 2381 | mask = readw(ofsAddr + TX_mask); |
@@ -2402,13 +2383,12 @@ int MoxaPortTxQueue(int port) | |||
2402 | return (len); | 2383 | return (len); |
2403 | } | 2384 | } |
2404 | 2385 | ||
2405 | int MoxaPortTxFree(int port) | 2386 | static int MoxaPortTxFree(struct moxa_port *port) |
2406 | { | 2387 | { |
2407 | void __iomem *ofsAddr; | 2388 | void __iomem *ofsAddr = port->tableAddr; |
2408 | ushort rptr, wptr, mask; | 2389 | ushort rptr, wptr, mask; |
2409 | int len; | 2390 | int len; |
2410 | 2391 | ||
2411 | ofsAddr = moxa_ports[port].tableAddr; | ||
2412 | rptr = readw(ofsAddr + TXrptr); | 2392 | rptr = readw(ofsAddr + TXrptr); |
2413 | wptr = readw(ofsAddr + TXwptr); | 2393 | wptr = readw(ofsAddr + TXwptr); |
2414 | mask = readw(ofsAddr + TX_mask); | 2394 | mask = readw(ofsAddr + TX_mask); |
@@ -2416,13 +2396,12 @@ int MoxaPortTxFree(int port) | |||
2416 | return (len); | 2396 | return (len); |
2417 | } | 2397 | } |
2418 | 2398 | ||
2419 | int MoxaPortRxQueue(int port) | 2399 | static int MoxaPortRxQueue(struct moxa_port *port) |
2420 | { | 2400 | { |
2421 | void __iomem *ofsAddr; | 2401 | void __iomem *ofsAddr = port->tableAddr; |
2422 | ushort rptr, wptr, mask; | 2402 | ushort rptr, wptr, mask; |
2423 | int len; | 2403 | int len; |
2424 | 2404 | ||
2425 | ofsAddr = moxa_ports[port].tableAddr; | ||
2426 | rptr = readw(ofsAddr + RXrptr); | 2405 | rptr = readw(ofsAddr + RXrptr); |
2427 | wptr = readw(ofsAddr + RXwptr); | 2406 | wptr = readw(ofsAddr + RXwptr); |
2428 | mask = readw(ofsAddr + RX_mask); | 2407 | mask = readw(ofsAddr + RX_mask); |
@@ -2431,37 +2410,30 @@ int MoxaPortRxQueue(int port) | |||
2431 | } | 2410 | } |
2432 | 2411 | ||
2433 | 2412 | ||
2434 | void MoxaPortTxDisable(int port) | 2413 | static void MoxaPortTxDisable(struct moxa_port *port) |
2435 | { | 2414 | { |
2436 | void __iomem *ofsAddr; | 2415 | moxafunc(port->tableAddr, FC_SetXoffState, Magic_code); |
2437 | |||
2438 | ofsAddr = moxa_ports[port].tableAddr; | ||
2439 | moxafunc(ofsAddr, FC_SetXoffState, Magic_code); | ||
2440 | } | 2416 | } |
2441 | 2417 | ||
2442 | void MoxaPortTxEnable(int port) | 2418 | static void MoxaPortTxEnable(struct moxa_port *port) |
2443 | { | 2419 | { |
2444 | void __iomem *ofsAddr; | 2420 | moxafunc(port->tableAddr, FC_SetXonState, Magic_code); |
2445 | |||
2446 | ofsAddr = moxa_ports[port].tableAddr; | ||
2447 | moxafunc(ofsAddr, FC_SetXonState, Magic_code); | ||
2448 | } | 2421 | } |
2449 | 2422 | ||
2450 | 2423 | ||
2451 | int MoxaPortResetBrkCnt(int port) | 2424 | static int MoxaPortResetBrkCnt(struct moxa_port *port) |
2452 | { | 2425 | { |
2453 | ushort cnt; | 2426 | ushort cnt; |
2454 | cnt = moxa_ports[port].breakCnt; | 2427 | cnt = port->breakCnt; |
2455 | moxa_ports[port].breakCnt = 0; | 2428 | port->breakCnt = 0; |
2456 | return (cnt); | 2429 | return (cnt); |
2457 | } | 2430 | } |
2458 | 2431 | ||
2459 | 2432 | ||
2460 | void MoxaPortSendBreak(int port, int ms100) | 2433 | static void MoxaPortSendBreak(struct moxa_port *port, int ms100) |
2461 | { | 2434 | { |
2462 | void __iomem *ofsAddr; | 2435 | void __iomem *ofsAddr = port->tableAddr; |
2463 | 2436 | ||
2464 | ofsAddr = moxa_ports[port].tableAddr; | ||
2465 | if (ms100) { | 2437 | if (ms100) { |
2466 | moxafunc(ofsAddr, FC_SendBreak, Magic_code); | 2438 | moxafunc(ofsAddr, FC_SendBreak, Magic_code); |
2467 | msleep(ms100 * 10); | 2439 | msleep(ms100 * 10); |
@@ -2479,7 +2451,7 @@ static int moxa_get_serial_info(struct moxa_port *info, | |||
2479 | 2451 | ||
2480 | memset(&tmp, 0, sizeof(tmp)); | 2452 | memset(&tmp, 0, sizeof(tmp)); |
2481 | tmp.type = info->type; | 2453 | tmp.type = info->type; |
2482 | tmp.line = info->port; | 2454 | tmp.line = info->tty->index; |
2483 | tmp.port = 0; | 2455 | tmp.port = 0; |
2484 | tmp.irq = 0; | 2456 | tmp.irq = 0; |
2485 | tmp.flags = info->asyncflags; | 2457 | tmp.flags = info->asyncflags; |
@@ -2522,9 +2494,9 @@ static int moxa_set_serial_info(struct moxa_port *info, | |||
2522 | new_serial.flags |= (info->asyncflags & ASYNC_FLAGS); | 2494 | new_serial.flags |= (info->asyncflags & ASYNC_FLAGS); |
2523 | 2495 | ||
2524 | if (new_serial.type == PORT_16550A) { | 2496 | if (new_serial.type == PORT_16550A) { |
2525 | MoxaSetFifo(info->port, 1); | 2497 | MoxaSetFifo(info, 1); |
2526 | } else { | 2498 | } else { |
2527 | MoxaSetFifo(info->port, 0); | 2499 | MoxaSetFifo(info, 0); |
2528 | } | 2500 | } |
2529 | 2501 | ||
2530 | info->type = new_serial.type; | 2502 | info->type = new_serial.type; |
@@ -2572,9 +2544,9 @@ static void moxa_low_water_check(void __iomem *ofsAddr) | |||
2572 | } | 2544 | } |
2573 | } | 2545 | } |
2574 | 2546 | ||
2575 | static void MoxaSetFifo(int port, int enable) | 2547 | static void MoxaSetFifo(struct moxa_port *port, int enable) |
2576 | { | 2548 | { |
2577 | void __iomem *ofsAddr = moxa_ports[port].tableAddr; | 2549 | void __iomem *ofsAddr = port->tableAddr; |
2578 | 2550 | ||
2579 | if (!enable) { | 2551 | if (!enable) { |
2580 | moxafunc(ofsAddr, FC_SetRxFIFOTrig, 0); | 2552 | moxafunc(ofsAddr, FC_SetRxFIFOTrig, 0); |