aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/rocket.c
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-07-16 16:56:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-20 20:12:37 -0400
commite60a10844879794c7b592acf123cbf9ea0e2c0e7 (patch)
tree48aad5909524bdfa08c99c29164f40e3be7ac2d4 /drivers/char/rocket.c
parent0ad9e7d1d6bf7829912be50d24d4f3f473006326 (diff)
rocket: use tty_port
Switch the rocketport to use the new tty_port structure Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/rocket.c')
-rw-r--r--drivers/char/rocket.c116
1 files changed, 58 insertions, 58 deletions
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index 743dc80a9325..bc35b900f9c6 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -434,15 +434,15 @@ static void rp_do_transmit(struct r_port *info)
434#endif 434#endif
435 if (!info) 435 if (!info)
436 return; 436 return;
437 if (!info->tty) { 437 if (!info->port.tty) {
438 printk(KERN_WARNING "rp: WARNING %s called with " 438 printk(KERN_WARNING "rp: WARNING %s called with "
439 "info->tty==NULL\n", __func__); 439 "info->port.tty==NULL\n", __func__);
440 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); 440 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
441 return; 441 return;
442 } 442 }
443 443
444 spin_lock_irqsave(&info->slock, flags); 444 spin_lock_irqsave(&info->slock, flags);
445 tty = info->tty; 445 tty = info->port.tty;
446 info->xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp); 446 info->xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp);
447 447
448 /* Loop sending data to FIFO until done or FIFO full */ 448 /* Loop sending data to FIFO until done or FIFO full */
@@ -502,13 +502,13 @@ static void rp_handle_port(struct r_port *info)
502 "info->flags & NOT_INIT\n"); 502 "info->flags & NOT_INIT\n");
503 return; 503 return;
504 } 504 }
505 if (!info->tty) { 505 if (!info->port.tty) {
506 printk(KERN_WARNING "rp: WARNING: rp_handle_port called with " 506 printk(KERN_WARNING "rp: WARNING: rp_handle_port called with "
507 "info->tty==NULL\n"); 507 "info->port.tty==NULL\n");
508 return; 508 return;
509 } 509 }
510 cp = &info->channel; 510 cp = &info->channel;
511 tty = info->tty; 511 tty = info->port.tty;
512 512
513 IntMask = sGetChanIntID(cp) & info->intmask; 513 IntMask = sGetChanIntID(cp) & info->intmask;
514#ifdef ROCKET_DEBUG_INTR 514#ifdef ROCKET_DEBUG_INTR
@@ -530,7 +530,7 @@ static void rp_handle_port(struct r_port *info)
530 tty_hangup(tty); 530 tty_hangup(tty);
531 } 531 }
532 info->cd_status = (ChanStatus & CD_ACT) ? 1 : 0; 532 info->cd_status = (ChanStatus & CD_ACT) ? 1 : 0;
533 wake_up_interruptible(&info->open_wait); 533 wake_up_interruptible(&info->port.open_wait);
534 } 534 }
535#ifdef ROCKET_DEBUG_INTR 535#ifdef ROCKET_DEBUG_INTR
536 if (IntMask & DELTA_CTS) { /* CTS change */ 536 if (IntMask & DELTA_CTS) { /* CTS change */
@@ -650,7 +650,7 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
650 info->chan = chan; 650 info->chan = chan;
651 info->closing_wait = 3000; 651 info->closing_wait = 3000;
652 info->close_delay = 50; 652 info->close_delay = 50;
653 init_waitqueue_head(&info->open_wait); 653 init_waitqueue_head(&info->port.open_wait);
654 init_completion(&info->close_wait); 654 init_completion(&info->close_wait);
655 info->flags &= ~ROCKET_MODE_MASK; 655 info->flags &= ~ROCKET_MODE_MASK;
656 switch (pc104[board][line]) { 656 switch (pc104[board][line]) {
@@ -717,7 +717,7 @@ static void configure_r_port(struct r_port *info,
717 unsigned rocketMode; 717 unsigned rocketMode;
718 int bits, baud, divisor; 718 int bits, baud, divisor;
719 CHANNEL_t *cp; 719 CHANNEL_t *cp;
720 struct ktermios *t = info->tty->termios; 720 struct ktermios *t = info->port.tty->termios;
721 721
722 cp = &info->channel; 722 cp = &info->channel;
723 cflag = t->c_cflag; 723 cflag = t->c_cflag;
@@ -750,7 +750,7 @@ static void configure_r_port(struct r_port *info,
750 } 750 }
751 751
752 /* baud rate */ 752 /* baud rate */
753 baud = tty_get_baud_rate(info->tty); 753 baud = tty_get_baud_rate(info->port.tty);
754 if (!baud) 754 if (!baud)
755 baud = 9600; 755 baud = 9600;
756 divisor = ((rp_baud_base[info->board] + (baud >> 1)) / baud) - 1; 756 divisor = ((rp_baud_base[info->board] + (baud >> 1)) / baud) - 1;
@@ -768,7 +768,7 @@ static void configure_r_port(struct r_port *info,
768 sSetBaud(cp, divisor); 768 sSetBaud(cp, divisor);
769 769
770 /* FIXME: Should really back compute a baud rate from the divisor */ 770 /* FIXME: Should really back compute a baud rate from the divisor */
771 tty_encode_baud_rate(info->tty, baud, baud); 771 tty_encode_baud_rate(info->port.tty, baud, baud);
772 772
773 if (cflag & CRTSCTS) { 773 if (cflag & CRTSCTS) {
774 info->intmask |= DELTA_CTS; 774 info->intmask |= DELTA_CTS;
@@ -793,15 +793,15 @@ static void configure_r_port(struct r_port *info,
793 * Handle software flow control in the board 793 * Handle software flow control in the board
794 */ 794 */
795#ifdef ROCKET_SOFT_FLOW 795#ifdef ROCKET_SOFT_FLOW
796 if (I_IXON(info->tty)) { 796 if (I_IXON(info->port.tty)) {
797 sEnTxSoftFlowCtl(cp); 797 sEnTxSoftFlowCtl(cp);
798 if (I_IXANY(info->tty)) { 798 if (I_IXANY(info->port.tty)) {
799 sEnIXANY(cp); 799 sEnIXANY(cp);
800 } else { 800 } else {
801 sDisIXANY(cp); 801 sDisIXANY(cp);
802 } 802 }
803 sSetTxXONChar(cp, START_CHAR(info->tty)); 803 sSetTxXONChar(cp, START_CHAR(info->port.tty));
804 sSetTxXOFFChar(cp, STOP_CHAR(info->tty)); 804 sSetTxXOFFChar(cp, STOP_CHAR(info->port.tty));
805 } else { 805 } else {
806 sDisTxSoftFlowCtl(cp); 806 sDisTxSoftFlowCtl(cp);
807 sDisIXANY(cp); 807 sDisIXANY(cp);
@@ -813,24 +813,24 @@ static void configure_r_port(struct r_port *info,
813 * Set up ignore/read mask words 813 * Set up ignore/read mask words
814 */ 814 */
815 info->read_status_mask = STMRCVROVRH | 0xFF; 815 info->read_status_mask = STMRCVROVRH | 0xFF;
816 if (I_INPCK(info->tty)) 816 if (I_INPCK(info->port.tty))
817 info->read_status_mask |= STMFRAMEH | STMPARITYH; 817 info->read_status_mask |= STMFRAMEH | STMPARITYH;
818 if (I_BRKINT(info->tty) || I_PARMRK(info->tty)) 818 if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
819 info->read_status_mask |= STMBREAKH; 819 info->read_status_mask |= STMBREAKH;
820 820
821 /* 821 /*
822 * Characters to ignore 822 * Characters to ignore
823 */ 823 */
824 info->ignore_status_mask = 0; 824 info->ignore_status_mask = 0;
825 if (I_IGNPAR(info->tty)) 825 if (I_IGNPAR(info->port.tty))
826 info->ignore_status_mask |= STMFRAMEH | STMPARITYH; 826 info->ignore_status_mask |= STMFRAMEH | STMPARITYH;
827 if (I_IGNBRK(info->tty)) { 827 if (I_IGNBRK(info->port.tty)) {
828 info->ignore_status_mask |= STMBREAKH; 828 info->ignore_status_mask |= STMBREAKH;
829 /* 829 /*
830 * If we're ignoring parity and break indicators, 830 * If we're ignoring parity and break indicators,
831 * ignore overruns too. (For real raw support). 831 * ignore overruns too. (For real raw support).
832 */ 832 */
833 if (I_IGNPAR(info->tty)) 833 if (I_IGNPAR(info->port.tty))
834 info->ignore_status_mask |= STMRCVROVRH; 834 info->ignore_status_mask |= STMRCVROVRH;
835 } 835 }
836 836
@@ -863,7 +863,7 @@ static void configure_r_port(struct r_port *info,
863 } 863 }
864} 864}
865 865
866/* info->count is considered critical, protected by spinlocks. */ 866/* info->port.count is considered critical, protected by spinlocks. */
867static int block_til_ready(struct tty_struct *tty, struct file *filp, 867static int block_til_ready(struct tty_struct *tty, struct file *filp,
868 struct r_port *info) 868 struct r_port *info)
869{ 869{
@@ -897,13 +897,13 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
897 897
898 /* 898 /*
899 * Block waiting for the carrier detect and the line to become free. While we are in 899 * Block waiting for the carrier detect and the line to become free. While we are in
900 * this loop, info->count is dropped by one, so that rp_close() knows when to free things. 900 * this loop, info->port.count is dropped by one, so that rp_close() knows when to free things.
901 * We restore it upon exit, either normal or abnormal. 901 * We restore it upon exit, either normal or abnormal.
902 */ 902 */
903 retval = 0; 903 retval = 0;
904 add_wait_queue(&info->open_wait, &wait); 904 add_wait_queue(&info->port.open_wait, &wait);
905#ifdef ROCKET_DEBUG_OPEN 905#ifdef ROCKET_DEBUG_OPEN
906 printk(KERN_INFO "block_til_ready before block: ttyR%d, count = %d\n", info->line, info->count); 906 printk(KERN_INFO "block_til_ready before block: ttyR%d, count = %d\n", info->line, info->port.count);
907#endif 907#endif
908 spin_lock_irqsave(&info->slock, flags); 908 spin_lock_irqsave(&info->slock, flags);
909 909
@@ -912,10 +912,10 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
912#else 912#else
913 if (!tty_hung_up_p(filp)) { 913 if (!tty_hung_up_p(filp)) {
914 extra_count = 1; 914 extra_count = 1;
915 info->count--; 915 info->port.count--;
916 } 916 }
917#endif 917#endif
918 info->blocked_open++; 918 info->port.blocked_open++;
919 919
920 spin_unlock_irqrestore(&info->slock, flags); 920 spin_unlock_irqrestore(&info->slock, flags);
921 921
@@ -940,24 +940,24 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
940 } 940 }
941#ifdef ROCKET_DEBUG_OPEN 941#ifdef ROCKET_DEBUG_OPEN
942 printk(KERN_INFO "block_til_ready blocking: ttyR%d, count = %d, flags=0x%0x\n", 942 printk(KERN_INFO "block_til_ready blocking: ttyR%d, count = %d, flags=0x%0x\n",
943 info->line, info->count, info->flags); 943 info->line, info->port.count, info->flags);
944#endif 944#endif
945 schedule(); /* Don't hold spinlock here, will hang PC */ 945 schedule(); /* Don't hold spinlock here, will hang PC */
946 } 946 }
947 __set_current_state(TASK_RUNNING); 947 __set_current_state(TASK_RUNNING);
948 remove_wait_queue(&info->open_wait, &wait); 948 remove_wait_queue(&info->port.open_wait, &wait);
949 949
950 spin_lock_irqsave(&info->slock, flags); 950 spin_lock_irqsave(&info->slock, flags);
951 951
952 if (extra_count) 952 if (extra_count)
953 info->count++; 953 info->port.count++;
954 info->blocked_open--; 954 info->port.blocked_open--;
955 955
956 spin_unlock_irqrestore(&info->slock, flags); 956 spin_unlock_irqrestore(&info->slock, flags);
957 957
958#ifdef ROCKET_DEBUG_OPEN 958#ifdef ROCKET_DEBUG_OPEN
959 printk(KERN_INFO "block_til_ready after blocking: ttyR%d, count = %d\n", 959 printk(KERN_INFO "block_til_ready after blocking: ttyR%d, count = %d\n",
960 info->line, info->count); 960 info->line, info->port.count);
961#endif 961#endif
962 if (retval) 962 if (retval)
963 return retval; 963 return retval;
@@ -1001,9 +1001,9 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
1001 info->xmit_buf = (unsigned char *) page; 1001 info->xmit_buf = (unsigned char *) page;
1002 1002
1003 tty->driver_data = info; 1003 tty->driver_data = info;
1004 info->tty = tty; 1004 info->port.tty = tty;
1005 1005
1006 if (info->count++ == 0) { 1006 if (info->port.count++ == 0) {
1007 atomic_inc(&rp_num_ports_open); 1007 atomic_inc(&rp_num_ports_open);
1008 1008
1009#ifdef ROCKET_DEBUG_OPEN 1009#ifdef ROCKET_DEBUG_OPEN
@@ -1012,7 +1012,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
1012#endif 1012#endif
1013 } 1013 }
1014#ifdef ROCKET_DEBUG_OPEN 1014#ifdef ROCKET_DEBUG_OPEN
1015 printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->count); 1015 printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
1016#endif 1016#endif
1017 1017
1018 /* 1018 /*
@@ -1048,13 +1048,13 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
1048 * Set up the tty->alt_speed kludge 1048 * Set up the tty->alt_speed kludge
1049 */ 1049 */
1050 if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI) 1050 if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI)
1051 info->tty->alt_speed = 57600; 1051 info->port.tty->alt_speed = 57600;
1052 if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI) 1052 if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI)
1053 info->tty->alt_speed = 115200; 1053 info->port.tty->alt_speed = 115200;
1054 if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI) 1054 if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI)
1055 info->tty->alt_speed = 230400; 1055 info->port.tty->alt_speed = 230400;
1056 if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP) 1056 if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP)
1057 info->tty->alt_speed = 460800; 1057 info->port.tty->alt_speed = 460800;
1058 1058
1059 configure_r_port(info, NULL); 1059 configure_r_port(info, NULL);
1060 if (tty->termios->c_cflag & CBAUD) { 1060 if (tty->termios->c_cflag & CBAUD) {
@@ -1076,7 +1076,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
1076} 1076}
1077 1077
1078/* 1078/*
1079 * Exception handler that closes a serial port. info->count is considered critical. 1079 * Exception handler that closes a serial port. info->port.count is considered critical.
1080 */ 1080 */
1081static void rp_close(struct tty_struct *tty, struct file *filp) 1081static void rp_close(struct tty_struct *tty, struct file *filp)
1082{ 1082{
@@ -1089,14 +1089,14 @@ static void rp_close(struct tty_struct *tty, struct file *filp)
1089 return; 1089 return;
1090 1090
1091#ifdef ROCKET_DEBUG_OPEN 1091#ifdef ROCKET_DEBUG_OPEN
1092 printk(KERN_INFO "rp_close ttyR%d, count = %d\n", info->line, info->count); 1092 printk(KERN_INFO "rp_close ttyR%d, count = %d\n", info->line, info->port.count);
1093#endif 1093#endif
1094 1094
1095 if (tty_hung_up_p(filp)) 1095 if (tty_hung_up_p(filp))
1096 return; 1096 return;
1097 spin_lock_irqsave(&info->slock, flags); 1097 spin_lock_irqsave(&info->slock, flags);
1098 1098
1099 if ((tty->count == 1) && (info->count != 1)) { 1099 if ((tty->count == 1) && (info->port.count != 1)) {
1100 /* 1100 /*
1101 * Uh, oh. tty->count is 1, which means that the tty 1101 * Uh, oh. tty->count is 1, which means that the tty
1102 * structure will be freed. Info->count should always 1102 * structure will be freed. Info->count should always
@@ -1105,15 +1105,15 @@ static void rp_close(struct tty_struct *tty, struct file *filp)
1105 * serial port won't be shutdown. 1105 * serial port won't be shutdown.
1106 */ 1106 */
1107 printk(KERN_WARNING "rp_close: bad serial port count; " 1107 printk(KERN_WARNING "rp_close: bad serial port count; "
1108 "tty->count is 1, info->count is %d\n", info->count); 1108 "tty->count is 1, info->port.count is %d\n", info->port.count);
1109 info->count = 1; 1109 info->port.count = 1;
1110 } 1110 }
1111 if (--info->count < 0) { 1111 if (--info->port.count < 0) {
1112 printk(KERN_WARNING "rp_close: bad serial port count for " 1112 printk(KERN_WARNING "rp_close: bad serial port count for "
1113 "ttyR%d: %d\n", info->line, info->count); 1113 "ttyR%d: %d\n", info->line, info->port.count);
1114 info->count = 0; 1114 info->port.count = 0;
1115 } 1115 }
1116 if (info->count) { 1116 if (info->port.count) {
1117 spin_unlock_irqrestore(&info->slock, flags); 1117 spin_unlock_irqrestore(&info->slock, flags);
1118 return; 1118 return;
1119 } 1119 }
@@ -1167,11 +1167,11 @@ static void rp_close(struct tty_struct *tty, struct file *filp)
1167 1167
1168 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); 1168 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
1169 1169
1170 if (info->blocked_open) { 1170 if (info->port.blocked_open) {
1171 if (info->close_delay) { 1171 if (info->close_delay) {
1172 msleep_interruptible(jiffies_to_msecs(info->close_delay)); 1172 msleep_interruptible(jiffies_to_msecs(info->close_delay));
1173 } 1173 }
1174 wake_up_interruptible(&info->open_wait); 1174 wake_up_interruptible(&info->port.open_wait);
1175 } else { 1175 } else {
1176 if (info->xmit_buf) { 1176 if (info->xmit_buf) {
1177 free_page((unsigned long) info->xmit_buf); 1177 free_page((unsigned long) info->xmit_buf);
@@ -1357,13 +1357,13 @@ static int set_config(struct r_port *info, struct rocket_config __user *new_info
1357 info->closing_wait = new_serial.closing_wait; 1357 info->closing_wait = new_serial.closing_wait;
1358 1358
1359 if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI) 1359 if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI)
1360 info->tty->alt_speed = 57600; 1360 info->port.tty->alt_speed = 57600;
1361 if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI) 1361 if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI)
1362 info->tty->alt_speed = 115200; 1362 info->port.tty->alt_speed = 115200;
1363 if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI) 1363 if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI)
1364 info->tty->alt_speed = 230400; 1364 info->port.tty->alt_speed = 230400;
1365 if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP) 1365 if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP)
1366 info->tty->alt_speed = 460800; 1366 info->port.tty->alt_speed = 460800;
1367 1367
1368 configure_r_port(info, NULL); 1368 configure_r_port(info, NULL);
1369 return 0; 1369 return 0;
@@ -1636,13 +1636,13 @@ static void rp_hangup(struct tty_struct *tty)
1636 rp_flush_buffer(tty); 1636 rp_flush_buffer(tty);
1637 if (info->flags & ROCKET_CLOSING) 1637 if (info->flags & ROCKET_CLOSING)
1638 return; 1638 return;
1639 if (info->count) 1639 if (info->port.count)
1640 atomic_dec(&rp_num_ports_open); 1640 atomic_dec(&rp_num_ports_open);
1641 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); 1641 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
1642 1642
1643 info->count = 0; 1643 info->port.count = 0;
1644 info->flags &= ~ROCKET_NORMAL_ACTIVE; 1644 info->flags &= ~ROCKET_NORMAL_ACTIVE;
1645 info->tty = NULL; 1645 info->port.tty = NULL;
1646 1646
1647 cp = &info->channel; 1647 cp = &info->channel;
1648 sDisRxFIFO(cp); 1648 sDisRxFIFO(cp);
@@ -1653,7 +1653,7 @@ static void rp_hangup(struct tty_struct *tty)
1653 sClrTxXOFF(cp); 1653 sClrTxXOFF(cp);
1654 info->flags &= ~ROCKET_INITIALIZED; 1654 info->flags &= ~ROCKET_INITIALIZED;
1655 1655
1656 wake_up_interruptible(&info->open_wait); 1656 wake_up_interruptible(&info->port.open_wait);
1657} 1657}
1658 1658
1659/* 1659/*
@@ -1762,7 +1762,7 @@ static int rp_write(struct tty_struct *tty,
1762 1762
1763 /* Write remaining data into the port's xmit_buf */ 1763 /* Write remaining data into the port's xmit_buf */
1764 while (1) { 1764 while (1) {
1765 if (!info->tty) /* Seemingly obligatory check... */ 1765 if (!info->port.tty) /* Seemingly obligatory check... */
1766 goto end; 1766 goto end;
1767 c = min(count, XMIT_BUF_SIZE - info->xmit_cnt - 1); 1767 c = min(count, XMIT_BUF_SIZE - info->xmit_cnt - 1);
1768 c = min(c, XMIT_BUF_SIZE - info->xmit_head); 1768 c = min(c, XMIT_BUF_SIZE - info->xmit_head);