aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/isicom.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/isicom.c')
-rw-r--r--drivers/char/isicom.c215
1 files changed, 99 insertions, 116 deletions
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index 4f3cefa8eb0e..d4281df10c22 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -198,17 +198,10 @@ struct isi_board {
198 198
199struct isi_port { 199struct isi_port {
200 unsigned short magic; 200 unsigned short magic;
201 unsigned int flags; 201 struct tty_port port;
202 int count;
203 int blocked_open;
204 int close_delay;
205 u16 channel; 202 u16 channel;
206 u16 status; 203 u16 status;
207 u16 closing_wait;
208 struct isi_board *card; 204 struct isi_board *card;
209 struct tty_struct *tty;
210 wait_queue_head_t close_wait;
211 wait_queue_head_t open_wait;
212 unsigned char *xmit_buf; 205 unsigned char *xmit_buf;
213 int xmit_head; 206 int xmit_head;
214 int xmit_tail; 207 int xmit_tail;
@@ -430,11 +423,11 @@ static void isicom_tx(unsigned long _data)
430 423
431 for (; count > 0; count--, port++) { 424 for (; count > 0; count--, port++) {
432 /* port not active or tx disabled to force flow control */ 425 /* port not active or tx disabled to force flow control */
433 if (!(port->flags & ASYNC_INITIALIZED) || 426 if (!(port->port.flags & ASYNC_INITIALIZED) ||
434 !(port->status & ISI_TXOK)) 427 !(port->status & ISI_TXOK))
435 continue; 428 continue;
436 429
437 tty = port->tty; 430 tty = port->port.tty;
438 431
439 if (tty == NULL) 432 if (tty == NULL)
440 continue; 433 continue;
@@ -458,7 +451,7 @@ static void isicom_tx(unsigned long _data)
458 if (residue == YES) { 451 if (residue == YES) {
459 residue = NO; 452 residue = NO;
460 if (cnt > 0) { 453 if (cnt > 0) {
461 wrd |= (port->xmit_buf[port->xmit_tail] 454 wrd |= (port->port.xmit_buf[port->xmit_tail]
462 << 8); 455 << 8);
463 port->xmit_tail = (port->xmit_tail + 1) 456 port->xmit_tail = (port->xmit_tail + 1)
464 & (SERIAL_XMIT_SIZE - 1); 457 & (SERIAL_XMIT_SIZE - 1);
@@ -474,14 +467,14 @@ static void isicom_tx(unsigned long _data)
474 if (cnt <= 0) 467 if (cnt <= 0)
475 break; 468 break;
476 word_count = cnt >> 1; 469 word_count = cnt >> 1;
477 outsw(base, port->xmit_buf+port->xmit_tail, word_count); 470 outsw(base, port->port.xmit_buf+port->xmit_tail, word_count);
478 port->xmit_tail = (port->xmit_tail 471 port->xmit_tail = (port->xmit_tail
479 + (word_count << 1)) & (SERIAL_XMIT_SIZE - 1); 472 + (word_count << 1)) & (SERIAL_XMIT_SIZE - 1);
480 txcount -= (word_count << 1); 473 txcount -= (word_count << 1);
481 port->xmit_cnt -= (word_count << 1); 474 port->xmit_cnt -= (word_count << 1);
482 if (cnt & 0x0001) { 475 if (cnt & 0x0001) {
483 residue = YES; 476 residue = YES;
484 wrd = port->xmit_buf[port->xmit_tail]; 477 wrd = port->port.xmit_buf[port->xmit_tail];
485 port->xmit_tail = (port->xmit_tail + 1) 478 port->xmit_tail = (port->xmit_tail + 1)
486 & (SERIAL_XMIT_SIZE - 1); 479 & (SERIAL_XMIT_SIZE - 1);
487 port->xmit_cnt--; 480 port->xmit_cnt--;
@@ -548,13 +541,13 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
548 return IRQ_HANDLED; 541 return IRQ_HANDLED;
549 } 542 }
550 port = card->ports + channel; 543 port = card->ports + channel;
551 if (!(port->flags & ASYNC_INITIALIZED)) { 544 if (!(port->port.flags & ASYNC_INITIALIZED)) {
552 outw(0x0000, base+0x04); /* enable interrupts */ 545 outw(0x0000, base+0x04); /* enable interrupts */
553 spin_unlock(&card->card_lock); 546 spin_unlock(&card->card_lock);
554 return IRQ_HANDLED; 547 return IRQ_HANDLED;
555 } 548 }
556 549
557 tty = port->tty; 550 tty = port->port.tty;
558 if (tty == NULL) { 551 if (tty == NULL) {
559 word_count = byte_count >> 1; 552 word_count = byte_count >> 1;
560 while (byte_count > 1) { 553 while (byte_count > 1) {
@@ -572,7 +565,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
572 header = inw(base); 565 header = inw(base);
573 switch (header & 0xff) { 566 switch (header & 0xff) {
574 case 0: /* Change in EIA signals */ 567 case 0: /* Change in EIA signals */
575 if (port->flags & ASYNC_CHECK_CD) { 568 if (port->port.flags & ASYNC_CHECK_CD) {
576 if (port->status & ISI_DCD) { 569 if (port->status & ISI_DCD) {
577 if (!(header & ISI_DCD)) { 570 if (!(header & ISI_DCD)) {
578 /* Carrier has been lost */ 571 /* Carrier has been lost */
@@ -585,7 +578,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
585 /* Carrier has been detected */ 578 /* Carrier has been detected */
586 pr_dbg("interrupt: DCD->high.\n"); 579 pr_dbg("interrupt: DCD->high.\n");
587 port->status |= ISI_DCD; 580 port->status |= ISI_DCD;
588 wake_up_interruptible(&port->open_wait); 581 wake_up_interruptible(&port->port.open_wait);
589 } 582 }
590 } else { 583 } else {
591 if (header & ISI_DCD) 584 if (header & ISI_DCD)
@@ -594,17 +587,17 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
594 port->status &= ~ISI_DCD; 587 port->status &= ~ISI_DCD;
595 } 588 }
596 589
597 if (port->flags & ASYNC_CTS_FLOW) { 590 if (port->port.flags & ASYNC_CTS_FLOW) {
598 if (port->tty->hw_stopped) { 591 if (port->port.tty->hw_stopped) {
599 if (header & ISI_CTS) { 592 if (header & ISI_CTS) {
600 port->tty->hw_stopped = 0; 593 port->port.tty->hw_stopped = 0;
601 /* start tx ing */ 594 /* start tx ing */
602 port->status |= (ISI_TXOK 595 port->status |= (ISI_TXOK
603 | ISI_CTS); 596 | ISI_CTS);
604 tty_wakeup(tty); 597 tty_wakeup(tty);
605 } 598 }
606 } else if (!(header & ISI_CTS)) { 599 } else if (!(header & ISI_CTS)) {
607 port->tty->hw_stopped = 1; 600 port->port.tty->hw_stopped = 1;
608 /* stop tx ing */ 601 /* stop tx ing */
609 port->status &= ~(ISI_TXOK | ISI_CTS); 602 port->status &= ~(ISI_TXOK | ISI_CTS);
610 } 603 }
@@ -629,7 +622,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
629 622
630 case 1: /* Received Break !!! */ 623 case 1: /* Received Break !!! */
631 tty_insert_flip_char(tty, 0, TTY_BREAK); 624 tty_insert_flip_char(tty, 0, TTY_BREAK);
632 if (port->flags & ASYNC_SAK) 625 if (port->port.flags & ASYNC_SAK)
633 do_SAK(tty); 626 do_SAK(tty);
634 tty_flip_buffer_push(tty); 627 tty_flip_buffer_push(tty);
635 break; 628 break;
@@ -681,7 +674,7 @@ static void isicom_config_port(struct isi_port *port)
681 shift_count = card->shift_count; 674 shift_count = card->shift_count;
682 unsigned char flow_ctrl; 675 unsigned char flow_ctrl;
683 676
684 tty = port->tty; 677 tty = port->port.tty;
685 678
686 if (tty == NULL) 679 if (tty == NULL)
687 return; 680 return;
@@ -697,7 +690,7 @@ static void isicom_config_port(struct isi_port *port)
697 690
698 /* 1,2,3,4 => 57.6, 115.2, 230, 460 kbps resp. */ 691 /* 1,2,3,4 => 57.6, 115.2, 230, 460 kbps resp. */
699 if (baud < 1 || baud > 4) 692 if (baud < 1 || baud > 4)
700 port->tty->termios->c_cflag &= ~CBAUDEX; 693 port->port.tty->termios->c_cflag &= ~CBAUDEX;
701 else 694 else
702 baud += 15; 695 baud += 15;
703 } 696 }
@@ -708,13 +701,13 @@ static void isicom_config_port(struct isi_port *port)
708 * the 'setserial' utility. 701 * the 'setserial' utility.
709 */ 702 */
710 703
711 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 704 if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
712 baud++; /* 57.6 Kbps */ 705 baud++; /* 57.6 Kbps */
713 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 706 if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
714 baud += 2; /* 115 Kbps */ 707 baud += 2; /* 115 Kbps */
715 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) 708 if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
716 baud += 3; /* 230 kbps*/ 709 baud += 3; /* 230 kbps*/
717 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 710 if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
718 baud += 4; /* 460 kbps*/ 711 baud += 4; /* 460 kbps*/
719 } 712 }
720 if (linuxb_to_isib[baud] == -1) { 713 if (linuxb_to_isib[baud] == -1) {
@@ -754,15 +747,15 @@ static void isicom_config_port(struct isi_port *port)
754 InterruptTheCard(base); 747 InterruptTheCard(base);
755 } 748 }
756 if (C_CLOCAL(tty)) 749 if (C_CLOCAL(tty))
757 port->flags &= ~ASYNC_CHECK_CD; 750 port->port.flags &= ~ASYNC_CHECK_CD;
758 else 751 else
759 port->flags |= ASYNC_CHECK_CD; 752 port->port.flags |= ASYNC_CHECK_CD;
760 753
761 /* flow control settings ...*/ 754 /* flow control settings ...*/
762 flow_ctrl = 0; 755 flow_ctrl = 0;
763 port->flags &= ~ASYNC_CTS_FLOW; 756 port->port.flags &= ~ASYNC_CTS_FLOW;
764 if (C_CRTSCTS(tty)) { 757 if (C_CRTSCTS(tty)) {
765 port->flags |= ASYNC_CTS_FLOW; 758 port->port.flags |= ASYNC_CTS_FLOW;
766 flow_ctrl |= ISICOM_CTSRTS; 759 flow_ctrl |= ISICOM_CTSRTS;
767 } 760 }
768 if (I_IXON(tty)) 761 if (I_IXON(tty))
@@ -809,23 +802,15 @@ static int isicom_setup_port(struct isi_port *port)
809 struct isi_board *card = port->card; 802 struct isi_board *card = port->card;
810 unsigned long flags; 803 unsigned long flags;
811 804
812 if (port->flags & ASYNC_INITIALIZED) 805 if (port->port.flags & ASYNC_INITIALIZED)
813 return 0; 806 return 0;
814 if (!port->xmit_buf) { 807 if (tty_port_alloc_xmit_buf(&port->port) < 0)
815 /* Relies on BKL */ 808 return -ENOMEM;
816 unsigned long page = get_zeroed_page(GFP_KERNEL);
817 if (page == 0)
818 return -ENOMEM;
819 if (port->xmit_buf)
820 free_page(page);
821 else
822 port->xmit_buf = (unsigned char *) page;
823 }
824 809
825 spin_lock_irqsave(&card->card_lock, flags); 810 spin_lock_irqsave(&card->card_lock, flags);
826 if (port->tty) 811 if (port->port.tty)
827 clear_bit(TTY_IO_ERROR, &port->tty->flags); 812 clear_bit(TTY_IO_ERROR, &port->port.tty->flags);
828 if (port->count == 1) 813 if (port->port.count == 1)
829 card->count++; 814 card->count++;
830 815
831 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; 816 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
@@ -839,7 +824,7 @@ static int isicom_setup_port(struct isi_port *port)
839 } 824 }
840 825
841 isicom_config_port(port); 826 isicom_config_port(port);
842 port->flags |= ASYNC_INITIALIZED; 827 port->port.flags |= ASYNC_INITIALIZED;
843 spin_unlock_irqrestore(&card->card_lock, flags); 828 spin_unlock_irqrestore(&card->card_lock, flags);
844 829
845 return 0; 830 return 0;
@@ -855,10 +840,10 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
855 840
856 /* block if port is in the process of being closed */ 841 /* block if port is in the process of being closed */
857 842
858 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { 843 if (tty_hung_up_p(filp) || port->port.flags & ASYNC_CLOSING) {
859 pr_dbg("block_til_ready: close in progress.\n"); 844 pr_dbg("block_til_ready: close in progress.\n");
860 interruptible_sleep_on(&port->close_wait); 845 interruptible_sleep_on(&port->port.close_wait);
861 if (port->flags & ASYNC_HUP_NOTIFY) 846 if (port->port.flags & ASYNC_HUP_NOTIFY)
862 return -EAGAIN; 847 return -EAGAIN;
863 else 848 else
864 return -ERESTARTSYS; 849 return -ERESTARTSYS;
@@ -869,7 +854,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
869 if ((filp->f_flags & O_NONBLOCK) || 854 if ((filp->f_flags & O_NONBLOCK) ||
870 (tty->flags & (1 << TTY_IO_ERROR))) { 855 (tty->flags & (1 << TTY_IO_ERROR))) {
871 pr_dbg("block_til_ready: non-block mode.\n"); 856 pr_dbg("block_til_ready: non-block mode.\n");
872 port->flags |= ASYNC_NORMAL_ACTIVE; 857 port->port.flags |= ASYNC_NORMAL_ACTIVE;
873 return 0; 858 return 0;
874 } 859 }
875 860
@@ -879,26 +864,26 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
879 /* block waiting for DCD to be asserted, and while 864 /* block waiting for DCD to be asserted, and while
880 callout dev is busy */ 865 callout dev is busy */
881 retval = 0; 866 retval = 0;
882 add_wait_queue(&port->open_wait, &wait); 867 add_wait_queue(&port->port.open_wait, &wait);
883 868
884 spin_lock_irqsave(&card->card_lock, flags); 869 spin_lock_irqsave(&card->card_lock, flags);
885 if (!tty_hung_up_p(filp)) 870 if (!tty_hung_up_p(filp))
886 port->count--; 871 port->port.count--;
887 port->blocked_open++; 872 port->port.blocked_open++;
888 spin_unlock_irqrestore(&card->card_lock, flags); 873 spin_unlock_irqrestore(&card->card_lock, flags);
889 874
890 while (1) { 875 while (1) {
891 raise_dtr_rts(port); 876 raise_dtr_rts(port);
892 877
893 set_current_state(TASK_INTERRUPTIBLE); 878 set_current_state(TASK_INTERRUPTIBLE);
894 if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) { 879 if (tty_hung_up_p(filp) || !(port->port.flags & ASYNC_INITIALIZED)) {
895 if (port->flags & ASYNC_HUP_NOTIFY) 880 if (port->port.flags & ASYNC_HUP_NOTIFY)
896 retval = -EAGAIN; 881 retval = -EAGAIN;
897 else 882 else
898 retval = -ERESTARTSYS; 883 retval = -ERESTARTSYS;
899 break; 884 break;
900 } 885 }
901 if (!(port->flags & ASYNC_CLOSING) && 886 if (!(port->port.flags & ASYNC_CLOSING) &&
902 (do_clocal || (port->status & ISI_DCD))) { 887 (do_clocal || (port->status & ISI_DCD))) {
903 break; 888 break;
904 } 889 }
@@ -909,15 +894,15 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
909 schedule(); 894 schedule();
910 } 895 }
911 set_current_state(TASK_RUNNING); 896 set_current_state(TASK_RUNNING);
912 remove_wait_queue(&port->open_wait, &wait); 897 remove_wait_queue(&port->port.open_wait, &wait);
913 spin_lock_irqsave(&card->card_lock, flags); 898 spin_lock_irqsave(&card->card_lock, flags);
914 if (!tty_hung_up_p(filp)) 899 if (!tty_hung_up_p(filp))
915 port->count++; 900 port->port.count++;
916 port->blocked_open--; 901 port->port.blocked_open--;
917 spin_unlock_irqrestore(&card->card_lock, flags); 902 spin_unlock_irqrestore(&card->card_lock, flags);
918 if (retval) 903 if (retval)
919 return retval; 904 return retval;
920 port->flags |= ASYNC_NORMAL_ACTIVE; 905 port->port.flags |= ASYNC_NORMAL_ACTIVE;
921 return 0; 906 return 0;
922} 907}
923 908
@@ -947,9 +932,9 @@ static int isicom_open(struct tty_struct *tty, struct file *filp)
947 932
948 isicom_setup_board(card); 933 isicom_setup_board(card);
949 934
950 port->count++; 935 port->port.count++;
951 tty->driver_data = port; 936 tty->driver_data = port;
952 port->tty = tty; 937 port->port.tty = tty;
953 error = isicom_setup_port(port); 938 error = isicom_setup_port(port);
954 if (error == 0) 939 if (error == 0)
955 error = block_til_ready(tty, filp, port); 940 error = block_til_ready(tty, filp, port);
@@ -970,18 +955,15 @@ static void isicom_shutdown_port(struct isi_port *port)
970 struct isi_board *card = port->card; 955 struct isi_board *card = port->card;
971 struct tty_struct *tty; 956 struct tty_struct *tty;
972 957
973 tty = port->tty; 958 tty = port->port.tty;
974 959
975 if (!(port->flags & ASYNC_INITIALIZED)) 960 if (!(port->port.flags & ASYNC_INITIALIZED))
976 return; 961 return;
977 962
978 if (port->xmit_buf) { 963 tty_port_free_xmit_buf(&port->port);
979 free_page((unsigned long) port->xmit_buf); 964 port->port.flags &= ~ASYNC_INITIALIZED;
980 port->xmit_buf = NULL;
981 }
982 port->flags &= ~ASYNC_INITIALIZED;
983 /* 3rd October 2000 : Vinayak P Risbud */ 965 /* 3rd October 2000 : Vinayak P Risbud */
984 port->tty = NULL; 966 port->port.tty = NULL;
985 967
986 /*Fix done by Anil .S on 30-04-2001 968 /*Fix done by Anil .S on 30-04-2001
987 remote login through isi port has dtr toggle problem 969 remote login through isi port has dtr toggle problem
@@ -1046,33 +1028,33 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)
1046 return; 1028 return;
1047 } 1029 }
1048 1030
1049 if (tty->count == 1 && port->count != 1) { 1031 if (tty->count == 1 && port->port.count != 1) {
1050 printk(KERN_WARNING "ISICOM:(0x%lx) isicom_close: bad port " 1032 printk(KERN_WARNING "ISICOM:(0x%lx) isicom_close: bad port "
1051 "count tty->count = 1 port count = %d.\n", 1033 "count tty->count = 1 port count = %d.\n",
1052 card->base, port->count); 1034 card->base, port->port.count);
1053 port->count = 1; 1035 port->port.count = 1;
1054 } 1036 }
1055 if (--port->count < 0) { 1037 if (--port->port.count < 0) {
1056 printk(KERN_WARNING "ISICOM:(0x%lx) isicom_close: bad port " 1038 printk(KERN_WARNING "ISICOM:(0x%lx) isicom_close: bad port "
1057 "count for channel%d = %d", card->base, port->channel, 1039 "count for channel%d = %d", card->base, port->channel,
1058 port->count); 1040 port->port.count);
1059 port->count = 0; 1041 port->port.count = 0;
1060 } 1042 }
1061 1043
1062 if (port->count) { 1044 if (port->port.count) {
1063 spin_unlock_irqrestore(&card->card_lock, flags); 1045 spin_unlock_irqrestore(&card->card_lock, flags);
1064 return; 1046 return;
1065 } 1047 }
1066 port->flags |= ASYNC_CLOSING; 1048 port->port.flags |= ASYNC_CLOSING;
1067 tty->closing = 1; 1049 tty->closing = 1;
1068 spin_unlock_irqrestore(&card->card_lock, flags); 1050 spin_unlock_irqrestore(&card->card_lock, flags);
1069 1051
1070 if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) 1052 if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
1071 tty_wait_until_sent(tty, port->closing_wait); 1053 tty_wait_until_sent(tty, port->port.closing_wait);
1072 /* indicate to the card that no more data can be received 1054 /* indicate to the card that no more data can be received
1073 on this port */ 1055 on this port */
1074 spin_lock_irqsave(&card->card_lock, flags); 1056 spin_lock_irqsave(&card->card_lock, flags);
1075 if (port->flags & ASYNC_INITIALIZED) { 1057 if (port->port.flags & ASYNC_INITIALIZED) {
1076 card->port_status &= ~(1 << port->channel); 1058 card->port_status &= ~(1 << port->channel);
1077 outw(card->port_status, card->base + 0x02); 1059 outw(card->port_status, card->base + 0x02);
1078 } 1060 }
@@ -1085,18 +1067,18 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)
1085 spin_lock_irqsave(&card->card_lock, flags); 1067 spin_lock_irqsave(&card->card_lock, flags);
1086 tty->closing = 0; 1068 tty->closing = 0;
1087 1069
1088 if (port->blocked_open) { 1070 if (port->port.blocked_open) {
1089 spin_unlock_irqrestore(&card->card_lock, flags); 1071 spin_unlock_irqrestore(&card->card_lock, flags);
1090 if (port->close_delay) { 1072 if (port->port.close_delay) {
1091 pr_dbg("scheduling until time out.\n"); 1073 pr_dbg("scheduling until time out.\n");
1092 msleep_interruptible( 1074 msleep_interruptible(
1093 jiffies_to_msecs(port->close_delay)); 1075 jiffies_to_msecs(port->port.close_delay));
1094 } 1076 }
1095 spin_lock_irqsave(&card->card_lock, flags); 1077 spin_lock_irqsave(&card->card_lock, flags);
1096 wake_up_interruptible(&port->open_wait); 1078 wake_up_interruptible(&port->port.open_wait);
1097 } 1079 }
1098 port->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); 1080 port->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
1099 wake_up_interruptible(&port->close_wait); 1081 wake_up_interruptible(&port->port.close_wait);
1100 spin_unlock_irqrestore(&card->card_lock, flags); 1082 spin_unlock_irqrestore(&card->card_lock, flags);
1101} 1083}
1102 1084
@@ -1112,9 +1094,6 @@ static int isicom_write(struct tty_struct *tty, const unsigned char *buf,
1112 if (isicom_paranoia_check(port, tty->name, "isicom_write")) 1094 if (isicom_paranoia_check(port, tty->name, "isicom_write"))
1113 return 0; 1095 return 0;
1114 1096
1115 if (!port->xmit_buf)
1116 return 0;
1117
1118 spin_lock_irqsave(&card->card_lock, flags); 1097 spin_lock_irqsave(&card->card_lock, flags);
1119 1098
1120 while (1) { 1099 while (1) {
@@ -1123,7 +1102,7 @@ static int isicom_write(struct tty_struct *tty, const unsigned char *buf,
1123 if (cnt <= 0) 1102 if (cnt <= 0)
1124 break; 1103 break;
1125 1104
1126 memcpy(port->xmit_buf + port->xmit_head, buf, cnt); 1105 memcpy(port->port.xmit_buf + port->xmit_head, buf, cnt);
1127 port->xmit_head = (port->xmit_head + cnt) & (SERIAL_XMIT_SIZE 1106 port->xmit_head = (port->xmit_head + cnt) & (SERIAL_XMIT_SIZE
1128 - 1); 1107 - 1);
1129 port->xmit_cnt += cnt; 1108 port->xmit_cnt += cnt;
@@ -1147,16 +1126,13 @@ static int isicom_put_char(struct tty_struct *tty, unsigned char ch)
1147 if (isicom_paranoia_check(port, tty->name, "isicom_put_char")) 1126 if (isicom_paranoia_check(port, tty->name, "isicom_put_char"))
1148 return 0; 1127 return 0;
1149 1128
1150 if (!port->xmit_buf)
1151 return 0;
1152
1153 spin_lock_irqsave(&card->card_lock, flags); 1129 spin_lock_irqsave(&card->card_lock, flags);
1154 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) { 1130 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) {
1155 spin_unlock_irqrestore(&card->card_lock, flags); 1131 spin_unlock_irqrestore(&card->card_lock, flags);
1156 return 0; 1132 return 0;
1157 } 1133 }
1158 1134
1159 port->xmit_buf[port->xmit_head++] = ch; 1135 port->port.xmit_buf[port->xmit_head++] = ch;
1160 port->xmit_head &= (SERIAL_XMIT_SIZE - 1); 1136 port->xmit_head &= (SERIAL_XMIT_SIZE - 1);
1161 port->xmit_cnt++; 1137 port->xmit_cnt++;
1162 spin_unlock_irqrestore(&card->card_lock, flags); 1138 spin_unlock_irqrestore(&card->card_lock, flags);
@@ -1172,7 +1148,7 @@ static void isicom_flush_chars(struct tty_struct *tty)
1172 return; 1148 return;
1173 1149
1174 if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || 1150 if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
1175 !port->xmit_buf) 1151 !port->port.xmit_buf)
1176 return; 1152 return;
1177 1153
1178 /* this tells the transmitter to consider this port for 1154 /* this tells the transmitter to consider this port for
@@ -1274,23 +1250,23 @@ static int isicom_set_serial_info(struct isi_port *port,
1274 1250
1275 lock_kernel(); 1251 lock_kernel();
1276 1252
1277 reconfig_port = ((port->flags & ASYNC_SPD_MASK) != 1253 reconfig_port = ((port->port.flags & ASYNC_SPD_MASK) !=
1278 (newinfo.flags & ASYNC_SPD_MASK)); 1254 (newinfo.flags & ASYNC_SPD_MASK));
1279 1255
1280 if (!capable(CAP_SYS_ADMIN)) { 1256 if (!capable(CAP_SYS_ADMIN)) {
1281 if ((newinfo.close_delay != port->close_delay) || 1257 if ((newinfo.close_delay != port->port.close_delay) ||
1282 (newinfo.closing_wait != port->closing_wait) || 1258 (newinfo.closing_wait != port->port.closing_wait) ||
1283 ((newinfo.flags & ~ASYNC_USR_MASK) != 1259 ((newinfo.flags & ~ASYNC_USR_MASK) !=
1284 (port->flags & ~ASYNC_USR_MASK))) { 1260 (port->port.flags & ~ASYNC_USR_MASK))) {
1285 unlock_kernel(); 1261 unlock_kernel();
1286 return -EPERM; 1262 return -EPERM;
1287 } 1263 }
1288 port->flags = ((port->flags & ~ASYNC_USR_MASK) | 1264 port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
1289 (newinfo.flags & ASYNC_USR_MASK)); 1265 (newinfo.flags & ASYNC_USR_MASK));
1290 } else { 1266 } else {
1291 port->close_delay = newinfo.close_delay; 1267 port->port.close_delay = newinfo.close_delay;
1292 port->closing_wait = newinfo.closing_wait; 1268 port->port.closing_wait = newinfo.closing_wait;
1293 port->flags = ((port->flags & ~ASYNC_FLAGS) | 1269 port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) |
1294 (newinfo.flags & ASYNC_FLAGS)); 1270 (newinfo.flags & ASYNC_FLAGS));
1295 } 1271 }
1296 if (reconfig_port) { 1272 if (reconfig_port) {
@@ -1314,10 +1290,10 @@ static int isicom_get_serial_info(struct isi_port *port,
1314 out_info.line = port - isi_ports; 1290 out_info.line = port - isi_ports;
1315 out_info.port = port->card->base; 1291 out_info.port = port->card->base;
1316 out_info.irq = port->card->irq; 1292 out_info.irq = port->card->irq;
1317 out_info.flags = port->flags; 1293 out_info.flags = port->port.flags;
1318/* out_info.baud_base = ? */ 1294/* out_info.baud_base = ? */
1319 out_info.close_delay = port->close_delay; 1295 out_info.close_delay = port->port.close_delay;
1320 out_info.closing_wait = port->closing_wait; 1296 out_info.closing_wait = port->port.closing_wait;
1321 unlock_kernel(); 1297 unlock_kernel();
1322 if (copy_to_user(info, &out_info, sizeof(out_info))) 1298 if (copy_to_user(info, &out_info, sizeof(out_info)))
1323 return -EFAULT; 1299 return -EFAULT;
@@ -1454,10 +1430,10 @@ static void isicom_hangup(struct tty_struct *tty)
1454 isicom_shutdown_port(port); 1430 isicom_shutdown_port(port);
1455 spin_unlock_irqrestore(&port->card->card_lock, flags); 1431 spin_unlock_irqrestore(&port->card->card_lock, flags);
1456 1432
1457 port->count = 0; 1433 port->port.count = 0;
1458 port->flags &= ~ASYNC_NORMAL_ACTIVE; 1434 port->port.flags &= ~ASYNC_NORMAL_ACTIVE;
1459 port->tty = NULL; 1435 port->port.tty = NULL;
1460 wake_up_interruptible(&port->open_wait); 1436 wake_up_interruptible(&port->port.open_wait);
1461} 1437}
1462 1438
1463 1439
@@ -1736,6 +1712,12 @@ static int __devinit isicom_probe(struct pci_dev *pdev,
1736 if (card_count >= BOARD_COUNT) 1712 if (card_count >= BOARD_COUNT)
1737 goto err; 1713 goto err;
1738 1714
1715 retval = pci_enable_device(pdev);
1716 if (retval) {
1717 dev_err(&pdev->dev, "failed to enable\n");
1718 goto err;
1719 }
1720
1739 dev_info(&pdev->dev, "ISI PCI Card(Device ID 0x%x)\n", ent->device); 1721 dev_info(&pdev->dev, "ISI PCI Card(Device ID 0x%x)\n", ent->device);
1740 1722
1741 /* allot the first empty slot in the array */ 1723 /* allot the first empty slot in the array */
@@ -1790,6 +1772,7 @@ errunrr:
1790errdec: 1772errdec:
1791 board->base = 0; 1773 board->base = 0;
1792 card_count--; 1774 card_count--;
1775 pci_disable_device(pdev);
1793err: 1776err:
1794 return retval; 1777 return retval;
1795} 1778}
@@ -1806,6 +1789,7 @@ static void __devexit isicom_remove(struct pci_dev *pdev)
1806 pci_release_region(pdev, 3); 1789 pci_release_region(pdev, 3);
1807 board->base = 0; 1790 board->base = 0;
1808 card_count--; 1791 card_count--;
1792 pci_disable_device(pdev);
1809} 1793}
1810 1794
1811static int __init isicom_init(void) 1795static int __init isicom_init(void)
@@ -1818,14 +1802,13 @@ static int __init isicom_init(void)
1818 isi_card[idx].ports = port; 1802 isi_card[idx].ports = port;
1819 spin_lock_init(&isi_card[idx].card_lock); 1803 spin_lock_init(&isi_card[idx].card_lock);
1820 for (channel = 0; channel < 16; channel++, port++) { 1804 for (channel = 0; channel < 16; channel++, port++) {
1805 tty_port_init(&port->port);
1821 port->magic = ISICOM_MAGIC; 1806 port->magic = ISICOM_MAGIC;
1822 port->card = &isi_card[idx]; 1807 port->card = &isi_card[idx];
1823 port->channel = channel; 1808 port->channel = channel;
1824 port->close_delay = 50 * HZ/100; 1809 port->port.close_delay = 50 * HZ/100;
1825 port->closing_wait = 3000 * HZ/100; 1810 port->port.closing_wait = 3000 * HZ/100;
1826 port->status = 0; 1811 port->status = 0;
1827 init_waitqueue_head(&port->open_wait);
1828 init_waitqueue_head(&port->close_wait);
1829 /* . . . */ 1812 /* . . . */
1830 } 1813 }
1831 isi_card[idx].base = 0; 1814 isi_card[idx].base = 0;