aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/riscom8.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/riscom8.c')
-rw-r--r--drivers/char/riscom8.c214
1 files changed, 88 insertions, 126 deletions
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index f073c710ab8d..2c6c8f33d6b4 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -322,7 +322,7 @@ static struct riscom_port *rc_get_port(struct riscom_board const *bp,
322 channel = rc_in(bp, CD180_GICR) >> GICR_CHAN_OFF; 322 channel = rc_in(bp, CD180_GICR) >> GICR_CHAN_OFF;
323 if (channel < CD180_NCH) { 323 if (channel < CD180_NCH) {
324 port = &rc_port[board_No(bp) * RC_NPORT + channel]; 324 port = &rc_port[board_No(bp) * RC_NPORT + channel];
325 if (port->flags & ASYNC_INITIALIZED) 325 if (port->port.flags & ASYNC_INITIALIZED)
326 return port; 326 return port;
327 } 327 }
328 printk(KERN_ERR "rc%d: %s interrupt from invalid port %d\n", 328 printk(KERN_ERR "rc%d: %s interrupt from invalid port %d\n",
@@ -341,7 +341,7 @@ static void rc_receive_exc(struct riscom_board const *bp)
341 if (port == NULL) 341 if (port == NULL)
342 return; 342 return;
343 343
344 tty = port->tty; 344 tty = port->port.tty;
345 345
346#ifdef RC_REPORT_OVERRUN 346#ifdef RC_REPORT_OVERRUN
347 status = rc_in(bp, CD180_RCSR); 347 status = rc_in(bp, CD180_RCSR);
@@ -364,7 +364,7 @@ static void rc_receive_exc(struct riscom_board const *bp)
364 printk(KERN_INFO "rc%d: port %d: Handling break...\n", 364 printk(KERN_INFO "rc%d: port %d: Handling break...\n",
365 board_No(bp), port_No(port)); 365 board_No(bp), port_No(port));
366 flag = TTY_BREAK; 366 flag = TTY_BREAK;
367 if (port->flags & ASYNC_SAK) 367 if (port->port.flags & ASYNC_SAK)
368 do_SAK(tty); 368 do_SAK(tty);
369 369
370 } else if (status & RCSR_PE) 370 } else if (status & RCSR_PE)
@@ -392,7 +392,7 @@ static void rc_receive(struct riscom_board const *bp)
392 if (port == NULL) 392 if (port == NULL)
393 return; 393 return;
394 394
395 tty = port->tty; 395 tty = port->port.tty;
396 396
397 count = rc_in(bp, CD180_RDCR); 397 count = rc_in(bp, CD180_RDCR);
398 398
@@ -422,7 +422,7 @@ static void rc_transmit(struct riscom_board const *bp)
422 if (port == NULL) 422 if (port == NULL)
423 return; 423 return;
424 424
425 tty = port->tty; 425 tty = port->port.tty;
426 426
427 if (port->IER & IER_TXEMPTY) { 427 if (port->IER & IER_TXEMPTY) {
428 /* FIFO drained */ 428 /* FIFO drained */
@@ -467,7 +467,7 @@ static void rc_transmit(struct riscom_board const *bp)
467 467
468 count = CD180_NFIFO; 468 count = CD180_NFIFO;
469 do { 469 do {
470 rc_out(bp, CD180_TDR, port->xmit_buf[port->xmit_tail++]); 470 rc_out(bp, CD180_TDR, port->port.xmit_buf[port->xmit_tail++]);
471 port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE-1); 471 port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE-1);
472 if (--port->xmit_cnt <= 0) 472 if (--port->xmit_cnt <= 0)
473 break; 473 break;
@@ -492,12 +492,12 @@ static void rc_check_modem(struct riscom_board const *bp)
492 if (port == NULL) 492 if (port == NULL)
493 return; 493 return;
494 494
495 tty = port->tty; 495 tty = port->port.tty;
496 496
497 mcr = rc_in(bp, CD180_MCR); 497 mcr = rc_in(bp, CD180_MCR);
498 if (mcr & MCR_CDCHG) { 498 if (mcr & MCR_CDCHG) {
499 if (rc_in(bp, CD180_MSVR) & MSVR_CD) 499 if (rc_in(bp, CD180_MSVR) & MSVR_CD)
500 wake_up_interruptible(&port->open_wait); 500 wake_up_interruptible(&port->port.open_wait);
501 else 501 else
502 tty_hangup(tty); 502 tty_hangup(tty);
503 } 503 }
@@ -632,15 +632,12 @@ static void rc_shutdown_board(struct riscom_board *bp)
632 */ 632 */
633static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port) 633static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
634{ 634{
635 struct tty_struct *tty = port->tty; 635 struct tty_struct *tty = port->port.tty;
636 unsigned long baud; 636 unsigned long baud;
637 long tmp; 637 long tmp;
638 unsigned char cor1 = 0, cor3 = 0; 638 unsigned char cor1 = 0, cor3 = 0;
639 unsigned char mcor1 = 0, mcor2 = 0; 639 unsigned char mcor1 = 0, mcor2 = 0;
640 640
641 if (tty == NULL || tty->termios == NULL)
642 return;
643
644 port->IER = 0; 641 port->IER = 0;
645 port->COR2 = 0; 642 port->COR2 = 0;
646 port->MSVR = MSVR_RTS; 643 port->MSVR = MSVR_RTS;
@@ -786,39 +783,30 @@ static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
786{ 783{
787 unsigned long flags; 784 unsigned long flags;
788 785
789 if (port->flags & ASYNC_INITIALIZED) 786 if (port->port.flags & ASYNC_INITIALIZED)
790 return 0; 787 return 0;
791 788
792 if (!port->xmit_buf) { 789 if (tty_port_alloc_xmit_buf(&port->port) < 0)
793 /* We may sleep in get_zeroed_page() */ 790 return -ENOMEM;
794 unsigned long tmp = get_zeroed_page(GFP_KERNEL); 791
795 if (tmp == 0)
796 return -ENOMEM;
797 if (port->xmit_buf)
798 free_page(tmp);
799 else
800 port->xmit_buf = (unsigned char *) tmp;
801 }
802 spin_lock_irqsave(&riscom_lock, flags); 792 spin_lock_irqsave(&riscom_lock, flags);
803 793
804 if (port->tty) 794 clear_bit(TTY_IO_ERROR, &port->port.tty->flags);
805 clear_bit(TTY_IO_ERROR, &port->tty->flags); 795 if (port->port.count == 1)
806 if (port->count == 1)
807 bp->count++; 796 bp->count++;
808 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; 797 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
809 rc_change_speed(bp, port); 798 rc_change_speed(bp, port);
810 port->flags |= ASYNC_INITIALIZED; 799 port->port.flags |= ASYNC_INITIALIZED;
811 800
812 spin_unlock_irqrestore(&riscom_lock, flags); 801 spin_unlock_irqrestore(&riscom_lock, flags);
813 return 0; 802 return 0;
814} 803}
815 804
816/* Must be called with interrupts disabled */ 805/* Must be called with interrupts disabled */
817static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port) 806static void rc_shutdown_port(struct tty_struct *tty,
807 struct riscom_board *bp, struct riscom_port *port)
818{ 808{
819 struct tty_struct *tty; 809 if (!(port->port.flags & ASYNC_INITIALIZED))
820
821 if (!(port->flags & ASYNC_INITIALIZED))
822 return; 810 return;
823 811
824#ifdef RC_REPORT_OVERRUN 812#ifdef RC_REPORT_OVERRUN
@@ -836,14 +824,8 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
836 printk("].\n"); 824 printk("].\n");
837 } 825 }
838#endif 826#endif
839 if (port->xmit_buf) { 827 tty_port_free_xmit_buf(&port->port);
840 free_page((unsigned long) port->xmit_buf); 828 if (C_HUPCL(tty)) {
841 port->xmit_buf = NULL;
842 }
843
844 tty = port->tty;
845
846 if (tty == NULL || C_HUPCL(tty)) {
847 /* Drop DTR */ 829 /* Drop DTR */
848 bp->DTR |= (1u << port_No(port)); 830 bp->DTR |= (1u << port_No(port));
849 rc_out(bp, RC_DTR, bp->DTR); 831 rc_out(bp, RC_DTR, bp->DTR);
@@ -858,9 +840,8 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
858 port->IER = 0; 840 port->IER = 0;
859 rc_out(bp, CD180_IER, port->IER); 841 rc_out(bp, CD180_IER, port->IER);
860 842
861 if (tty) 843 set_bit(TTY_IO_ERROR, &tty->flags);
862 set_bit(TTY_IO_ERROR, &tty->flags); 844 port->port.flags &= ~ASYNC_INITIALIZED;
863 port->flags &= ~ASYNC_INITIALIZED;
864 845
865 if (--bp->count < 0) { 846 if (--bp->count < 0) {
866 printk(KERN_INFO "rc%d: rc_shutdown_port: " 847 printk(KERN_INFO "rc%d: rc_shutdown_port: "
@@ -890,9 +871,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
890 * If the device is in the middle of being closed, then block 871 * If the device is in the middle of being closed, then block
891 * until it's done, and then try again. 872 * until it's done, and then try again.
892 */ 873 */
893 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { 874 if (tty_hung_up_p(filp) || port->port.flags & ASYNC_CLOSING) {
894 interruptible_sleep_on(&port->close_wait); 875 interruptible_sleep_on(&port->port.close_wait);
895 if (port->flags & ASYNC_HUP_NOTIFY) 876 if (port->port.flags & ASYNC_HUP_NOTIFY)
896 return -EAGAIN; 877 return -EAGAIN;
897 else 878 else
898 return -ERESTARTSYS; 879 return -ERESTARTSYS;
@@ -904,7 +885,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
904 */ 885 */
905 if ((filp->f_flags & O_NONBLOCK) || 886 if ((filp->f_flags & O_NONBLOCK) ||
906 (tty->flags & (1 << TTY_IO_ERROR))) { 887 (tty->flags & (1 << TTY_IO_ERROR))) {
907 port->flags |= ASYNC_NORMAL_ACTIVE; 888 port->port.flags |= ASYNC_NORMAL_ACTIVE;
908 return 0; 889 return 0;
909 } 890 }
910 891
@@ -919,16 +900,16 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
919 * exit, either normal or abnormal. 900 * exit, either normal or abnormal.
920 */ 901 */
921 retval = 0; 902 retval = 0;
922 add_wait_queue(&port->open_wait, &wait); 903 add_wait_queue(&port->port.open_wait, &wait);
923 904
924 spin_lock_irqsave(&riscom_lock, flags); 905 spin_lock_irqsave(&riscom_lock, flags);
925 906
926 if (!tty_hung_up_p(filp)) 907 if (!tty_hung_up_p(filp))
927 port->count--; 908 port->port.count--;
928 909
929 spin_unlock_irqrestore(&riscom_lock, flags); 910 spin_unlock_irqrestore(&riscom_lock, flags);
930 911
931 port->blocked_open++; 912 port->port.blocked_open++;
932 while (1) { 913 while (1) {
933 spin_lock_irqsave(&riscom_lock, flags); 914 spin_lock_irqsave(&riscom_lock, flags);
934 915
@@ -942,14 +923,14 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
942 923
943 set_current_state(TASK_INTERRUPTIBLE); 924 set_current_state(TASK_INTERRUPTIBLE);
944 if (tty_hung_up_p(filp) || 925 if (tty_hung_up_p(filp) ||
945 !(port->flags & ASYNC_INITIALIZED)) { 926 !(port->port.flags & ASYNC_INITIALIZED)) {
946 if (port->flags & ASYNC_HUP_NOTIFY) 927 if (port->port.flags & ASYNC_HUP_NOTIFY)
947 retval = -EAGAIN; 928 retval = -EAGAIN;
948 else 929 else
949 retval = -ERESTARTSYS; 930 retval = -ERESTARTSYS;
950 break; 931 break;
951 } 932 }
952 if (!(port->flags & ASYNC_CLOSING) && 933 if (!(port->port.flags & ASYNC_CLOSING) &&
953 (do_clocal || CD)) 934 (do_clocal || CD))
954 break; 935 break;
955 if (signal_pending(current)) { 936 if (signal_pending(current)) {
@@ -959,14 +940,14 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
959 schedule(); 940 schedule();
960 } 941 }
961 __set_current_state(TASK_RUNNING); 942 __set_current_state(TASK_RUNNING);
962 remove_wait_queue(&port->open_wait, &wait); 943 remove_wait_queue(&port->port.open_wait, &wait);
963 if (!tty_hung_up_p(filp)) 944 if (!tty_hung_up_p(filp))
964 port->count++; 945 port->port.count++;
965 port->blocked_open--; 946 port->port.blocked_open--;
966 if (retval) 947 if (retval)
967 return retval; 948 return retval;
968 949
969 port->flags |= ASYNC_NORMAL_ACTIVE; 950 port->port.flags |= ASYNC_NORMAL_ACTIVE;
970 return 0; 951 return 0;
971} 952}
972 953
@@ -990,9 +971,9 @@ static int rc_open(struct tty_struct *tty, struct file *filp)
990 if (error) 971 if (error)
991 return error; 972 return error;
992 973
993 port->count++; 974 port->port.count++;
994 tty->driver_data = port; 975 tty->driver_data = port;
995 port->tty = tty; 976 port->port.tty = tty;
996 977
997 error = rc_setup_port(bp, port); 978 error = rc_setup_port(bp, port);
998 if (error == 0) 979 if (error == 0)
@@ -1031,28 +1012,28 @@ static void rc_close(struct tty_struct *tty, struct file *filp)
1031 goto out; 1012 goto out;
1032 1013
1033 bp = port_Board(port); 1014 bp = port_Board(port);
1034 if ((tty->count == 1) && (port->count != 1)) { 1015 if ((tty->count == 1) && (port->port.count != 1)) {
1035 printk(KERN_INFO "rc%d: rc_close: bad port count;" 1016 printk(KERN_INFO "rc%d: rc_close: bad port count;"
1036 " tty->count is 1, port count is %d\n", 1017 " tty->count is 1, port count is %d\n",
1037 board_No(bp), port->count); 1018 board_No(bp), port->port.count);
1038 port->count = 1; 1019 port->port.count = 1;
1039 } 1020 }
1040 if (--port->count < 0) { 1021 if (--port->port.count < 0) {
1041 printk(KERN_INFO "rc%d: rc_close: bad port count " 1022 printk(KERN_INFO "rc%d: rc_close: bad port count "
1042 "for tty%d: %d\n", 1023 "for tty%d: %d\n",
1043 board_No(bp), port_No(port), port->count); 1024 board_No(bp), port_No(port), port->port.count);
1044 port->count = 0; 1025 port->port.count = 0;
1045 } 1026 }
1046 if (port->count) 1027 if (port->port.count)
1047 goto out; 1028 goto out;
1048 port->flags |= ASYNC_CLOSING; 1029 port->port.flags |= ASYNC_CLOSING;
1049 /* 1030 /*
1050 * Now we wait for the transmit buffer to clear; and we notify 1031 * Now we wait for the transmit buffer to clear; and we notify
1051 * the line discipline to only process XON/XOFF characters. 1032 * the line discipline to only process XON/XOFF characters.
1052 */ 1033 */
1053 tty->closing = 1; 1034 tty->closing = 1;
1054 if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) 1035 if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
1055 tty_wait_until_sent(tty, port->closing_wait); 1036 tty_wait_until_sent(tty, port->port.closing_wait);
1056 /* 1037 /*
1057 * At this point we stop accepting input. To do this, we 1038 * At this point we stop accepting input. To do this, we
1058 * disable the receive line status interrupts, and tell the 1039 * disable the receive line status interrupts, and tell the
@@ -1060,7 +1041,7 @@ static void rc_close(struct tty_struct *tty, struct file *filp)
1060 * line status register. 1041 * line status register.
1061 */ 1042 */
1062 port->IER &= ~IER_RXD; 1043 port->IER &= ~IER_RXD;
1063 if (port->flags & ASYNC_INITIALIZED) { 1044 if (port->port.flags & ASYNC_INITIALIZED) {
1064 port->IER &= ~IER_TXRDY; 1045 port->IER &= ~IER_TXRDY;
1065 port->IER |= IER_TXEMPTY; 1046 port->IER |= IER_TXEMPTY;
1066 rc_out(bp, CD180_CAR, port_No(port)); 1047 rc_out(bp, CD180_CAR, port_No(port));
@@ -1077,19 +1058,19 @@ static void rc_close(struct tty_struct *tty, struct file *filp)
1077 break; 1058 break;
1078 } 1059 }
1079 } 1060 }
1080 rc_shutdown_port(bp, port); 1061 rc_shutdown_port(tty, bp, port);
1081 rc_flush_buffer(tty); 1062 rc_flush_buffer(tty);
1082 tty_ldisc_flush(tty); 1063 tty_ldisc_flush(tty);
1083 1064
1084 tty->closing = 0; 1065 tty->closing = 0;
1085 port->tty = NULL; 1066 port->port.tty = NULL;
1086 if (port->blocked_open) { 1067 if (port->port.blocked_open) {
1087 if (port->close_delay) 1068 if (port->port.close_delay)
1088 msleep_interruptible(jiffies_to_msecs(port->close_delay)); 1069 msleep_interruptible(jiffies_to_msecs(port->port.close_delay));
1089 wake_up_interruptible(&port->open_wait); 1070 wake_up_interruptible(&port->port.open_wait);
1090 } 1071 }
1091 port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 1072 port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
1092 wake_up_interruptible(&port->close_wait); 1073 wake_up_interruptible(&port->port.close_wait);
1093 1074
1094out: 1075out:
1095 spin_unlock_irqrestore(&riscom_lock, flags); 1076 spin_unlock_irqrestore(&riscom_lock, flags);
@@ -1108,9 +1089,6 @@ static int rc_write(struct tty_struct *tty,
1108 1089
1109 bp = port_Board(port); 1090 bp = port_Board(port);
1110 1091
1111 if (!tty || !port->xmit_buf)
1112 return 0;
1113
1114 while (1) { 1092 while (1) {
1115 spin_lock_irqsave(&riscom_lock, flags); 1093 spin_lock_irqsave(&riscom_lock, flags);
1116 1094
@@ -1119,7 +1097,7 @@ static int rc_write(struct tty_struct *tty,
1119 if (c <= 0) 1097 if (c <= 0)
1120 break; /* lock continues to be held */ 1098 break; /* lock continues to be held */
1121 1099
1122 memcpy(port->xmit_buf + port->xmit_head, buf, c); 1100 memcpy(port->port.xmit_buf + port->xmit_head, buf, c);
1123 port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1); 1101 port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
1124 port->xmit_cnt += c; 1102 port->xmit_cnt += c;
1125 1103
@@ -1151,15 +1129,12 @@ static int rc_put_char(struct tty_struct *tty, unsigned char ch)
1151 if (rc_paranoia_check(port, tty->name, "rc_put_char")) 1129 if (rc_paranoia_check(port, tty->name, "rc_put_char"))
1152 return 0; 1130 return 0;
1153 1131
1154 if (!tty || !port->xmit_buf)
1155 return 0;
1156
1157 spin_lock_irqsave(&riscom_lock, flags); 1132 spin_lock_irqsave(&riscom_lock, flags);
1158 1133
1159 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) 1134 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
1160 goto out; 1135 goto out;
1161 1136
1162 port->xmit_buf[port->xmit_head++] = ch; 1137 port->port.xmit_buf[port->xmit_head++] = ch;
1163 port->xmit_head &= SERIAL_XMIT_SIZE - 1; 1138 port->xmit_head &= SERIAL_XMIT_SIZE - 1;
1164 port->xmit_cnt++; 1139 port->xmit_cnt++;
1165 ret = 1; 1140 ret = 1;
@@ -1177,8 +1152,7 @@ static void rc_flush_chars(struct tty_struct *tty)
1177 if (rc_paranoia_check(port, tty->name, "rc_flush_chars")) 1152 if (rc_paranoia_check(port, tty->name, "rc_flush_chars"))
1178 return; 1153 return;
1179 1154
1180 if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || 1155 if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped)
1181 !port->xmit_buf)
1182 return; 1156 return;
1183 1157
1184 spin_lock_irqsave(&riscom_lock, flags); 1158 spin_lock_irqsave(&riscom_lock, flags);
@@ -1276,11 +1250,15 @@ static int rc_tiocmset(struct tty_struct *tty, struct file *file,
1276 return 0; 1250 return 0;
1277} 1251}
1278 1252
1279static void rc_send_break(struct riscom_port *port, unsigned long length) 1253static int rc_send_break(struct tty_struct *tty, int length)
1280{ 1254{
1255 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1281 struct riscom_board *bp = port_Board(port); 1256 struct riscom_board *bp = port_Board(port);
1282 unsigned long flags; 1257 unsigned long flags;
1283 1258
1259 if (length == 0 || length == -1)
1260 return -EOPNOTSUPP;
1261
1284 spin_lock_irqsave(&riscom_lock, flags); 1262 spin_lock_irqsave(&riscom_lock, flags);
1285 1263
1286 port->break_length = RISCOM_TPS / HZ * length; 1264 port->break_length = RISCOM_TPS / HZ * length;
@@ -1294,6 +1272,7 @@ static void rc_send_break(struct riscom_port *port, unsigned long length)
1294 rc_wait_CCR(bp); 1272 rc_wait_CCR(bp);
1295 1273
1296 spin_unlock_irqrestore(&riscom_lock, flags); 1274 spin_unlock_irqrestore(&riscom_lock, flags);
1275 return 0;
1297} 1276}
1298 1277
1299static int rc_set_serial_info(struct riscom_port *port, 1278static int rc_set_serial_info(struct riscom_port *port,
@@ -1317,22 +1296,22 @@ static int rc_set_serial_info(struct riscom_port *port,
1317 return -EINVAL; 1296 return -EINVAL;
1318#endif 1297#endif
1319 1298
1320 change_speed = ((port->flags & ASYNC_SPD_MASK) != 1299 change_speed = ((port->port.flags & ASYNC_SPD_MASK) !=
1321 (tmp.flags & ASYNC_SPD_MASK)); 1300 (tmp.flags & ASYNC_SPD_MASK));
1322 1301
1323 if (!capable(CAP_SYS_ADMIN)) { 1302 if (!capable(CAP_SYS_ADMIN)) {
1324 if ((tmp.close_delay != port->close_delay) || 1303 if ((tmp.close_delay != port->port.close_delay) ||
1325 (tmp.closing_wait != port->closing_wait) || 1304 (tmp.closing_wait != port->port.closing_wait) ||
1326 ((tmp.flags & ~ASYNC_USR_MASK) != 1305 ((tmp.flags & ~ASYNC_USR_MASK) !=
1327 (port->flags & ~ASYNC_USR_MASK))) 1306 (port->port.flags & ~ASYNC_USR_MASK)))
1328 return -EPERM; 1307 return -EPERM;
1329 port->flags = ((port->flags & ~ASYNC_USR_MASK) | 1308 port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
1330 (tmp.flags & ASYNC_USR_MASK)); 1309 (tmp.flags & ASYNC_USR_MASK));
1331 } else { 1310 } else {
1332 port->flags = ((port->flags & ~ASYNC_FLAGS) | 1311 port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) |
1333 (tmp.flags & ASYNC_FLAGS)); 1312 (tmp.flags & ASYNC_FLAGS));
1334 port->close_delay = tmp.close_delay; 1313 port->port.close_delay = tmp.close_delay;
1335 port->closing_wait = tmp.closing_wait; 1314 port->port.closing_wait = tmp.closing_wait;
1336 } 1315 }
1337 if (change_speed) { 1316 if (change_speed) {
1338 unsigned long flags; 1317 unsigned long flags;
@@ -1355,10 +1334,10 @@ static int rc_get_serial_info(struct riscom_port *port,
1355 tmp.line = port - rc_port; 1334 tmp.line = port - rc_port;
1356 tmp.port = bp->base; 1335 tmp.port = bp->base;
1357 tmp.irq = bp->irq; 1336 tmp.irq = bp->irq;
1358 tmp.flags = port->flags; 1337 tmp.flags = port->port.flags;
1359 tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC; 1338 tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC;
1360 tmp.close_delay = port->close_delay * HZ/100; 1339 tmp.close_delay = port->port.close_delay * HZ/100;
1361 tmp.closing_wait = port->closing_wait * HZ/100; 1340 tmp.closing_wait = port->port.closing_wait * HZ/100;
1362 tmp.xmit_fifo_size = CD180_NFIFO; 1341 tmp.xmit_fifo_size = CD180_NFIFO;
1363 return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0; 1342 return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0;
1364} 1343}
@@ -1368,27 +1347,12 @@ static int rc_ioctl(struct tty_struct *tty, struct file *filp,
1368{ 1347{
1369 struct riscom_port *port = (struct riscom_port *)tty->driver_data; 1348 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1370 void __user *argp = (void __user *)arg; 1349 void __user *argp = (void __user *)arg;
1371 int retval = 0; 1350 int retval;
1372 1351
1373 if (rc_paranoia_check(port, tty->name, "rc_ioctl")) 1352 if (rc_paranoia_check(port, tty->name, "rc_ioctl"))
1374 return -ENODEV; 1353 return -ENODEV;
1375 1354
1376 switch (cmd) { 1355 switch (cmd) {
1377 case TCSBRK: /* SVID version: non-zero arg --> no break */
1378 retval = tty_check_change(tty);
1379 if (retval)
1380 return retval;
1381 tty_wait_until_sent(tty, 0);
1382 if (!arg)
1383 rc_send_break(port, HZ/4); /* 1/4 second */
1384 break;
1385 case TCSBRKP: /* support for POSIX tcsendbreak() */
1386 retval = tty_check_change(tty);
1387 if (retval)
1388 return retval;
1389 tty_wait_until_sent(tty, 0);
1390 rc_send_break(port, arg ? arg*(HZ/10) : HZ/4);
1391 break;
1392 case TIOCGSERIAL: 1356 case TIOCGSERIAL:
1393 lock_kernel(); 1357 lock_kernel();
1394 retval = rc_get_serial_info(port, argp); 1358 retval = rc_get_serial_info(port, argp);
@@ -1480,7 +1444,7 @@ static void rc_start(struct tty_struct *tty)
1480 1444
1481 spin_lock_irqsave(&riscom_lock, flags); 1445 spin_lock_irqsave(&riscom_lock, flags);
1482 1446
1483 if (port->xmit_cnt && port->xmit_buf && !(port->IER & IER_TXRDY)) { 1447 if (port->xmit_cnt && port->port.xmit_buf && !(port->IER & IER_TXRDY)) {
1484 port->IER |= IER_TXRDY; 1448 port->IER |= IER_TXRDY;
1485 rc_out(bp, CD180_CAR, port_No(port)); 1449 rc_out(bp, CD180_CAR, port_No(port));
1486 rc_out(bp, CD180_IER, port->IER); 1450 rc_out(bp, CD180_IER, port->IER);
@@ -1498,11 +1462,11 @@ static void rc_hangup(struct tty_struct *tty)
1498 1462
1499 bp = port_Board(port); 1463 bp = port_Board(port);
1500 1464
1501 rc_shutdown_port(bp, port); 1465 rc_shutdown_port(tty, bp, port);
1502 port->count = 0; 1466 port->port.count = 0;
1503 port->flags &= ~ASYNC_NORMAL_ACTIVE; 1467 port->port.flags &= ~ASYNC_NORMAL_ACTIVE;
1504 port->tty = NULL; 1468 port->port.tty = NULL;
1505 wake_up_interruptible(&port->open_wait); 1469 wake_up_interruptible(&port->port.open_wait);
1506} 1470}
1507 1471
1508static void rc_set_termios(struct tty_struct *tty, 1472static void rc_set_termios(struct tty_struct *tty,
@@ -1543,6 +1507,7 @@ static const struct tty_operations riscom_ops = {
1543 .hangup = rc_hangup, 1507 .hangup = rc_hangup,
1544 .tiocmget = rc_tiocmget, 1508 .tiocmget = rc_tiocmget,
1545 .tiocmset = rc_tiocmset, 1509 .tiocmset = rc_tiocmset,
1510 .break_ctl = rc_send_break,
1546}; 1511};
1547 1512
1548static int __init rc_init_drivers(void) 1513static int __init rc_init_drivers(void)
@@ -1564,7 +1529,7 @@ static int __init rc_init_drivers(void)
1564 B9600 | CS8 | CREAD | HUPCL | CLOCAL; 1529 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1565 riscom_driver->init_termios.c_ispeed = 9600; 1530 riscom_driver->init_termios.c_ispeed = 9600;
1566 riscom_driver->init_termios.c_ospeed = 9600; 1531 riscom_driver->init_termios.c_ospeed = 9600;
1567 riscom_driver->flags = TTY_DRIVER_REAL_RAW; 1532 riscom_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_HARDWARE_BREAK;
1568 tty_set_operations(riscom_driver, &riscom_ops); 1533 tty_set_operations(riscom_driver, &riscom_ops);
1569 error = tty_register_driver(riscom_driver); 1534 error = tty_register_driver(riscom_driver);
1570 if (error != 0) { 1535 if (error != 0) {
@@ -1575,11 +1540,8 @@ static int __init rc_init_drivers(void)
1575 } 1540 }
1576 memset(rc_port, 0, sizeof(rc_port)); 1541 memset(rc_port, 0, sizeof(rc_port));
1577 for (i = 0; i < RC_NPORT * RC_NBOARD; i++) { 1542 for (i = 0; i < RC_NPORT * RC_NBOARD; i++) {
1543 tty_port_init(&rc_port[i].port);
1578 rc_port[i].magic = RISCOM8_MAGIC; 1544 rc_port[i].magic = RISCOM8_MAGIC;
1579 rc_port[i].close_delay = 50 * HZ / 100;
1580 rc_port[i].closing_wait = 3000 * HZ / 100;
1581 init_waitqueue_head(&rc_port[i].open_wait);
1582 init_waitqueue_head(&rc_port[i].close_wait);
1583 } 1545 }
1584 return 0; 1546 return 0;
1585} 1547}