Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

isicom: use tty_port

Switch isicom to use a tty_port structure for some fields

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alan Cox and committed by
Linus Torvalds
f1d03228 d99101fd

+79 -102
+79 -102
drivers/char/isicom.c
··· 198 198 199 199 struct isi_port { 200 200 unsigned short magic; 201 - unsigned int flags; 202 - int count; 203 - int blocked_open; 201 + struct tty_port port; 204 202 int close_delay; 205 203 u16 channel; 206 204 u16 status; 207 205 u16 closing_wait; 208 206 struct isi_board *card; 209 - struct tty_struct *tty; 210 - wait_queue_head_t close_wait; 211 - wait_queue_head_t open_wait; 212 207 unsigned char *xmit_buf; 213 208 int xmit_head; 214 209 int xmit_tail; ··· 425 430 426 431 for (; count > 0; count--, port++) { 427 432 /* port not active or tx disabled to force flow control */ 428 - if (!(port->flags & ASYNC_INITIALIZED) || 433 + if (!(port->port.flags & ASYNC_INITIALIZED) || 429 434 !(port->status & ISI_TXOK)) 430 435 continue; 431 436 432 - tty = port->tty; 437 + tty = port->port.tty; 433 438 434 439 if (tty == NULL) 435 440 continue; ··· 453 458 if (residue == YES) { 454 459 residue = NO; 455 460 if (cnt > 0) { 456 - wrd |= (port->xmit_buf[port->xmit_tail] 461 + wrd |= (port->port.xmit_buf[port->xmit_tail] 457 462 << 8); 458 463 port->xmit_tail = (port->xmit_tail + 1) 459 464 & (SERIAL_XMIT_SIZE - 1); ··· 469 474 if (cnt <= 0) 470 475 break; 471 476 word_count = cnt >> 1; 472 - outsw(base, port->xmit_buf+port->xmit_tail, word_count); 477 + outsw(base, port->port.xmit_buf+port->xmit_tail, word_count); 473 478 port->xmit_tail = (port->xmit_tail 474 479 + (word_count << 1)) & (SERIAL_XMIT_SIZE - 1); 475 480 txcount -= (word_count << 1); 476 481 port->xmit_cnt -= (word_count << 1); 477 482 if (cnt & 0x0001) { 478 483 residue = YES; 479 - wrd = port->xmit_buf[port->xmit_tail]; 484 + wrd = port->port.xmit_buf[port->xmit_tail]; 480 485 port->xmit_tail = (port->xmit_tail + 1) 481 486 & (SERIAL_XMIT_SIZE - 1); 482 487 port->xmit_cnt--; ··· 543 548 return IRQ_HANDLED; 544 549 } 545 550 port = card->ports + channel; 546 - if (!(port->flags & ASYNC_INITIALIZED)) { 551 + if (!(port->port.flags & ASYNC_INITIALIZED)) { 547 552 outw(0x0000, base+0x04); /* enable interrupts */ 548 553 spin_unlock(&card->card_lock); 549 554 return IRQ_HANDLED; 550 555 } 551 556 552 - tty = port->tty; 557 + tty = port->port.tty; 553 558 if (tty == NULL) { 554 559 word_count = byte_count >> 1; 555 560 while (byte_count > 1) { ··· 567 572 header = inw(base); 568 573 switch (header & 0xff) { 569 574 case 0: /* Change in EIA signals */ 570 - if (port->flags & ASYNC_CHECK_CD) { 575 + if (port->port.flags & ASYNC_CHECK_CD) { 571 576 if (port->status & ISI_DCD) { 572 577 if (!(header & ISI_DCD)) { 573 578 /* Carrier has been lost */ ··· 580 585 /* Carrier has been detected */ 581 586 pr_dbg("interrupt: DCD->high.\n"); 582 587 port->status |= ISI_DCD; 583 - wake_up_interruptible(&port->open_wait); 588 + wake_up_interruptible(&port->port.open_wait); 584 589 } 585 590 } else { 586 591 if (header & ISI_DCD) ··· 589 594 port->status &= ~ISI_DCD; 590 595 } 591 596 592 - if (port->flags & ASYNC_CTS_FLOW) { 593 - if (port->tty->hw_stopped) { 597 + if (port->port.flags & ASYNC_CTS_FLOW) { 598 + if (port->port.tty->hw_stopped) { 594 599 if (header & ISI_CTS) { 595 - port->tty->hw_stopped = 0; 600 + port->port.tty->hw_stopped = 0; 596 601 /* start tx ing */ 597 602 port->status |= (ISI_TXOK 598 603 | ISI_CTS); 599 604 tty_wakeup(tty); 600 605 } 601 606 } else if (!(header & ISI_CTS)) { 602 - port->tty->hw_stopped = 1; 607 + port->port.tty->hw_stopped = 1; 603 608 /* stop tx ing */ 604 609 port->status &= ~(ISI_TXOK | ISI_CTS); 605 610 } ··· 624 629 625 630 case 1: /* Received Break !!! */ 626 631 tty_insert_flip_char(tty, 0, TTY_BREAK); 627 - if (port->flags & ASYNC_SAK) 632 + if (port->port.flags & ASYNC_SAK) 628 633 do_SAK(tty); 629 634 tty_flip_buffer_push(tty); 630 635 break; ··· 676 681 shift_count = card->shift_count; 677 682 unsigned char flow_ctrl; 678 683 679 - tty = port->tty; 684 + tty = port->port.tty; 680 685 681 686 if (tty == NULL) 682 687 return; ··· 692 697 693 698 /* 1,2,3,4 => 57.6, 115.2, 230, 460 kbps resp. */ 694 699 if (baud < 1 || baud > 4) 695 - port->tty->termios->c_cflag &= ~CBAUDEX; 700 + port->port.tty->termios->c_cflag &= ~CBAUDEX; 696 701 else 697 702 baud += 15; 698 703 } ··· 703 708 * the 'setserial' utility. 704 709 */ 705 710 706 - if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 711 + if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 707 712 baud++; /* 57.6 Kbps */ 708 - if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 713 + if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 709 714 baud += 2; /* 115 Kbps */ 710 - if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) 715 + if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) 711 716 baud += 3; /* 230 kbps*/ 712 - if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 717 + if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 713 718 baud += 4; /* 460 kbps*/ 714 719 } 715 720 if (linuxb_to_isib[baud] == -1) { ··· 749 754 InterruptTheCard(base); 750 755 } 751 756 if (C_CLOCAL(tty)) 752 - port->flags &= ~ASYNC_CHECK_CD; 757 + port->port.flags &= ~ASYNC_CHECK_CD; 753 758 else 754 - port->flags |= ASYNC_CHECK_CD; 759 + port->port.flags |= ASYNC_CHECK_CD; 755 760 756 761 /* flow control settings ...*/ 757 762 flow_ctrl = 0; 758 - port->flags &= ~ASYNC_CTS_FLOW; 763 + port->port.flags &= ~ASYNC_CTS_FLOW; 759 764 if (C_CRTSCTS(tty)) { 760 - port->flags |= ASYNC_CTS_FLOW; 765 + port->port.flags |= ASYNC_CTS_FLOW; 761 766 flow_ctrl |= ISICOM_CTSRTS; 762 767 } 763 768 if (I_IXON(tty)) ··· 804 809 struct isi_board *card = port->card; 805 810 unsigned long flags; 806 811 807 - if (port->flags & ASYNC_INITIALIZED) 812 + if (port->port.flags & ASYNC_INITIALIZED) 808 813 return 0; 809 - if (!port->xmit_buf) { 810 - /* Relies on BKL */ 811 - unsigned long page = get_zeroed_page(GFP_KERNEL); 812 - if (page == 0) 813 - return -ENOMEM; 814 - if (port->xmit_buf) 815 - free_page(page); 816 - else 817 - port->xmit_buf = (unsigned char *) page; 818 - } 814 + if (tty_port_alloc_xmit_buf(&port->port) < 0) 815 + return -ENOMEM; 819 816 820 817 spin_lock_irqsave(&card->card_lock, flags); 821 - if (port->tty) 822 - clear_bit(TTY_IO_ERROR, &port->tty->flags); 823 - if (port->count == 1) 818 + if (port->port.tty) 819 + clear_bit(TTY_IO_ERROR, &port->port.tty->flags); 820 + if (port->port.count == 1) 824 821 card->count++; 825 822 826 823 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; ··· 826 839 } 827 840 828 841 isicom_config_port(port); 829 - port->flags |= ASYNC_INITIALIZED; 842 + port->port.flags |= ASYNC_INITIALIZED; 830 843 spin_unlock_irqrestore(&card->card_lock, flags); 831 844 832 845 return 0; ··· 842 855 843 856 /* block if port is in the process of being closed */ 844 857 845 - if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { 858 + if (tty_hung_up_p(filp) || port->port.flags & ASYNC_CLOSING) { 846 859 pr_dbg("block_til_ready: close in progress.\n"); 847 - interruptible_sleep_on(&port->close_wait); 848 - if (port->flags & ASYNC_HUP_NOTIFY) 860 + interruptible_sleep_on(&port->port.close_wait); 861 + if (port->port.flags & ASYNC_HUP_NOTIFY) 849 862 return -EAGAIN; 850 863 else 851 864 return -ERESTARTSYS; ··· 856 869 if ((filp->f_flags & O_NONBLOCK) || 857 870 (tty->flags & (1 << TTY_IO_ERROR))) { 858 871 pr_dbg("block_til_ready: non-block mode.\n"); 859 - port->flags |= ASYNC_NORMAL_ACTIVE; 872 + port->port.flags |= ASYNC_NORMAL_ACTIVE; 860 873 return 0; 861 874 } 862 875 ··· 866 879 /* block waiting for DCD to be asserted, and while 867 880 callout dev is busy */ 868 881 retval = 0; 869 - add_wait_queue(&port->open_wait, &wait); 882 + add_wait_queue(&port->port.open_wait, &wait); 870 883 871 884 spin_lock_irqsave(&card->card_lock, flags); 872 885 if (!tty_hung_up_p(filp)) 873 - port->count--; 874 - port->blocked_open++; 886 + port->port.count--; 887 + port->port.blocked_open++; 875 888 spin_unlock_irqrestore(&card->card_lock, flags); 876 889 877 890 while (1) { 878 891 raise_dtr_rts(port); 879 892 880 893 set_current_state(TASK_INTERRUPTIBLE); 881 - if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) { 882 - if (port->flags & ASYNC_HUP_NOTIFY) 894 + if (tty_hung_up_p(filp) || !(port->port.flags & ASYNC_INITIALIZED)) { 895 + if (port->port.flags & ASYNC_HUP_NOTIFY) 883 896 retval = -EAGAIN; 884 897 else 885 898 retval = -ERESTARTSYS; 886 899 break; 887 900 } 888 - if (!(port->flags & ASYNC_CLOSING) && 901 + if (!(port->port.flags & ASYNC_CLOSING) && 889 902 (do_clocal || (port->status & ISI_DCD))) { 890 903 break; 891 904 } ··· 896 909 schedule(); 897 910 } 898 911 set_current_state(TASK_RUNNING); 899 - remove_wait_queue(&port->open_wait, &wait); 912 + remove_wait_queue(&port->port.open_wait, &wait); 900 913 spin_lock_irqsave(&card->card_lock, flags); 901 914 if (!tty_hung_up_p(filp)) 902 - port->count++; 903 - port->blocked_open--; 915 + port->port.count++; 916 + port->port.blocked_open--; 904 917 spin_unlock_irqrestore(&card->card_lock, flags); 905 918 if (retval) 906 919 return retval; 907 - port->flags |= ASYNC_NORMAL_ACTIVE; 920 + port->port.flags |= ASYNC_NORMAL_ACTIVE; 908 921 return 0; 909 922 } 910 923 ··· 934 947 935 948 isicom_setup_board(card); 936 949 937 - port->count++; 950 + port->port.count++; 938 951 tty->driver_data = port; 939 - port->tty = tty; 952 + port->port.tty = tty; 940 953 error = isicom_setup_port(port); 941 954 if (error == 0) 942 955 error = block_til_ready(tty, filp, port); ··· 957 970 struct isi_board *card = port->card; 958 971 struct tty_struct *tty; 959 972 960 - tty = port->tty; 973 + tty = port->port.tty; 961 974 962 - if (!(port->flags & ASYNC_INITIALIZED)) 975 + if (!(port->port.flags & ASYNC_INITIALIZED)) 963 976 return; 964 977 965 - if (port->xmit_buf) { 966 - free_page((unsigned long) port->xmit_buf); 967 - port->xmit_buf = NULL; 968 - } 969 - port->flags &= ~ASYNC_INITIALIZED; 978 + tty_port_free_xmit_buf(&port->port); 979 + port->port.flags &= ~ASYNC_INITIALIZED; 970 980 /* 3rd October 2000 : Vinayak P Risbud */ 971 - port->tty = NULL; 981 + port->port.tty = NULL; 972 982 973 983 /*Fix done by Anil .S on 30-04-2001 974 984 remote login through isi port has dtr toggle problem ··· 1030 1046 return; 1031 1047 } 1032 1048 1033 - if (tty->count == 1 && port->count != 1) { 1049 + if (tty->count == 1 && port->port.count != 1) { 1034 1050 printk(KERN_WARNING "ISICOM:(0x%lx) isicom_close: bad port " 1035 1051 "count tty->count = 1 port count = %d.\n", 1036 - card->base, port->count); 1037 - port->count = 1; 1052 + card->base, port->port.count); 1053 + port->port.count = 1; 1038 1054 } 1039 - if (--port->count < 0) { 1055 + if (--port->port.count < 0) { 1040 1056 printk(KERN_WARNING "ISICOM:(0x%lx) isicom_close: bad port " 1041 1057 "count for channel%d = %d", card->base, port->channel, 1042 - port->count); 1043 - port->count = 0; 1058 + port->port.count); 1059 + port->port.count = 0; 1044 1060 } 1045 1061 1046 - if (port->count) { 1062 + if (port->port.count) { 1047 1063 spin_unlock_irqrestore(&card->card_lock, flags); 1048 1064 return; 1049 1065 } 1050 - port->flags |= ASYNC_CLOSING; 1066 + port->port.flags |= ASYNC_CLOSING; 1051 1067 tty->closing = 1; 1052 1068 spin_unlock_irqrestore(&card->card_lock, flags); 1053 1069 ··· 1056 1072 /* indicate to the card that no more data can be received 1057 1073 on this port */ 1058 1074 spin_lock_irqsave(&card->card_lock, flags); 1059 - if (port->flags & ASYNC_INITIALIZED) { 1075 + if (port->port.flags & ASYNC_INITIALIZED) { 1060 1076 card->port_status &= ~(1 << port->channel); 1061 1077 outw(card->port_status, card->base + 0x02); 1062 1078 } ··· 1069 1085 spin_lock_irqsave(&card->card_lock, flags); 1070 1086 tty->closing = 0; 1071 1087 1072 - if (port->blocked_open) { 1088 + if (port->port.blocked_open) { 1073 1089 spin_unlock_irqrestore(&card->card_lock, flags); 1074 1090 if (port->close_delay) { 1075 1091 pr_dbg("scheduling until time out.\n"); ··· 1077 1093 jiffies_to_msecs(port->close_delay)); 1078 1094 } 1079 1095 spin_lock_irqsave(&card->card_lock, flags); 1080 - wake_up_interruptible(&port->open_wait); 1096 + wake_up_interruptible(&port->port.open_wait); 1081 1097 } 1082 - port->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); 1083 - wake_up_interruptible(&port->close_wait); 1098 + port->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); 1099 + wake_up_interruptible(&port->port.close_wait); 1084 1100 spin_unlock_irqrestore(&card->card_lock, flags); 1085 1101 } 1086 1102 ··· 1096 1112 if (isicom_paranoia_check(port, tty->name, "isicom_write")) 1097 1113 return 0; 1098 1114 1099 - if (!port->xmit_buf) 1100 - return 0; 1101 - 1102 1115 spin_lock_irqsave(&card->card_lock, flags); 1103 1116 1104 1117 while (1) { ··· 1104 1123 if (cnt <= 0) 1105 1124 break; 1106 1125 1107 - memcpy(port->xmit_buf + port->xmit_head, buf, cnt); 1126 + memcpy(port->port.xmit_buf + port->xmit_head, buf, cnt); 1108 1127 port->xmit_head = (port->xmit_head + cnt) & (SERIAL_XMIT_SIZE 1109 1128 - 1); 1110 1129 port->xmit_cnt += cnt; ··· 1128 1147 if (isicom_paranoia_check(port, tty->name, "isicom_put_char")) 1129 1148 return 0; 1130 1149 1131 - if (!port->xmit_buf) 1132 - return 0; 1133 - 1134 1150 spin_lock_irqsave(&card->card_lock, flags); 1135 1151 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) { 1136 1152 spin_unlock_irqrestore(&card->card_lock, flags); 1137 1153 return 0; 1138 1154 } 1139 1155 1140 - port->xmit_buf[port->xmit_head++] = ch; 1156 + port->port.xmit_buf[port->xmit_head++] = ch; 1141 1157 port->xmit_head &= (SERIAL_XMIT_SIZE - 1); 1142 1158 port->xmit_cnt++; 1143 1159 spin_unlock_irqrestore(&card->card_lock, flags); ··· 1150 1172 return; 1151 1173 1152 1174 if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || 1153 - !port->xmit_buf) 1175 + !port->port.xmit_buf) 1154 1176 return; 1155 1177 1156 1178 /* this tells the transmitter to consider this port for ··· 1252 1274 1253 1275 lock_kernel(); 1254 1276 1255 - reconfig_port = ((port->flags & ASYNC_SPD_MASK) != 1277 + reconfig_port = ((port->port.flags & ASYNC_SPD_MASK) != 1256 1278 (newinfo.flags & ASYNC_SPD_MASK)); 1257 1279 1258 1280 if (!capable(CAP_SYS_ADMIN)) { 1259 1281 if ((newinfo.close_delay != port->close_delay) || 1260 1282 (newinfo.closing_wait != port->closing_wait) || 1261 1283 ((newinfo.flags & ~ASYNC_USR_MASK) != 1262 - (port->flags & ~ASYNC_USR_MASK))) { 1284 + (port->port.flags & ~ASYNC_USR_MASK))) { 1263 1285 unlock_kernel(); 1264 1286 return -EPERM; 1265 1287 } 1266 - port->flags = ((port->flags & ~ASYNC_USR_MASK) | 1288 + port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) | 1267 1289 (newinfo.flags & ASYNC_USR_MASK)); 1268 1290 } else { 1269 1291 port->close_delay = newinfo.close_delay; 1270 1292 port->closing_wait = newinfo.closing_wait; 1271 - port->flags = ((port->flags & ~ASYNC_FLAGS) | 1293 + port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) | 1272 1294 (newinfo.flags & ASYNC_FLAGS)); 1273 1295 } 1274 1296 if (reconfig_port) { ··· 1292 1314 out_info.line = port - isi_ports; 1293 1315 out_info.port = port->card->base; 1294 1316 out_info.irq = port->card->irq; 1295 - out_info.flags = port->flags; 1317 + out_info.flags = port->port.flags; 1296 1318 /* out_info.baud_base = ? */ 1297 1319 out_info.close_delay = port->close_delay; 1298 1320 out_info.closing_wait = port->closing_wait; ··· 1432 1454 isicom_shutdown_port(port); 1433 1455 spin_unlock_irqrestore(&port->card->card_lock, flags); 1434 1456 1435 - port->count = 0; 1436 - port->flags &= ~ASYNC_NORMAL_ACTIVE; 1437 - port->tty = NULL; 1438 - wake_up_interruptible(&port->open_wait); 1457 + port->port.count = 0; 1458 + port->port.flags &= ~ASYNC_NORMAL_ACTIVE; 1459 + port->port.tty = NULL; 1460 + wake_up_interruptible(&port->port.open_wait); 1439 1461 } 1440 1462 1441 1463 ··· 1810 1832 port->close_delay = 50 * HZ/100; 1811 1833 port->closing_wait = 3000 * HZ/100; 1812 1834 port->status = 0; 1813 - init_waitqueue_head(&port->open_wait); 1814 - init_waitqueue_head(&port->close_wait); 1835 + tty_port_init(&port->port); 1815 1836 /* . . . */ 1816 1837 } 1817 1838 isi_card[idx].base = 0;