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

stallion: use tty_port

Switch the stallion driver to use the tty_port structure

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
f8ae4764 b1d1619b

+81 -85
+80 -80
drivers/char/stallion.c
··· 613 613 { 614 614 unsigned int oldsigs = portp->sigs; 615 615 616 - if (!portp->tty) 616 + if (!portp->port.tty) 617 617 return; 618 618 619 619 portp->sigs = stl_getsignals(portp); 620 620 621 621 if ((portp->sigs & TIOCM_CD) && ((oldsigs & TIOCM_CD) == 0)) 622 - wake_up_interruptible(&portp->open_wait); 622 + wake_up_interruptible(&portp->port.open_wait); 623 623 624 624 if ((oldsigs & TIOCM_CD) && ((portp->sigs & TIOCM_CD) == 0)) 625 - if (portp->flags & ASYNC_CHECK_CD) 626 - tty_hangup(portp->tty); 625 + if (portp->port.flags & ASYNC_CHECK_CD) 626 + tty_hangup(portp->port.tty); 627 627 } 628 628 629 629 /* ··· 734 734 * On the first open of the device setup the port hardware, and 735 735 * initialize the per port data structure. 736 736 */ 737 - portp->tty = tty; 737 + portp->port.tty = tty; 738 738 tty->driver_data = portp; 739 - portp->refcount++; 739 + portp->port.count++; 740 740 741 - if ((portp->flags & ASYNC_INITIALIZED) == 0) { 741 + if ((portp->port.flags & ASYNC_INITIALIZED) == 0) { 742 742 if (!portp->tx.buf) { 743 743 portp->tx.buf = kmalloc(STL_TXBUFSIZE, GFP_KERNEL); 744 744 if (!portp->tx.buf) ··· 752 752 stl_enablerxtx(portp, 1, 1); 753 753 stl_startrxtx(portp, 1, 0); 754 754 clear_bit(TTY_IO_ERROR, &tty->flags); 755 - portp->flags |= ASYNC_INITIALIZED; 755 + portp->port.flags |= ASYNC_INITIALIZED; 756 756 } 757 757 758 758 /* ··· 761 761 * The sleep here does not need interrupt protection since the wakeup 762 762 * for it is done with the same context. 763 763 */ 764 - if (portp->flags & ASYNC_CLOSING) { 765 - interruptible_sleep_on(&portp->close_wait); 766 - if (portp->flags & ASYNC_HUP_NOTIFY) 764 + if (portp->port.flags & ASYNC_CLOSING) { 765 + interruptible_sleep_on(&portp->port.close_wait); 766 + if (portp->port.flags & ASYNC_HUP_NOTIFY) 767 767 return -EAGAIN; 768 768 return -ERESTARTSYS; 769 769 } ··· 777 777 if ((rc = stl_waitcarrier(portp, filp)) != 0) 778 778 return rc; 779 779 780 - portp->flags |= ASYNC_NORMAL_ACTIVE; 780 + portp->port.flags |= ASYNC_NORMAL_ACTIVE; 781 781 782 782 return 0; 783 783 } ··· 801 801 802 802 spin_lock_irqsave(&stallion_lock, flags); 803 803 804 - if (portp->tty->termios->c_cflag & CLOCAL) 804 + if (portp->port.tty->termios->c_cflag & CLOCAL) 805 805 doclocal++; 806 806 807 807 portp->openwaitcnt++; 808 808 if (! tty_hung_up_p(filp)) 809 - portp->refcount--; 809 + portp->port.count--; 810 810 811 811 for (;;) { 812 812 /* Takes brd_lock internally */ 813 813 stl_setsignals(portp, 1, 1); 814 814 if (tty_hung_up_p(filp) || 815 - ((portp->flags & ASYNC_INITIALIZED) == 0)) { 816 - if (portp->flags & ASYNC_HUP_NOTIFY) 815 + ((portp->port.flags & ASYNC_INITIALIZED) == 0)) { 816 + if (portp->port.flags & ASYNC_HUP_NOTIFY) 817 817 rc = -EBUSY; 818 818 else 819 819 rc = -ERESTARTSYS; 820 820 break; 821 821 } 822 - if (((portp->flags & ASYNC_CLOSING) == 0) && 822 + if (((portp->port.flags & ASYNC_CLOSING) == 0) && 823 823 (doclocal || (portp->sigs & TIOCM_CD))) 824 824 break; 825 825 if (signal_pending(current)) { ··· 827 827 break; 828 828 } 829 829 /* FIXME */ 830 - interruptible_sleep_on(&portp->open_wait); 830 + interruptible_sleep_on(&portp->port.open_wait); 831 831 } 832 832 833 833 if (! tty_hung_up_p(filp)) 834 - portp->refcount++; 834 + portp->port.count++; 835 835 portp->openwaitcnt--; 836 836 spin_unlock_irqrestore(&stallion_lock, flags); 837 837 ··· 904 904 spin_unlock_irqrestore(&stallion_lock, flags); 905 905 return; 906 906 } 907 - if ((tty->count == 1) && (portp->refcount != 1)) 908 - portp->refcount = 1; 909 - if (portp->refcount-- > 1) { 907 + if ((tty->count == 1) && (portp->port.count != 1)) 908 + portp->port.count = 1; 909 + if (portp->port.count-- > 1) { 910 910 spin_unlock_irqrestore(&stallion_lock, flags); 911 911 return; 912 912 } 913 913 914 - portp->refcount = 0; 915 - portp->flags |= ASYNC_CLOSING; 914 + portp->port.count = 0; 915 + portp->port.flags |= ASYNC_CLOSING; 916 916 917 917 /* 918 918 * May want to wait for any data to drain before closing. The BUSY ··· 930 930 931 931 932 932 spin_lock_irqsave(&stallion_lock, flags); 933 - portp->flags &= ~ASYNC_INITIALIZED; 933 + portp->port.flags &= ~ASYNC_INITIALIZED; 934 934 spin_unlock_irqrestore(&stallion_lock, flags); 935 935 936 936 stl_disableintrs(portp); ··· 949 949 tty_ldisc_flush(tty); 950 950 951 951 tty->closing = 0; 952 - portp->tty = NULL; 952 + portp->port.tty = NULL; 953 953 954 954 if (portp->openwaitcnt) { 955 955 if (portp->close_delay) 956 956 msleep_interruptible(jiffies_to_msecs(portp->close_delay)); 957 - wake_up_interruptible(&portp->open_wait); 957 + wake_up_interruptible(&portp->port.open_wait); 958 958 } 959 959 960 - portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 961 - wake_up_interruptible(&portp->close_wait); 960 + portp->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 961 + wake_up_interruptible(&portp->port.close_wait); 962 962 } 963 963 964 964 /*****************************************************************************/ ··· 1153 1153 memset(&sio, 0, sizeof(struct serial_struct)); 1154 1154 sio.line = portp->portnr; 1155 1155 sio.port = portp->ioaddr; 1156 - sio.flags = portp->flags; 1156 + sio.flags = portp->port.flags; 1157 1157 sio.baud_base = portp->baud_base; 1158 1158 sio.close_delay = portp->close_delay; 1159 1159 sio.closing_wait = portp->closing_wait; ··· 1194 1194 if ((sio.baud_base != portp->baud_base) || 1195 1195 (sio.close_delay != portp->close_delay) || 1196 1196 ((sio.flags & ~ASYNC_USR_MASK) != 1197 - (portp->flags & ~ASYNC_USR_MASK))) 1197 + (portp->port.flags & ~ASYNC_USR_MASK))) 1198 1198 return -EPERM; 1199 1199 } 1200 1200 1201 - portp->flags = (portp->flags & ~ASYNC_USR_MASK) | 1201 + portp->port.flags = (portp->port.flags & ~ASYNC_USR_MASK) | 1202 1202 (sio.flags & ASYNC_USR_MASK); 1203 1203 portp->baud_base = sio.baud_base; 1204 1204 portp->close_delay = sio.close_delay; 1205 1205 portp->closing_wait = sio.closing_wait; 1206 1206 portp->custom_divisor = sio.custom_divisor; 1207 - stl_setport(portp, portp->tty->termios); 1207 + stl_setport(portp, portp->port.tty->termios); 1208 1208 return 0; 1209 1209 } 1210 1210 ··· 1353 1353 stl_start(tty); 1354 1354 } 1355 1355 if (((old->c_cflag & CLOCAL) == 0) && (tiosp->c_cflag & CLOCAL)) 1356 - wake_up_interruptible(&portp->open_wait); 1356 + wake_up_interruptible(&portp->port.open_wait); 1357 1357 } 1358 1358 1359 1359 /*****************************************************************************/ ··· 1438 1438 if (portp == NULL) 1439 1439 return; 1440 1440 1441 - portp->flags &= ~ASYNC_INITIALIZED; 1441 + portp->port.flags &= ~ASYNC_INITIALIZED; 1442 1442 stl_disableintrs(portp); 1443 1443 if (tty->termios->c_cflag & HUPCL) 1444 1444 stl_setsignals(portp, 0, 0); ··· 1452 1452 portp->tx.head = NULL; 1453 1453 portp->tx.tail = NULL; 1454 1454 } 1455 - portp->tty = NULL; 1456 - portp->flags &= ~ASYNC_NORMAL_ACTIVE; 1457 - portp->refcount = 0; 1458 - wake_up_interruptible(&portp->open_wait); 1455 + portp->port.tty = NULL; 1456 + portp->port.flags &= ~ASYNC_NORMAL_ACTIVE; 1457 + portp->port.count = 0; 1458 + wake_up_interruptible(&portp->port.open_wait); 1459 1459 } 1460 1460 1461 1461 /*****************************************************************************/ ··· 1814 1814 portp->baud_base = STL_BAUDBASE; 1815 1815 portp->close_delay = STL_CLOSEDELAY; 1816 1816 portp->closing_wait = 30 * HZ; 1817 - init_waitqueue_head(&portp->open_wait); 1818 - init_waitqueue_head(&portp->close_wait); 1817 + init_waitqueue_head(&portp->port.open_wait); 1818 + init_waitqueue_head(&portp->port.close_wait); 1819 1819 portp->stats.brd = portp->brdnr; 1820 1820 portp->stats.panel = portp->panelnr; 1821 1821 portp->stats.port = portp->portnr; ··· 1840 1840 portp = panelp->ports[k]; 1841 1841 if (portp == NULL) 1842 1842 continue; 1843 - if (portp->tty != NULL) 1844 - stl_hangup(portp->tty); 1843 + if (portp->port.tty != NULL) 1844 + stl_hangup(portp->port.tty); 1845 1845 kfree(portp->tx.buf); 1846 1846 kfree(portp); 1847 1847 } ··· 2513 2513 } 2514 2514 2515 2515 portp->stats.state = portp->istate; 2516 - portp->stats.flags = portp->flags; 2516 + portp->stats.flags = portp->port.flags; 2517 2517 portp->stats.hwid = portp->hwid; 2518 2518 2519 2519 portp->stats.ttystate = 0; ··· 2524 2524 portp->stats.rxbuffered = 0; 2525 2525 2526 2526 spin_lock_irqsave(&stallion_lock, flags); 2527 - if (portp->tty != NULL) 2528 - if (portp->tty->driver_data == portp) { 2529 - portp->stats.ttystate = portp->tty->flags; 2527 + if (portp->port.tty != NULL) 2528 + if (portp->port.tty->driver_data == portp) { 2529 + portp->stats.ttystate = portp->port.tty->flags; 2530 2530 /* No longer available as a statistic */ 2531 - portp->stats.rxbuffered = 1; /*portp->tty->flip.count; */ 2532 - if (portp->tty->termios != NULL) { 2533 - portp->stats.cflags = portp->tty->termios->c_cflag; 2534 - portp->stats.iflags = portp->tty->termios->c_iflag; 2535 - portp->stats.oflags = portp->tty->termios->c_oflag; 2536 - portp->stats.lflags = portp->tty->termios->c_lflag; 2531 + portp->stats.rxbuffered = 1; /*portp->port.tty->flip.count; */ 2532 + if (portp->port.tty->termios != NULL) { 2533 + portp->stats.cflags = portp->port.tty->termios->c_cflag; 2534 + portp->stats.iflags = portp->port.tty->termios->c_iflag; 2535 + portp->stats.oflags = portp->port.tty->termios->c_oflag; 2536 + portp->stats.lflags = portp->port.tty->termios->c_lflag; 2537 2537 } 2538 2538 } 2539 2539 spin_unlock_irqrestore(&stallion_lock, flags); ··· 2939 2939 } 2940 2940 baudrate = stl_baudrates[baudrate]; 2941 2941 if ((tiosp->c_cflag & CBAUD) == B38400) { 2942 - if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 2942 + if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 2943 2943 baudrate = 57600; 2944 - else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 2944 + else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 2945 2945 baudrate = 115200; 2946 - else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) 2946 + else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) 2947 2947 baudrate = 230400; 2948 - else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 2948 + else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 2949 2949 baudrate = 460800; 2950 - else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) 2950 + else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) 2951 2951 baudrate = (portp->baud_base / portp->custom_divisor); 2952 2952 } 2953 2953 if (baudrate > STL_CD1400MAXBAUD) ··· 2969 2969 mcor1 |= MCOR1_DCD; 2970 2970 mcor2 |= MCOR2_DCD; 2971 2971 sreron |= SRER_MODEM; 2972 - portp->flags |= ASYNC_CHECK_CD; 2972 + portp->port.flags |= ASYNC_CHECK_CD; 2973 2973 } else 2974 - portp->flags &= ~ASYNC_CHECK_CD; 2974 + portp->port.flags &= ~ASYNC_CHECK_CD; 2975 2975 2976 2976 /* 2977 2977 * Setup cd1400 enhanced modes if we can. In particular we want to ··· 3242 3242 3243 3243 if (portp == NULL) 3244 3244 return; 3245 - tty = portp->tty; 3245 + tty = portp->port.tty; 3246 3246 if (tty == NULL) 3247 3247 return; 3248 3248 ··· 3304 3304 3305 3305 if (portp == NULL) 3306 3306 return; 3307 - tty = portp->tty; 3307 + tty = portp->port.tty; 3308 3308 if (tty == NULL) 3309 3309 return; 3310 3310 ··· 3503 3503 if ((len == 0) || ((len < STL_TXBUFLOW) && 3504 3504 (test_bit(ASYI_TXLOW, &portp->istate) == 0))) { 3505 3505 set_bit(ASYI_TXLOW, &portp->istate); 3506 - if (portp->tty) 3507 - tty_wakeup(portp->tty); 3506 + if (portp->port.tty) 3507 + tty_wakeup(portp->port.tty); 3508 3508 } 3509 3509 3510 3510 if (len == 0) { ··· 3568 3568 return; 3569 3569 } 3570 3570 portp = panelp->ports[(ioack >> 3)]; 3571 - tty = portp->tty; 3571 + tty = portp->port.tty; 3572 3572 3573 3573 if ((ioack & ACK_TYPMASK) == ACK_TYPRXGOOD) { 3574 3574 outb((RDCR + portp->uartaddr), ioaddr); ··· 3613 3613 if (portp->rxmarkmsk & status) { 3614 3614 if (status & ST_BREAK) { 3615 3615 status = TTY_BREAK; 3616 - if (portp->flags & ASYNC_SAK) { 3616 + if (portp->port.flags & ASYNC_SAK) { 3617 3617 do_SAK(tty); 3618 3618 BRDENABLE(portp->brdnr, portp->pagenr); 3619 3619 } ··· 3899 3899 } 3900 3900 baudrate = stl_baudrates[baudrate]; 3901 3901 if ((tiosp->c_cflag & CBAUD) == B38400) { 3902 - if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 3902 + if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 3903 3903 baudrate = 57600; 3904 - else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 3904 + else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 3905 3905 baudrate = 115200; 3906 - else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) 3906 + else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) 3907 3907 baudrate = 230400; 3908 - else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 3908 + else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 3909 3909 baudrate = 460800; 3910 - else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) 3910 + else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) 3911 3911 baudrate = (portp->baud_base / portp->custom_divisor); 3912 3912 } 3913 3913 if (baudrate > STL_SC26198MAXBAUD) ··· 3922 3922 * Check what form of modem signaling is required and set it up. 3923 3923 */ 3924 3924 if (tiosp->c_cflag & CLOCAL) { 3925 - portp->flags &= ~ASYNC_CHECK_CD; 3925 + portp->port.flags &= ~ASYNC_CHECK_CD; 3926 3926 } else { 3927 3927 iopr |= IOPR_DCDCOS; 3928 3928 imron |= IR_IOPORT; 3929 - portp->flags |= ASYNC_CHECK_CD; 3929 + portp->port.flags |= ASYNC_CHECK_CD; 3930 3930 } 3931 3931 3932 3932 /* ··· 4174 4174 4175 4175 if (portp == NULL) 4176 4176 return; 4177 - tty = portp->tty; 4177 + tty = portp->port.tty; 4178 4178 if (tty == NULL) 4179 4179 return; 4180 4180 ··· 4243 4243 4244 4244 if (portp == NULL) 4245 4245 return; 4246 - tty = portp->tty; 4246 + tty = portp->port.tty; 4247 4247 if (tty == NULL) 4248 4248 return; 4249 4249 ··· 4421 4421 if ((len == 0) || ((len < STL_TXBUFLOW) && 4422 4422 (test_bit(ASYI_TXLOW, &portp->istate) == 0))) { 4423 4423 set_bit(ASYI_TXLOW, &portp->istate); 4424 - if (portp->tty) 4425 - tty_wakeup(portp->tty); 4424 + if (portp->port.tty) 4425 + tty_wakeup(portp->port.tty); 4426 4426 } 4427 4427 4428 4428 if (len == 0) { ··· 4475 4475 4476 4476 pr_debug("stl_sc26198rxisr(portp=%p,iack=%x)\n", portp, iack); 4477 4477 4478 - tty = portp->tty; 4478 + tty = portp->port.tty; 4479 4479 ioaddr = portp->ioaddr; 4480 4480 outb(GIBCR, (ioaddr + XP_ADDR)); 4481 4481 len = inb(ioaddr + XP_DATA) + 1; ··· 4527 4527 struct tty_struct *tty; 4528 4528 unsigned int ioaddr; 4529 4529 4530 - tty = portp->tty; 4530 + tty = portp->port.tty; 4531 4531 ioaddr = portp->ioaddr; 4532 4532 4533 4533 if (status & SR_RXPARITY) ··· 4544 4544 if (portp->rxmarkmsk & status) { 4545 4545 if (status & SR_RXBREAK) { 4546 4546 status = TTY_BREAK; 4547 - if (portp->flags & ASYNC_SAK) { 4547 + if (portp->port.flags & ASYNC_SAK) { 4548 4548 do_SAK(tty); 4549 4549 BRDENABLE(portp->brdnr, portp->pagenr); 4550 4550 }
+1 -5
include/linux/stallion.h
··· 69 69 */ 70 70 struct stlport { 71 71 unsigned long magic; 72 + struct tty_port port; 72 73 unsigned int portnr; 73 74 unsigned int panelnr; 74 75 unsigned int brdnr; ··· 77 76 int uartaddr; 78 77 unsigned int pagenr; 79 78 unsigned long istate; 80 - int flags; 81 79 int baud_base; 82 80 int custom_divisor; 83 81 int close_delay; 84 82 int closing_wait; 85 - int refcount; 86 83 int openwaitcnt; 87 84 int brklen; 88 85 unsigned int sigs; ··· 91 92 unsigned long clk; 92 93 unsigned long hwid; 93 94 void *uartp; 94 - struct tty_struct *tty; 95 - wait_queue_head_t open_wait; 96 - wait_queue_head_t close_wait; 97 95 comstats_t stats; 98 96 struct stlrq tx; 99 97 };