aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/synclink_gt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/synclink_gt.c')
-rw-r--r--drivers/char/synclink_gt.c247
1 files changed, 117 insertions, 130 deletions
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index 55c1653be00c..2c3e43bb2cc9 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -244,11 +244,11 @@ struct _input_signal_events {
244 */ 244 */
245struct slgt_info { 245struct slgt_info {
246 void *if_ptr; /* General purpose pointer (used by SPPP) */ 246 void *if_ptr; /* General purpose pointer (used by SPPP) */
247 struct tty_port port;
247 248
248 struct slgt_info *next_device; /* device list link */ 249 struct slgt_info *next_device; /* device list link */
249 250
250 int magic; 251 int magic;
251 int flags;
252 252
253 char device_name[25]; 253 char device_name[25];
254 struct pci_dev *pdev; 254 struct pci_dev *pdev;
@@ -260,23 +260,15 @@ struct slgt_info {
260 /* array of pointers to port contexts on this adapter */ 260 /* array of pointers to port contexts on this adapter */
261 struct slgt_info *port_array[SLGT_MAX_PORTS]; 261 struct slgt_info *port_array[SLGT_MAX_PORTS];
262 262
263 int count; /* count of opens */
264 int line; /* tty line instance number */ 263 int line; /* tty line instance number */
265 unsigned short close_delay;
266 unsigned short closing_wait; /* time to wait before closing */
267 264
268 struct mgsl_icount icount; 265 struct mgsl_icount icount;
269 266
270 struct tty_struct *tty;
271 int timeout; 267 int timeout;
272 int x_char; /* xon/xoff character */ 268 int x_char; /* xon/xoff character */
273 int blocked_open; /* # of blocked opens */
274 unsigned int read_status_mask; 269 unsigned int read_status_mask;
275 unsigned int ignore_status_mask; 270 unsigned int ignore_status_mask;
276 271
277 wait_queue_head_t open_wait;
278 wait_queue_head_t close_wait;
279
280 wait_queue_head_t status_event_wait_q; 272 wait_queue_head_t status_event_wait_q;
281 wait_queue_head_t event_wait_q; 273 wait_queue_head_t event_wait_q;
282 struct timer_list tx_timer; 274 struct timer_list tx_timer;
@@ -641,8 +633,8 @@ static void ldisc_receive_buf(struct tty_struct *tty,
641 return; 633 return;
642 ld = tty_ldisc_ref(tty); 634 ld = tty_ldisc_ref(tty);
643 if (ld) { 635 if (ld) {
644 if (ld->receive_buf) 636 if (ld->ops->receive_buf)
645 ld->receive_buf(tty, data, flags, count); 637 ld->ops->receive_buf(tty, data, flags, count);
646 tty_ldisc_deref(ld); 638 tty_ldisc_deref(ld);
647 } 639 }
648} 640}
@@ -672,20 +664,20 @@ static int open(struct tty_struct *tty, struct file *filp)
672 } 664 }
673 665
674 tty->driver_data = info; 666 tty->driver_data = info;
675 info->tty = tty; 667 info->port.tty = tty;
676 668
677 DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->count)); 669 DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
678 670
679 /* If port is closing, signal caller to try again */ 671 /* If port is closing, signal caller to try again */
680 if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){ 672 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
681 if (info->flags & ASYNC_CLOSING) 673 if (info->port.flags & ASYNC_CLOSING)
682 interruptible_sleep_on(&info->close_wait); 674 interruptible_sleep_on(&info->port.close_wait);
683 retval = ((info->flags & ASYNC_HUP_NOTIFY) ? 675 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
684 -EAGAIN : -ERESTARTSYS); 676 -EAGAIN : -ERESTARTSYS);
685 goto cleanup; 677 goto cleanup;
686 } 678 }
687 679
688 info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 680 info->port.tty->low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
689 681
690 spin_lock_irqsave(&info->netlock, flags); 682 spin_lock_irqsave(&info->netlock, flags);
691 if (info->netcount) { 683 if (info->netcount) {
@@ -693,10 +685,10 @@ static int open(struct tty_struct *tty, struct file *filp)
693 spin_unlock_irqrestore(&info->netlock, flags); 685 spin_unlock_irqrestore(&info->netlock, flags);
694 goto cleanup; 686 goto cleanup;
695 } 687 }
696 info->count++; 688 info->port.count++;
697 spin_unlock_irqrestore(&info->netlock, flags); 689 spin_unlock_irqrestore(&info->netlock, flags);
698 690
699 if (info->count == 1) { 691 if (info->port.count == 1) {
700 /* 1st open on this device, init hardware */ 692 /* 1st open on this device, init hardware */
701 retval = startup(info); 693 retval = startup(info);
702 if (retval < 0) 694 if (retval < 0)
@@ -714,9 +706,9 @@ static int open(struct tty_struct *tty, struct file *filp)
714cleanup: 706cleanup:
715 if (retval) { 707 if (retval) {
716 if (tty->count == 1) 708 if (tty->count == 1)
717 info->tty = NULL; /* tty layer will release tty struct */ 709 info->port.tty = NULL; /* tty layer will release tty struct */
718 if(info->count) 710 if(info->port.count)
719 info->count--; 711 info->port.count--;
720 } 712 }
721 713
722 DBGINFO(("%s open rc=%d\n", info->device_name, retval)); 714 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
@@ -729,32 +721,32 @@ static void close(struct tty_struct *tty, struct file *filp)
729 721
730 if (sanity_check(info, tty->name, "close")) 722 if (sanity_check(info, tty->name, "close"))
731 return; 723 return;
732 DBGINFO(("%s close entry, count=%d\n", info->device_name, info->count)); 724 DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
733 725
734 if (!info->count) 726 if (!info->port.count)
735 return; 727 return;
736 728
737 if (tty_hung_up_p(filp)) 729 if (tty_hung_up_p(filp))
738 goto cleanup; 730 goto cleanup;
739 731
740 if ((tty->count == 1) && (info->count != 1)) { 732 if ((tty->count == 1) && (info->port.count != 1)) {
741 /* 733 /*
742 * tty->count is 1 and the tty structure will be freed. 734 * tty->count is 1 and the tty structure will be freed.
743 * info->count should be one in this case. 735 * info->port.count should be one in this case.
744 * if it's not, correct it so that the port is shutdown. 736 * if it's not, correct it so that the port is shutdown.
745 */ 737 */
746 DBGERR(("%s close: bad refcount; tty->count=1, " 738 DBGERR(("%s close: bad refcount; tty->count=1, "
747 "info->count=%d\n", info->device_name, info->count)); 739 "info->port.count=%d\n", info->device_name, info->port.count));
748 info->count = 1; 740 info->port.count = 1;
749 } 741 }
750 742
751 info->count--; 743 info->port.count--;
752 744
753 /* if at least one open remaining, leave hardware active */ 745 /* if at least one open remaining, leave hardware active */
754 if (info->count) 746 if (info->port.count)
755 goto cleanup; 747 goto cleanup;
756 748
757 info->flags |= ASYNC_CLOSING; 749 info->port.flags |= ASYNC_CLOSING;
758 750
759 /* set tty->closing to notify line discipline to 751 /* set tty->closing to notify line discipline to
760 * only process XON/XOFF characters. Only the N_TTY 752 * only process XON/XOFF characters. Only the N_TTY
@@ -764,12 +756,12 @@ static void close(struct tty_struct *tty, struct file *filp)
764 756
765 /* wait for transmit data to clear all layers */ 757 /* wait for transmit data to clear all layers */
766 758
767 if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) { 759 if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) {
768 DBGINFO(("%s call tty_wait_until_sent\n", info->device_name)); 760 DBGINFO(("%s call tty_wait_until_sent\n", info->device_name));
769 tty_wait_until_sent(tty, info->closing_wait); 761 tty_wait_until_sent(tty, info->port.closing_wait);
770 } 762 }
771 763
772 if (info->flags & ASYNC_INITIALIZED) 764 if (info->port.flags & ASYNC_INITIALIZED)
773 wait_until_sent(tty, info->timeout); 765 wait_until_sent(tty, info->timeout);
774 flush_buffer(tty); 766 flush_buffer(tty);
775 tty_ldisc_flush(tty); 767 tty_ldisc_flush(tty);
@@ -777,21 +769,21 @@ static void close(struct tty_struct *tty, struct file *filp)
777 shutdown(info); 769 shutdown(info);
778 770
779 tty->closing = 0; 771 tty->closing = 0;
780 info->tty = NULL; 772 info->port.tty = NULL;
781 773
782 if (info->blocked_open) { 774 if (info->port.blocked_open) {
783 if (info->close_delay) { 775 if (info->port.close_delay) {
784 msleep_interruptible(jiffies_to_msecs(info->close_delay)); 776 msleep_interruptible(jiffies_to_msecs(info->port.close_delay));
785 } 777 }
786 wake_up_interruptible(&info->open_wait); 778 wake_up_interruptible(&info->port.open_wait);
787 } 779 }
788 780
789 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 781 info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
790 782
791 wake_up_interruptible(&info->close_wait); 783 wake_up_interruptible(&info->port.close_wait);
792 784
793cleanup: 785cleanup:
794 DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->count)); 786 DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
795} 787}
796 788
797static void hangup(struct tty_struct *tty) 789static void hangup(struct tty_struct *tty)
@@ -805,11 +797,11 @@ static void hangup(struct tty_struct *tty)
805 flush_buffer(tty); 797 flush_buffer(tty);
806 shutdown(info); 798 shutdown(info);
807 799
808 info->count = 0; 800 info->port.count = 0;
809 info->flags &= ~ASYNC_NORMAL_ACTIVE; 801 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
810 info->tty = NULL; 802 info->port.tty = NULL;
811 803
812 wake_up_interruptible(&info->open_wait); 804 wake_up_interruptible(&info->port.open_wait);
813} 805}
814 806
815static void set_termios(struct tty_struct *tty, struct ktermios *old_termios) 807static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
@@ -959,7 +951,7 @@ static void wait_until_sent(struct tty_struct *tty, int timeout)
959 if (sanity_check(info, tty->name, "wait_until_sent")) 951 if (sanity_check(info, tty->name, "wait_until_sent"))
960 return; 952 return;
961 DBGINFO(("%s wait_until_sent entry\n", info->device_name)); 953 DBGINFO(("%s wait_until_sent entry\n", info->device_name));
962 if (!(info->flags & ASYNC_INITIALIZED)) 954 if (!(info->port.flags & ASYNC_INITIALIZED))
963 goto exit; 955 goto exit;
964 956
965 orig_jiffies = jiffies; 957 orig_jiffies = jiffies;
@@ -1500,7 +1492,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
1500 unsigned short new_crctype; 1492 unsigned short new_crctype;
1501 1493
1502 /* return error if TTY interface open */ 1494 /* return error if TTY interface open */
1503 if (info->count) 1495 if (info->port.count)
1504 return -EBUSY; 1496 return -EBUSY;
1505 1497
1506 DBGINFO(("%s hdlcdev_attach\n", info->device_name)); 1498 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
@@ -1544,7 +1536,6 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
1544static int hdlcdev_xmit(struct sk_buff *skb, struct net_device *dev) 1536static int hdlcdev_xmit(struct sk_buff *skb, struct net_device *dev)
1545{ 1537{
1546 struct slgt_info *info = dev_to_port(dev); 1538 struct slgt_info *info = dev_to_port(dev);
1547 struct net_device_stats *stats = hdlc_stats(dev);
1548 unsigned long flags; 1539 unsigned long flags;
1549 1540
1550 DBGINFO(("%s hdlc_xmit\n", dev->name)); 1541 DBGINFO(("%s hdlc_xmit\n", dev->name));
@@ -1557,8 +1548,8 @@ static int hdlcdev_xmit(struct sk_buff *skb, struct net_device *dev)
1557 tx_load(info, skb->data, skb->len); 1548 tx_load(info, skb->data, skb->len);
1558 1549
1559 /* update network statistics */ 1550 /* update network statistics */
1560 stats->tx_packets++; 1551 dev->stats.tx_packets++;
1561 stats->tx_bytes += skb->len; 1552 dev->stats.tx_bytes += skb->len;
1562 1553
1563 /* done with socket buffer, so free it */ 1554 /* done with socket buffer, so free it */
1564 dev_kfree_skb(skb); 1555 dev_kfree_skb(skb);
@@ -1600,7 +1591,7 @@ static int hdlcdev_open(struct net_device *dev)
1600 1591
1601 /* arbitrate between network and tty opens */ 1592 /* arbitrate between network and tty opens */
1602 spin_lock_irqsave(&info->netlock, flags); 1593 spin_lock_irqsave(&info->netlock, flags);
1603 if (info->count != 0 || info->netcount != 0) { 1594 if (info->port.count != 0 || info->netcount != 0) {
1604 DBGINFO(("%s hdlc_open busy\n", dev->name)); 1595 DBGINFO(("%s hdlc_open busy\n", dev->name));
1605 spin_unlock_irqrestore(&info->netlock, flags); 1596 spin_unlock_irqrestore(&info->netlock, flags);
1606 return -EBUSY; 1597 return -EBUSY;
@@ -1685,7 +1676,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1685 DBGINFO(("%s hdlcdev_ioctl\n", dev->name)); 1676 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
1686 1677
1687 /* return error if TTY interface open */ 1678 /* return error if TTY interface open */
1688 if (info->count) 1679 if (info->port.count)
1689 return -EBUSY; 1680 return -EBUSY;
1690 1681
1691 if (cmd != SIOCWANDEV) 1682 if (cmd != SIOCWANDEV)
@@ -1775,13 +1766,12 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1775static void hdlcdev_tx_timeout(struct net_device *dev) 1766static void hdlcdev_tx_timeout(struct net_device *dev)
1776{ 1767{
1777 struct slgt_info *info = dev_to_port(dev); 1768 struct slgt_info *info = dev_to_port(dev);
1778 struct net_device_stats *stats = hdlc_stats(dev);
1779 unsigned long flags; 1769 unsigned long flags;
1780 1770
1781 DBGINFO(("%s hdlcdev_tx_timeout\n", dev->name)); 1771 DBGINFO(("%s hdlcdev_tx_timeout\n", dev->name));
1782 1772
1783 stats->tx_errors++; 1773 dev->stats.tx_errors++;
1784 stats->tx_aborted_errors++; 1774 dev->stats.tx_aborted_errors++;
1785 1775
1786 spin_lock_irqsave(&info->lock,flags); 1776 spin_lock_irqsave(&info->lock,flags);
1787 tx_stop(info); 1777 tx_stop(info);
@@ -1814,26 +1804,25 @@ static void hdlcdev_rx(struct slgt_info *info, char *buf, int size)
1814{ 1804{
1815 struct sk_buff *skb = dev_alloc_skb(size); 1805 struct sk_buff *skb = dev_alloc_skb(size);
1816 struct net_device *dev = info->netdev; 1806 struct net_device *dev = info->netdev;
1817 struct net_device_stats *stats = hdlc_stats(dev);
1818 1807
1819 DBGINFO(("%s hdlcdev_rx\n", dev->name)); 1808 DBGINFO(("%s hdlcdev_rx\n", dev->name));
1820 1809
1821 if (skb == NULL) { 1810 if (skb == NULL) {
1822 DBGERR(("%s: can't alloc skb, drop packet\n", dev->name)); 1811 DBGERR(("%s: can't alloc skb, drop packet\n", dev->name));
1823 stats->rx_dropped++; 1812 dev->stats.rx_dropped++;
1824 return; 1813 return;
1825 } 1814 }
1826 1815
1827 memcpy(skb_put(skb, size),buf,size); 1816 memcpy(skb_put(skb, size), buf, size);
1828 1817
1829 skb->protocol = hdlc_type_trans(skb, info->netdev); 1818 skb->protocol = hdlc_type_trans(skb, dev);
1830 1819
1831 stats->rx_packets++; 1820 dev->stats.rx_packets++;
1832 stats->rx_bytes += size; 1821 dev->stats.rx_bytes += size;
1833 1822
1834 netif_rx(skb); 1823 netif_rx(skb);
1835 1824
1836 info->netdev->last_rx = jiffies; 1825 dev->last_rx = jiffies;
1837} 1826}
1838 1827
1839/** 1828/**
@@ -1906,7 +1895,7 @@ static void hdlcdev_exit(struct slgt_info *info)
1906 */ 1895 */
1907static void rx_async(struct slgt_info *info) 1896static void rx_async(struct slgt_info *info)
1908{ 1897{
1909 struct tty_struct *tty = info->tty; 1898 struct tty_struct *tty = info->port.tty;
1910 struct mgsl_icount *icount = &info->icount; 1899 struct mgsl_icount *icount = &info->icount;
1911 unsigned int start, end; 1900 unsigned int start, end;
1912 unsigned char *p; 1901 unsigned char *p;
@@ -2057,7 +2046,7 @@ static void bh_handler(struct work_struct *work)
2057 2046
2058static void bh_transmit(struct slgt_info *info) 2047static void bh_transmit(struct slgt_info *info)
2059{ 2048{
2060 struct tty_struct *tty = info->tty; 2049 struct tty_struct *tty = info->port.tty;
2061 2050
2062 DBGBH(("%s bh_transmit\n", info->device_name)); 2051 DBGBH(("%s bh_transmit\n", info->device_name));
2063 if (tty) 2052 if (tty)
@@ -2103,17 +2092,17 @@ static void cts_change(struct slgt_info *info, unsigned short status)
2103 wake_up_interruptible(&info->event_wait_q); 2092 wake_up_interruptible(&info->event_wait_q);
2104 info->pending_bh |= BH_STATUS; 2093 info->pending_bh |= BH_STATUS;
2105 2094
2106 if (info->flags & ASYNC_CTS_FLOW) { 2095 if (info->port.flags & ASYNC_CTS_FLOW) {
2107 if (info->tty) { 2096 if (info->port.tty) {
2108 if (info->tty->hw_stopped) { 2097 if (info->port.tty->hw_stopped) {
2109 if (info->signals & SerialSignal_CTS) { 2098 if (info->signals & SerialSignal_CTS) {
2110 info->tty->hw_stopped = 0; 2099 info->port.tty->hw_stopped = 0;
2111 info->pending_bh |= BH_TRANSMIT; 2100 info->pending_bh |= BH_TRANSMIT;
2112 return; 2101 return;
2113 } 2102 }
2114 } else { 2103 } else {
2115 if (!(info->signals & SerialSignal_CTS)) 2104 if (!(info->signals & SerialSignal_CTS))
2116 info->tty->hw_stopped = 1; 2105 info->port.tty->hw_stopped = 1;
2117 } 2106 }
2118 } 2107 }
2119 } 2108 }
@@ -2146,12 +2135,12 @@ static void dcd_change(struct slgt_info *info, unsigned short status)
2146 wake_up_interruptible(&info->event_wait_q); 2135 wake_up_interruptible(&info->event_wait_q);
2147 info->pending_bh |= BH_STATUS; 2136 info->pending_bh |= BH_STATUS;
2148 2137
2149 if (info->flags & ASYNC_CHECK_CD) { 2138 if (info->port.flags & ASYNC_CHECK_CD) {
2150 if (info->signals & SerialSignal_DCD) 2139 if (info->signals & SerialSignal_DCD)
2151 wake_up_interruptible(&info->open_wait); 2140 wake_up_interruptible(&info->port.open_wait);
2152 else { 2141 else {
2153 if (info->tty) 2142 if (info->port.tty)
2154 tty_hangup(info->tty); 2143 tty_hangup(info->port.tty);
2155 } 2144 }
2156 } 2145 }
2157} 2146}
@@ -2194,12 +2183,12 @@ static void isr_serial(struct slgt_info *info)
2194 if ((status & IRQ_RXBREAK) && (status & RXBREAK)) { 2183 if ((status & IRQ_RXBREAK) && (status & RXBREAK)) {
2195 info->icount.brk++; 2184 info->icount.brk++;
2196 /* process break detection if tty control allows */ 2185 /* process break detection if tty control allows */
2197 if (info->tty) { 2186 if (info->port.tty) {
2198 if (!(status & info->ignore_status_mask)) { 2187 if (!(status & info->ignore_status_mask)) {
2199 if (info->read_status_mask & MASK_BREAK) { 2188 if (info->read_status_mask & MASK_BREAK) {
2200 tty_insert_flip_char(info->tty, 0, TTY_BREAK); 2189 tty_insert_flip_char(info->port.tty, 0, TTY_BREAK);
2201 if (info->flags & ASYNC_SAK) 2190 if (info->port.flags & ASYNC_SAK)
2202 do_SAK(info->tty); 2191 do_SAK(info->port.tty);
2203 } 2192 }
2204 } 2193 }
2205 } 2194 }
@@ -2319,7 +2308,7 @@ static void isr_txeom(struct slgt_info *info, unsigned short status)
2319 else 2308 else
2320#endif 2309#endif
2321 { 2310 {
2322 if (info->tty && (info->tty->stopped || info->tty->hw_stopped)) { 2311 if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) {
2323 tx_stop(info); 2312 tx_stop(info);
2324 return; 2313 return;
2325 } 2314 }
@@ -2395,7 +2384,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
2395 for(i=0; i < info->port_count ; i++) { 2384 for(i=0; i < info->port_count ; i++) {
2396 struct slgt_info *port = info->port_array[i]; 2385 struct slgt_info *port = info->port_array[i];
2397 2386
2398 if (port && (port->count || port->netcount) && 2387 if (port && (port->port.count || port->netcount) &&
2399 port->pending_bh && !port->bh_running && 2388 port->pending_bh && !port->bh_running &&
2400 !port->bh_requested) { 2389 !port->bh_requested) {
2401 DBGISR(("%s bh queued\n", port->device_name)); 2390 DBGISR(("%s bh queued\n", port->device_name));
@@ -2414,7 +2403,7 @@ static int startup(struct slgt_info *info)
2414{ 2403{
2415 DBGINFO(("%s startup\n", info->device_name)); 2404 DBGINFO(("%s startup\n", info->device_name));
2416 2405
2417 if (info->flags & ASYNC_INITIALIZED) 2406 if (info->port.flags & ASYNC_INITIALIZED)
2418 return 0; 2407 return 0;
2419 2408
2420 if (!info->tx_buf) { 2409 if (!info->tx_buf) {
@@ -2432,10 +2421,10 @@ static int startup(struct slgt_info *info)
2432 /* program hardware for current parameters */ 2421 /* program hardware for current parameters */
2433 change_params(info); 2422 change_params(info);
2434 2423
2435 if (info->tty) 2424 if (info->port.tty)
2436 clear_bit(TTY_IO_ERROR, &info->tty->flags); 2425 clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
2437 2426
2438 info->flags |= ASYNC_INITIALIZED; 2427 info->port.flags |= ASYNC_INITIALIZED;
2439 2428
2440 return 0; 2429 return 0;
2441} 2430}
@@ -2447,7 +2436,7 @@ static void shutdown(struct slgt_info *info)
2447{ 2436{
2448 unsigned long flags; 2437 unsigned long flags;
2449 2438
2450 if (!(info->flags & ASYNC_INITIALIZED)) 2439 if (!(info->port.flags & ASYNC_INITIALIZED))
2451 return; 2440 return;
2452 2441
2453 DBGINFO(("%s shutdown\n", info->device_name)); 2442 DBGINFO(("%s shutdown\n", info->device_name));
@@ -2470,7 +2459,7 @@ static void shutdown(struct slgt_info *info)
2470 2459
2471 slgt_irq_off(info, IRQ_ALL | IRQ_MASTER); 2460 slgt_irq_off(info, IRQ_ALL | IRQ_MASTER);
2472 2461
2473 if (!info->tty || info->tty->termios->c_cflag & HUPCL) { 2462 if (!info->port.tty || info->port.tty->termios->c_cflag & HUPCL) {
2474 info->signals &= ~(SerialSignal_DTR + SerialSignal_RTS); 2463 info->signals &= ~(SerialSignal_DTR + SerialSignal_RTS);
2475 set_signals(info); 2464 set_signals(info);
2476 } 2465 }
@@ -2479,10 +2468,10 @@ static void shutdown(struct slgt_info *info)
2479 2468
2480 spin_unlock_irqrestore(&info->lock,flags); 2469 spin_unlock_irqrestore(&info->lock,flags);
2481 2470
2482 if (info->tty) 2471 if (info->port.tty)
2483 set_bit(TTY_IO_ERROR, &info->tty->flags); 2472 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
2484 2473
2485 info->flags &= ~ASYNC_INITIALIZED; 2474 info->port.flags &= ~ASYNC_INITIALIZED;
2486} 2475}
2487 2476
2488static void program_hw(struct slgt_info *info) 2477static void program_hw(struct slgt_info *info)
@@ -2511,7 +2500,7 @@ static void program_hw(struct slgt_info *info)
2511 get_signals(info); 2500 get_signals(info);
2512 2501
2513 if (info->netcount || 2502 if (info->netcount ||
2514 (info->tty && info->tty->termios->c_cflag & CREAD)) 2503 (info->port.tty && info->port.tty->termios->c_cflag & CREAD))
2515 rx_start(info); 2504 rx_start(info);
2516 2505
2517 spin_unlock_irqrestore(&info->lock,flags); 2506 spin_unlock_irqrestore(&info->lock,flags);
@@ -2525,11 +2514,11 @@ static void change_params(struct slgt_info *info)
2525 unsigned cflag; 2514 unsigned cflag;
2526 int bits_per_char; 2515 int bits_per_char;
2527 2516
2528 if (!info->tty || !info->tty->termios) 2517 if (!info->port.tty || !info->port.tty->termios)
2529 return; 2518 return;
2530 DBGINFO(("%s change_params\n", info->device_name)); 2519 DBGINFO(("%s change_params\n", info->device_name));
2531 2520
2532 cflag = info->tty->termios->c_cflag; 2521 cflag = info->port.tty->termios->c_cflag;
2533 2522
2534 /* if B0 rate (hangup) specified then negate DTR and RTS */ 2523 /* if B0 rate (hangup) specified then negate DTR and RTS */
2535 /* otherwise assert DTR and RTS */ 2524 /* otherwise assert DTR and RTS */
@@ -2561,7 +2550,7 @@ static void change_params(struct slgt_info *info)
2561 bits_per_char = info->params.data_bits + 2550 bits_per_char = info->params.data_bits +
2562 info->params.stop_bits + 1; 2551 info->params.stop_bits + 1;
2563 2552
2564 info->params.data_rate = tty_get_baud_rate(info->tty); 2553 info->params.data_rate = tty_get_baud_rate(info->port.tty);
2565 2554
2566 if (info->params.data_rate) { 2555 if (info->params.data_rate) {
2567 info->timeout = (32*HZ*bits_per_char) / 2556 info->timeout = (32*HZ*bits_per_char) /
@@ -2570,30 +2559,30 @@ static void change_params(struct slgt_info *info)
2570 info->timeout += HZ/50; /* Add .02 seconds of slop */ 2559 info->timeout += HZ/50; /* Add .02 seconds of slop */
2571 2560
2572 if (cflag & CRTSCTS) 2561 if (cflag & CRTSCTS)
2573 info->flags |= ASYNC_CTS_FLOW; 2562 info->port.flags |= ASYNC_CTS_FLOW;
2574 else 2563 else
2575 info->flags &= ~ASYNC_CTS_FLOW; 2564 info->port.flags &= ~ASYNC_CTS_FLOW;
2576 2565
2577 if (cflag & CLOCAL) 2566 if (cflag & CLOCAL)
2578 info->flags &= ~ASYNC_CHECK_CD; 2567 info->port.flags &= ~ASYNC_CHECK_CD;
2579 else 2568 else
2580 info->flags |= ASYNC_CHECK_CD; 2569 info->port.flags |= ASYNC_CHECK_CD;
2581 2570
2582 /* process tty input control flags */ 2571 /* process tty input control flags */
2583 2572
2584 info->read_status_mask = IRQ_RXOVER; 2573 info->read_status_mask = IRQ_RXOVER;
2585 if (I_INPCK(info->tty)) 2574 if (I_INPCK(info->port.tty))
2586 info->read_status_mask |= MASK_PARITY | MASK_FRAMING; 2575 info->read_status_mask |= MASK_PARITY | MASK_FRAMING;
2587 if (I_BRKINT(info->tty) || I_PARMRK(info->tty)) 2576 if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
2588 info->read_status_mask |= MASK_BREAK; 2577 info->read_status_mask |= MASK_BREAK;
2589 if (I_IGNPAR(info->tty)) 2578 if (I_IGNPAR(info->port.tty))
2590 info->ignore_status_mask |= MASK_PARITY | MASK_FRAMING; 2579 info->ignore_status_mask |= MASK_PARITY | MASK_FRAMING;
2591 if (I_IGNBRK(info->tty)) { 2580 if (I_IGNBRK(info->port.tty)) {
2592 info->ignore_status_mask |= MASK_BREAK; 2581 info->ignore_status_mask |= MASK_BREAK;
2593 /* If ignoring parity and break indicators, ignore 2582 /* If ignoring parity and break indicators, ignore
2594 * overruns too. (For real raw support). 2583 * overruns too. (For real raw support).
2595 */ 2584 */
2596 if (I_IGNPAR(info->tty)) 2585 if (I_IGNPAR(info->port.tty))
2597 info->ignore_status_mask |= MASK_OVERRUN; 2586 info->ignore_status_mask |= MASK_OVERRUN;
2598 } 2587 }
2599 2588
@@ -3144,7 +3133,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3144 3133
3145 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ 3134 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){
3146 /* nonblock mode is set or port is not enabled */ 3135 /* nonblock mode is set or port is not enabled */
3147 info->flags |= ASYNC_NORMAL_ACTIVE; 3136 info->port.flags |= ASYNC_NORMAL_ACTIVE;
3148 return 0; 3137 return 0;
3149 } 3138 }
3150 3139
@@ -3153,21 +3142,21 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3153 3142
3154 /* Wait for carrier detect and the line to become 3143 /* Wait for carrier detect and the line to become
3155 * free (i.e., not in use by the callout). While we are in 3144 * free (i.e., not in use by the callout). While we are in
3156 * this loop, info->count is dropped by one, so that 3145 * this loop, info->port.count is dropped by one, so that
3157 * close() knows when to free things. We restore it upon 3146 * close() knows when to free things. We restore it upon
3158 * exit, either normal or abnormal. 3147 * exit, either normal or abnormal.
3159 */ 3148 */
3160 3149
3161 retval = 0; 3150 retval = 0;
3162 add_wait_queue(&info->open_wait, &wait); 3151 add_wait_queue(&info->port.open_wait, &wait);
3163 3152
3164 spin_lock_irqsave(&info->lock, flags); 3153 spin_lock_irqsave(&info->lock, flags);
3165 if (!tty_hung_up_p(filp)) { 3154 if (!tty_hung_up_p(filp)) {
3166 extra_count = true; 3155 extra_count = true;
3167 info->count--; 3156 info->port.count--;
3168 } 3157 }
3169 spin_unlock_irqrestore(&info->lock, flags); 3158 spin_unlock_irqrestore(&info->lock, flags);
3170 info->blocked_open++; 3159 info->port.blocked_open++;
3171 3160
3172 while (1) { 3161 while (1) {
3173 if ((tty->termios->c_cflag & CBAUD)) { 3162 if ((tty->termios->c_cflag & CBAUD)) {
@@ -3179,8 +3168,8 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3179 3168
3180 set_current_state(TASK_INTERRUPTIBLE); 3169 set_current_state(TASK_INTERRUPTIBLE);
3181 3170
3182 if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)){ 3171 if (tty_hung_up_p(filp) || !(info->port.flags & ASYNC_INITIALIZED)){
3183 retval = (info->flags & ASYNC_HUP_NOTIFY) ? 3172 retval = (info->port.flags & ASYNC_HUP_NOTIFY) ?
3184 -EAGAIN : -ERESTARTSYS; 3173 -EAGAIN : -ERESTARTSYS;
3185 break; 3174 break;
3186 } 3175 }
@@ -3189,7 +3178,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3189 get_signals(info); 3178 get_signals(info);
3190 spin_unlock_irqrestore(&info->lock,flags); 3179 spin_unlock_irqrestore(&info->lock,flags);
3191 3180
3192 if (!(info->flags & ASYNC_CLOSING) && 3181 if (!(info->port.flags & ASYNC_CLOSING) &&
3193 (do_clocal || (info->signals & SerialSignal_DCD)) ) { 3182 (do_clocal || (info->signals & SerialSignal_DCD)) ) {
3194 break; 3183 break;
3195 } 3184 }
@@ -3204,14 +3193,14 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3204 } 3193 }
3205 3194
3206 set_current_state(TASK_RUNNING); 3195 set_current_state(TASK_RUNNING);
3207 remove_wait_queue(&info->open_wait, &wait); 3196 remove_wait_queue(&info->port.open_wait, &wait);
3208 3197
3209 if (extra_count) 3198 if (extra_count)
3210 info->count++; 3199 info->port.count++;
3211 info->blocked_open--; 3200 info->port.blocked_open--;
3212 3201
3213 if (!retval) 3202 if (!retval)
3214 info->flags |= ASYNC_NORMAL_ACTIVE; 3203 info->port.flags |= ASYNC_NORMAL_ACTIVE;
3215 3204
3216 DBGINFO(("%s block_til_ready ready, rc=%d\n", tty->driver->name, retval)); 3205 DBGINFO(("%s block_til_ready ready, rc=%d\n", tty->driver->name, retval));
3217 return retval; 3206 return retval;
@@ -3454,14 +3443,13 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev
3454 DBGERR(("%s device alloc failed adapter=%d port=%d\n", 3443 DBGERR(("%s device alloc failed adapter=%d port=%d\n",
3455 driver_name, adapter_num, port_num)); 3444 driver_name, adapter_num, port_num));
3456 } else { 3445 } else {
3446 tty_port_init(&info->port);
3457 info->magic = MGSL_MAGIC; 3447 info->magic = MGSL_MAGIC;
3458 INIT_WORK(&info->task, bh_handler); 3448 INIT_WORK(&info->task, bh_handler);
3459 info->max_frame_size = 4096; 3449 info->max_frame_size = 4096;
3460 info->raw_rx_size = DMABUFSIZE; 3450 info->raw_rx_size = DMABUFSIZE;
3461 info->close_delay = 5*HZ/10; 3451 info->port.close_delay = 5*HZ/10;
3462 info->closing_wait = 30*HZ; 3452 info->port.closing_wait = 30*HZ;
3463 init_waitqueue_head(&info->open_wait);
3464 init_waitqueue_head(&info->close_wait);
3465 init_waitqueue_head(&info->status_event_wait_q); 3453 init_waitqueue_head(&info->status_event_wait_q);
3466 init_waitqueue_head(&info->event_wait_q); 3454 init_waitqueue_head(&info->event_wait_q);
3467 spin_lock_init(&info->netlock); 3455 spin_lock_init(&info->netlock);
@@ -4505,7 +4493,7 @@ static bool rx_get_frame(struct slgt_info *info)
4505 unsigned short status; 4493 unsigned short status;
4506 unsigned int framesize = 0; 4494 unsigned int framesize = 0;
4507 unsigned long flags; 4495 unsigned long flags;
4508 struct tty_struct *tty = info->tty; 4496 struct tty_struct *tty = info->port.tty;
4509 unsigned char addr_field = 0xff; 4497 unsigned char addr_field = 0xff;
4510 unsigned int crc_size = 0; 4498 unsigned int crc_size = 0;
4511 4499
@@ -4577,9 +4565,8 @@ check_again:
4577 4565
4578#if SYNCLINK_GENERIC_HDLC 4566#if SYNCLINK_GENERIC_HDLC
4579 if (framesize == 0) { 4567 if (framesize == 0) {
4580 struct net_device_stats *stats = hdlc_stats(info->netdev); 4568 info->netdev->stats.rx_errors++;
4581 stats->rx_errors++; 4569 info->netdev->stats.rx_frame_errors++;
4582 stats->rx_frame_errors++;
4583 } 4570 }
4584#endif 4571#endif
4585 4572
@@ -4656,7 +4643,7 @@ static bool rx_get_buf(struct slgt_info *info)
4656 DBGDATA(info, info->rbufs[i].buf, count, "rx"); 4643 DBGDATA(info, info->rbufs[i].buf, count, "rx");
4657 DBGINFO(("rx_get_buf size=%d\n", count)); 4644 DBGINFO(("rx_get_buf size=%d\n", count));
4658 if (count) 4645 if (count)
4659 ldisc_receive_buf(info->tty, info->rbufs[i].buf, 4646 ldisc_receive_buf(info->port.tty, info->rbufs[i].buf,
4660 info->flag_buf, count); 4647 info->flag_buf, count);
4661 free_rbufs(info, i, i); 4648 free_rbufs(info, i, i);
4662 return true; 4649 return true;
@@ -4765,11 +4752,11 @@ static int irq_test(struct slgt_info *info)
4765{ 4752{
4766 unsigned long timeout; 4753 unsigned long timeout;
4767 unsigned long flags; 4754 unsigned long flags;
4768 struct tty_struct *oldtty = info->tty; 4755 struct tty_struct *oldtty = info->port.tty;
4769 u32 speed = info->params.data_rate; 4756 u32 speed = info->params.data_rate;
4770 4757
4771 info->params.data_rate = 921600; 4758 info->params.data_rate = 921600;
4772 info->tty = NULL; 4759 info->port.tty = NULL;
4773 4760
4774 spin_lock_irqsave(&info->lock, flags); 4761 spin_lock_irqsave(&info->lock, flags);
4775 async_mode(info); 4762 async_mode(info);
@@ -4797,7 +4784,7 @@ static int irq_test(struct slgt_info *info)
4797 spin_unlock_irqrestore(&info->lock,flags); 4784 spin_unlock_irqrestore(&info->lock,flags);
4798 4785
4799 info->params.data_rate = speed; 4786 info->params.data_rate = speed;
4800 info->tty = oldtty; 4787 info->port.tty = oldtty;
4801 4788
4802 info->init_error = info->irq_occurred ? 0 : DiagStatus_IrqFailure; 4789 info->init_error = info->irq_occurred ? 0 : DiagStatus_IrqFailure;
4803 return info->irq_occurred ? 0 : -ENODEV; 4790 return info->irq_occurred ? 0 : -ENODEV;
@@ -4837,7 +4824,7 @@ static int loopback_test(struct slgt_info *info)
4837 int rc = -ENODEV; 4824 int rc = -ENODEV;
4838 unsigned long flags; 4825 unsigned long flags;
4839 4826
4840 struct tty_struct *oldtty = info->tty; 4827 struct tty_struct *oldtty = info->port.tty;
4841 MGSL_PARAMS params; 4828 MGSL_PARAMS params;
4842 4829
4843 memcpy(&params, &info->params, sizeof(params)); 4830 memcpy(&params, &info->params, sizeof(params));
@@ -4845,7 +4832,7 @@ static int loopback_test(struct slgt_info *info)
4845 info->params.mode = MGSL_MODE_ASYNC; 4832 info->params.mode = MGSL_MODE_ASYNC;
4846 info->params.data_rate = 921600; 4833 info->params.data_rate = 921600;
4847 info->params.loopback = 1; 4834 info->params.loopback = 1;
4848 info->tty = NULL; 4835 info->port.tty = NULL;
4849 4836
4850 /* build and send transmit frame */ 4837 /* build and send transmit frame */
4851 for (count = 0; count < TESTFRAMESIZE; ++count) 4838 for (count = 0; count < TESTFRAMESIZE; ++count)
@@ -4883,7 +4870,7 @@ static int loopback_test(struct slgt_info *info)
4883 spin_unlock_irqrestore(&info->lock,flags); 4870 spin_unlock_irqrestore(&info->lock,flags);
4884 4871
4885 memcpy(&info->params, &params, sizeof(info->params)); 4872 memcpy(&info->params, &params, sizeof(info->params));
4886 info->tty = oldtty; 4873 info->port.tty = oldtty;
4887 4874
4888 info->init_error = rc ? DiagStatus_DmaFailure : 0; 4875 info->init_error = rc ? DiagStatus_DmaFailure : 0;
4889 return rc; 4876 return rc;