aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/sx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/sx.c')
-rw-r--r--drivers/char/sx.c115
1 files changed, 56 insertions, 59 deletions
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index b1a7a8cb65ea..b1239ee48b78 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -1,4 +1,3 @@
1
2/* sx.c -- driver for the Specialix SX series cards. 1/* sx.c -- driver for the Specialix SX series cards.
3 * 2 *
4 * This driver will also support the older SI, and XIO cards. 3 * This driver will also support the older SI, and XIO cards.
@@ -930,7 +929,7 @@ static int sx_set_real_termios(void *ptr)
930 929
931 func_enter2(); 930 func_enter2();
932 931
933 if (!port->gs.tty) 932 if (!port->gs.port.tty)
934 return 0; 933 return 0;
935 934
936 /* What is this doing here? -- REW 935 /* What is this doing here? -- REW
@@ -941,19 +940,19 @@ static int sx_set_real_termios(void *ptr)
941 940
942 sx_set_baud(port); 941 sx_set_baud(port);
943 942
944#define CFLAG port->gs.tty->termios->c_cflag 943#define CFLAG port->gs.port.tty->termios->c_cflag
945 sx_write_channel_byte(port, hi_mr1, 944 sx_write_channel_byte(port, hi_mr1,
946 (C_PARENB(port->gs.tty) ? MR1_WITH : MR1_NONE) | 945 (C_PARENB(port->gs.port.tty) ? MR1_WITH : MR1_NONE) |
947 (C_PARODD(port->gs.tty) ? MR1_ODD : MR1_EVEN) | 946 (C_PARODD(port->gs.port.tty) ? MR1_ODD : MR1_EVEN) |
948 (C_CRTSCTS(port->gs.tty) ? MR1_RTS_RXFLOW : 0) | 947 (C_CRTSCTS(port->gs.port.tty) ? MR1_RTS_RXFLOW : 0) |
949 (((CFLAG & CSIZE) == CS8) ? MR1_8_BITS : 0) | 948 (((CFLAG & CSIZE) == CS8) ? MR1_8_BITS : 0) |
950 (((CFLAG & CSIZE) == CS7) ? MR1_7_BITS : 0) | 949 (((CFLAG & CSIZE) == CS7) ? MR1_7_BITS : 0) |
951 (((CFLAG & CSIZE) == CS6) ? MR1_6_BITS : 0) | 950 (((CFLAG & CSIZE) == CS6) ? MR1_6_BITS : 0) |
952 (((CFLAG & CSIZE) == CS5) ? MR1_5_BITS : 0)); 951 (((CFLAG & CSIZE) == CS5) ? MR1_5_BITS : 0));
953 952
954 sx_write_channel_byte(port, hi_mr2, 953 sx_write_channel_byte(port, hi_mr2,
955 (C_CRTSCTS(port->gs.tty) ? MR2_CTS_TXFLOW : 0) | 954 (C_CRTSCTS(port->gs.port.tty) ? MR2_CTS_TXFLOW : 0) |
956 (C_CSTOPB(port->gs.tty) ? MR2_2_STOP : 955 (C_CSTOPB(port->gs.port.tty) ? MR2_2_STOP :
957 MR2_1_STOP)); 956 MR2_1_STOP));
958 957
959 switch (CFLAG & CSIZE) { 958 switch (CFLAG & CSIZE) {
@@ -976,44 +975,44 @@ static int sx_set_real_termios(void *ptr)
976 } 975 }
977 976
978 sx_write_channel_byte(port, hi_prtcl, 977 sx_write_channel_byte(port, hi_prtcl,
979 (I_IXON(port->gs.tty) ? SP_TXEN : 0) | 978 (I_IXON(port->gs.port.tty) ? SP_TXEN : 0) |
980 (I_IXOFF(port->gs.tty) ? SP_RXEN : 0) | 979 (I_IXOFF(port->gs.port.tty) ? SP_RXEN : 0) |
981 (I_IXANY(port->gs.tty) ? SP_TANY : 0) | SP_DCEN); 980 (I_IXANY(port->gs.port.tty) ? SP_TANY : 0) | SP_DCEN);
982 981
983 sx_write_channel_byte(port, hi_break, 982 sx_write_channel_byte(port, hi_break,
984 (I_IGNBRK(port->gs.tty) ? BR_IGN : 0 | 983 (I_IGNBRK(port->gs.port.tty) ? BR_IGN : 0 |
985 I_BRKINT(port->gs.tty) ? BR_INT : 0)); 984 I_BRKINT(port->gs.port.tty) ? BR_INT : 0));
986 985
987 sx_write_channel_byte(port, hi_txon, START_CHAR(port->gs.tty)); 986 sx_write_channel_byte(port, hi_txon, START_CHAR(port->gs.port.tty));
988 sx_write_channel_byte(port, hi_rxon, START_CHAR(port->gs.tty)); 987 sx_write_channel_byte(port, hi_rxon, START_CHAR(port->gs.port.tty));
989 sx_write_channel_byte(port, hi_txoff, STOP_CHAR(port->gs.tty)); 988 sx_write_channel_byte(port, hi_txoff, STOP_CHAR(port->gs.port.tty));
990 sx_write_channel_byte(port, hi_rxoff, STOP_CHAR(port->gs.tty)); 989 sx_write_channel_byte(port, hi_rxoff, STOP_CHAR(port->gs.port.tty));
991 990
992 sx_reconfigure_port(port); 991 sx_reconfigure_port(port);
993 992
994 /* Tell line discipline whether we will do input cooking */ 993 /* Tell line discipline whether we will do input cooking */
995 if (I_OTHER(port->gs.tty)) { 994 if (I_OTHER(port->gs.port.tty)) {
996 clear_bit(TTY_HW_COOK_IN, &port->gs.tty->flags); 995 clear_bit(TTY_HW_COOK_IN, &port->gs.port.tty->flags);
997 } else { 996 } else {
998 set_bit(TTY_HW_COOK_IN, &port->gs.tty->flags); 997 set_bit(TTY_HW_COOK_IN, &port->gs.port.tty->flags);
999 } 998 }
1000 sx_dprintk(SX_DEBUG_TERMIOS, "iflags: %x(%d) ", 999 sx_dprintk(SX_DEBUG_TERMIOS, "iflags: %x(%d) ",
1001 (unsigned int)port->gs.tty->termios->c_iflag, 1000 (unsigned int)port->gs.port.tty->termios->c_iflag,
1002 I_OTHER(port->gs.tty)); 1001 I_OTHER(port->gs.port.tty));
1003 1002
1004/* Tell line discipline whether we will do output cooking. 1003/* Tell line discipline whether we will do output cooking.
1005 * If OPOST is set and no other output flags are set then we can do output 1004 * If OPOST is set and no other output flags are set then we can do output
1006 * processing. Even if only *one* other flag in the O_OTHER group is set 1005 * processing. Even if only *one* other flag in the O_OTHER group is set
1007 * we do cooking in software. 1006 * we do cooking in software.
1008 */ 1007 */
1009 if (O_OPOST(port->gs.tty) && !O_OTHER(port->gs.tty)) { 1008 if (O_OPOST(port->gs.port.tty) && !O_OTHER(port->gs.port.tty)) {
1010 set_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags); 1009 set_bit(TTY_HW_COOK_OUT, &port->gs.port.tty->flags);
1011 } else { 1010 } else {
1012 clear_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags); 1011 clear_bit(TTY_HW_COOK_OUT, &port->gs.port.tty->flags);
1013 } 1012 }
1014 sx_dprintk(SX_DEBUG_TERMIOS, "oflags: %x(%d)\n", 1013 sx_dprintk(SX_DEBUG_TERMIOS, "oflags: %x(%d)\n",
1015 (unsigned int)port->gs.tty->termios->c_oflag, 1014 (unsigned int)port->gs.port.tty->termios->c_oflag,
1016 O_OTHER(port->gs.tty)); 1015 O_OTHER(port->gs.port.tty));
1017 /* port->c_dcd = sx_get_CD (port); */ 1016 /* port->c_dcd = sx_get_CD (port); */
1018 func_exit(); 1017 func_exit();
1019 return 0; 1018 return 0;
@@ -1102,8 +1101,8 @@ static void sx_transmit_chars(struct sx_port *port)
1102 sx_disable_tx_interrupts(port); 1101 sx_disable_tx_interrupts(port);
1103 } 1102 }
1104 1103
1105 if ((port->gs.xmit_cnt <= port->gs.wakeup_chars) && port->gs.tty) { 1104 if ((port->gs.xmit_cnt <= port->gs.wakeup_chars) && port->gs.port.tty) {
1106 tty_wakeup(port->gs.tty); 1105 tty_wakeup(port->gs.port.tty);
1107 sx_dprintk(SX_DEBUG_TRANSMIT, "Waking up.... ldisc (%d)....\n", 1106 sx_dprintk(SX_DEBUG_TRANSMIT, "Waking up.... ldisc (%d)....\n",
1108 port->gs.wakeup_chars); 1107 port->gs.wakeup_chars);
1109 } 1108 }
@@ -1126,7 +1125,7 @@ static inline void sx_receive_chars(struct sx_port *port)
1126 unsigned char *rp; 1125 unsigned char *rp;
1127 1126
1128 func_enter2(); 1127 func_enter2();
1129 tty = port->gs.tty; 1128 tty = port->gs.port.tty;
1130 while (1) { 1129 while (1) {
1131 rx_op = sx_read_channel_byte(port, hi_rxopos); 1130 rx_op = sx_read_channel_byte(port, hi_rxopos);
1132 c = (sx_read_channel_byte(port, hi_rxipos) - rx_op) & 0xff; 1131 c = (sx_read_channel_byte(port, hi_rxipos) - rx_op) & 0xff;
@@ -1211,12 +1210,12 @@ static inline void sx_check_modem_signals(struct sx_port *port)
1211 /* DCD went UP */ 1210 /* DCD went UP */
1212 if ((sx_read_channel_byte(port, hi_hstat) != 1211 if ((sx_read_channel_byte(port, hi_hstat) !=
1213 HS_IDLE_CLOSED) && 1212 HS_IDLE_CLOSED) &&
1214 !(port->gs.tty->termios-> 1213 !(port->gs.port.tty->termios->
1215 c_cflag & CLOCAL)) { 1214 c_cflag & CLOCAL)) {
1216 /* Are we blocking in open? */ 1215 /* Are we blocking in open? */
1217 sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD " 1216 sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD "
1218 "active, unblocking open\n"); 1217 "active, unblocking open\n");
1219 wake_up_interruptible(&port->gs. 1218 wake_up_interruptible(&port->gs.port.
1220 open_wait); 1219 open_wait);
1221 } else { 1220 } else {
1222 sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD " 1221 sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD "
@@ -1224,10 +1223,10 @@ static inline void sx_check_modem_signals(struct sx_port *port)
1224 } 1223 }
1225 } else { 1224 } else {
1226 /* DCD went down! */ 1225 /* DCD went down! */
1227 if (!(port->gs.tty->termios->c_cflag & CLOCAL)){ 1226 if (!(port->gs.port.tty->termios->c_cflag & CLOCAL)){
1228 sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD " 1227 sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD "
1229 "dropped. hanging up....\n"); 1228 "dropped. hanging up....\n");
1230 tty_hangup(port->gs.tty); 1229 tty_hangup(port->gs.port.tty);
1231 } else { 1230 } else {
1232 sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD " 1231 sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD "
1233 "dropped. ignoring.\n"); 1232 "dropped. ignoring.\n");
@@ -1325,7 +1324,7 @@ static irqreturn_t sx_interrupt(int irq, void *ptr)
1325 1324
1326 for (i = 0; i < board->nports; i++) { 1325 for (i = 0; i < board->nports; i++) {
1327 port = &board->ports[i]; 1326 port = &board->ports[i];
1328 if (port->gs.flags & GS_ACTIVE) { 1327 if (port->gs.port.flags & GS_ACTIVE) {
1329 if (sx_read_channel_byte(port, hi_state)) { 1328 if (sx_read_channel_byte(port, hi_state)) {
1330 sx_dprintk(SX_DEBUG_INTERRUPTS, "Port %d: " 1329 sx_dprintk(SX_DEBUG_INTERRUPTS, "Port %d: "
1331 "modem signal change?... \n",i); 1330 "modem signal change?... \n",i);
@@ -1334,7 +1333,7 @@ static irqreturn_t sx_interrupt(int irq, void *ptr)
1334 if (port->gs.xmit_cnt) { 1333 if (port->gs.xmit_cnt) {
1335 sx_transmit_chars(port); 1334 sx_transmit_chars(port);
1336 } 1335 }
1337 if (!(port->gs.flags & SX_RX_THROTTLE)) { 1336 if (!(port->gs.port.flags & SX_RX_THROTTLE)) {
1338 sx_receive_chars(port); 1337 sx_receive_chars(port);
1339 } 1338 }
1340 } 1339 }
@@ -1373,7 +1372,7 @@ static void sx_disable_tx_interrupts(void *ptr)
1373 struct sx_port *port = ptr; 1372 struct sx_port *port = ptr;
1374 func_enter2(); 1373 func_enter2();
1375 1374
1376 port->gs.flags &= ~GS_TX_INTEN; 1375 port->gs.port.flags &= ~GS_TX_INTEN;
1377 1376
1378 func_exit(); 1377 func_exit();
1379} 1378}
@@ -1394,7 +1393,7 @@ static void sx_enable_tx_interrupts(void *ptr)
1394 1393
1395 /* XXX Must be "HIGH_WATER" for SI card according to doc. */ 1394 /* XXX Must be "HIGH_WATER" for SI card according to doc. */
1396 if (data_in_buffer < LOW_WATER) 1395 if (data_in_buffer < LOW_WATER)
1397 port->gs.flags &= ~GS_TX_INTEN; 1396 port->gs.port.flags &= ~GS_TX_INTEN;
1398 1397
1399 func_exit(); 1398 func_exit();
1400} 1399}
@@ -1442,8 +1441,8 @@ static void sx_shutdown_port(void *ptr)
1442 1441
1443 func_enter(); 1442 func_enter();
1444 1443
1445 port->gs.flags &= ~GS_ACTIVE; 1444 port->gs.port.flags &= ~GS_ACTIVE;
1446 if (port->gs.tty && (port->gs.tty->termios->c_cflag & HUPCL)) { 1445 if (port->gs.port.tty && (port->gs.port.tty->termios->c_cflag & HUPCL)) {
1447 sx_setsignals(port, 0, 0); 1446 sx_setsignals(port, 0, 0);
1448 sx_reconfigure_port(port); 1447 sx_reconfigure_port(port);
1449 } 1448 }
@@ -1485,8 +1484,8 @@ static int sx_open(struct tty_struct *tty, struct file *filp)
1485 spin_lock_irqsave(&port->gs.driver_lock, flags); 1484 spin_lock_irqsave(&port->gs.driver_lock, flags);
1486 1485
1487 tty->driver_data = port; 1486 tty->driver_data = port;
1488 port->gs.tty = tty; 1487 port->gs.port.tty = tty;
1489 port->gs.count++; 1488 port->gs.port.count++;
1490 spin_unlock_irqrestore(&port->gs.driver_lock, flags); 1489 spin_unlock_irqrestore(&port->gs.driver_lock, flags);
1491 1490
1492 sx_dprintk(SX_DEBUG_OPEN, "starting port\n"); 1491 sx_dprintk(SX_DEBUG_OPEN, "starting port\n");
@@ -1497,12 +1496,12 @@ static int sx_open(struct tty_struct *tty, struct file *filp)
1497 retval = gs_init_port(&port->gs); 1496 retval = gs_init_port(&port->gs);
1498 sx_dprintk(SX_DEBUG_OPEN, "done gs_init\n"); 1497 sx_dprintk(SX_DEBUG_OPEN, "done gs_init\n");
1499 if (retval) { 1498 if (retval) {
1500 port->gs.count--; 1499 port->gs.port.count--;
1501 return retval; 1500 return retval;
1502 } 1501 }
1503 1502
1504 port->gs.flags |= GS_ACTIVE; 1503 port->gs.port.flags |= GS_ACTIVE;
1505 if (port->gs.count <= 1) 1504 if (port->gs.port.count <= 1)
1506 sx_setsignals(port, 1, 1); 1505 sx_setsignals(port, 1, 1);
1507 1506
1508#if 0 1507#if 0
@@ -1513,12 +1512,12 @@ static int sx_open(struct tty_struct *tty, struct file *filp)
1513 my_hd_io(port->board->base + port->ch_base, sizeof(*port)); 1512 my_hd_io(port->board->base + port->ch_base, sizeof(*port));
1514#endif 1513#endif
1515 1514
1516 if (port->gs.count <= 1) { 1515 if (port->gs.port.count <= 1) {
1517 if (sx_send_command(port, HS_LOPEN, -1, HS_IDLE_OPEN) != 1) { 1516 if (sx_send_command(port, HS_LOPEN, -1, HS_IDLE_OPEN) != 1) {
1518 printk(KERN_ERR "sx: Card didn't respond to LOPEN " 1517 printk(KERN_ERR "sx: Card didn't respond to LOPEN "
1519 "command.\n"); 1518 "command.\n");
1520 spin_lock_irqsave(&port->gs.driver_lock, flags); 1519 spin_lock_irqsave(&port->gs.driver_lock, flags);
1521 port->gs.count--; 1520 port->gs.port.count--;
1522 spin_unlock_irqrestore(&port->gs.driver_lock, flags); 1521 spin_unlock_irqrestore(&port->gs.driver_lock, flags);
1523 return -EIO; 1522 return -EIO;
1524 } 1523 }
@@ -1526,11 +1525,11 @@ static int sx_open(struct tty_struct *tty, struct file *filp)
1526 1525
1527 retval = gs_block_til_ready(port, filp); 1526 retval = gs_block_til_ready(port, filp);
1528 sx_dprintk(SX_DEBUG_OPEN, "Block til ready returned %d. Count=%d\n", 1527 sx_dprintk(SX_DEBUG_OPEN, "Block til ready returned %d. Count=%d\n",
1529 retval, port->gs.count); 1528 retval, port->gs.port.count);
1530 1529
1531 if (retval) { 1530 if (retval) {
1532/* 1531/*
1533 * Don't lower gs.count here because sx_close() will be called later 1532 * Don't lower gs.port.count here because sx_close() will be called later
1534 */ 1533 */
1535 1534
1536 return retval; 1535 return retval;
@@ -1571,14 +1570,14 @@ static void sx_close(void *ptr)
1571 } 1570 }
1572 1571
1573 sx_dprintk(SX_DEBUG_CLOSE, "waited %d jiffies for close. count=%d\n", 1572 sx_dprintk(SX_DEBUG_CLOSE, "waited %d jiffies for close. count=%d\n",
1574 5 * HZ - to - 1, port->gs.count); 1573 5 * HZ - to - 1, port->gs.port.count);
1575 1574
1576 if (port->gs.count) { 1575 if (port->gs.port.count) {
1577 sx_dprintk(SX_DEBUG_CLOSE, "WARNING port count:%d\n", 1576 sx_dprintk(SX_DEBUG_CLOSE, "WARNING port count:%d\n",
1578 port->gs.count); 1577 port->gs.port.count);
1579 /*printk("%s SETTING port count to zero: %p count: %d\n", 1578 /*printk("%s SETTING port count to zero: %p count: %d\n",
1580 __func__, port, port->gs.count); 1579 __func__, port, port->gs.port.count);
1581 port->gs.count = 0;*/ 1580 port->gs.port.count = 0;*/
1582 } 1581 }
1583 1582
1584 func_exit(); 1583 func_exit();
@@ -1939,7 +1938,7 @@ static void sx_throttle(struct tty_struct *tty)
1939 * control then throttle the port. 1938 * control then throttle the port.
1940 */ 1939 */
1941 if ((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty))) { 1940 if ((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty))) {
1942 port->gs.flags |= SX_RX_THROTTLE; 1941 port->gs.port.flags |= SX_RX_THROTTLE;
1943 } 1942 }
1944 func_exit(); 1943 func_exit();
1945} 1944}
@@ -1953,7 +1952,7 @@ static void sx_unthrottle(struct tty_struct *tty)
1953 * this port in case we disabled flow control while the port 1952 * this port in case we disabled flow control while the port
1954 * was throttled 1953 * was throttled
1955 */ 1954 */
1956 port->gs.flags &= ~SX_RX_THROTTLE; 1955 port->gs.port.flags &= ~SX_RX_THROTTLE;
1957 func_exit(); 1956 func_exit();
1958 return; 1957 return;
1959} 1958}
@@ -2408,9 +2407,7 @@ static int sx_init_portstructs(int nboards, int nports)
2408 /* 2407 /*
2409 * Initializing wait queue 2408 * Initializing wait queue
2410 */ 2409 */
2411 init_waitqueue_head(&port->gs.open_wait); 2410 tty_port_init(&port->gs.port);
2412 init_waitqueue_head(&port->gs.close_wait);
2413
2414 port++; 2411 port++;
2415 } 2412 }
2416 } 2413 }