aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/synclinkmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/synclinkmp.c')
-rw-r--r--drivers/char/synclinkmp.c219
1 files changed, 106 insertions, 113 deletions
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index 10241ed86100..5768c4136342 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -151,18 +151,15 @@ struct _input_signal_events {
151typedef struct _synclinkmp_info { 151typedef struct _synclinkmp_info {
152 void *if_ptr; /* General purpose pointer (used by SPPP) */ 152 void *if_ptr; /* General purpose pointer (used by SPPP) */
153 int magic; 153 int magic;
154 int flags; 154 struct tty_port port;
155 int count; /* count of opens */
156 int line; 155 int line;
157 unsigned short close_delay; 156 unsigned short close_delay;
158 unsigned short closing_wait; /* time to wait before closing */ 157 unsigned short closing_wait; /* time to wait before closing */
159 158
160 struct mgsl_icount icount; 159 struct mgsl_icount icount;
161 160
162 struct tty_struct *tty;
163 int timeout; 161 int timeout;
164 int x_char; /* xon/xoff character */ 162 int x_char; /* xon/xoff character */
165 int blocked_open; /* # of blocked opens */
166 u16 read_status_mask1; /* break detection (SR1 indications) */ 163 u16 read_status_mask1; /* break detection (SR1 indications) */
167 u16 read_status_mask2; /* parity/framing/overun (SR2 indications) */ 164 u16 read_status_mask2; /* parity/framing/overun (SR2 indications) */
168 unsigned char ignore_status_mask1; /* break detection (SR1 indications) */ 165 unsigned char ignore_status_mask1; /* break detection (SR1 indications) */
@@ -172,9 +169,6 @@ typedef struct _synclinkmp_info {
172 int tx_get; 169 int tx_get;
173 int tx_count; 170 int tx_count;
174 171
175 wait_queue_head_t open_wait;
176 wait_queue_head_t close_wait;
177
178 wait_queue_head_t status_event_wait_q; 172 wait_queue_head_t status_event_wait_q;
179 wait_queue_head_t event_wait_q; 173 wait_queue_head_t event_wait_q;
180 struct timer_list tx_timer; /* HDLC transmit timeout timer */ 174 struct timer_list tx_timer; /* HDLC transmit timeout timer */
@@ -462,13 +456,13 @@ static int synclinkmp_device_count = 0;
462 * .text section address and breakpoint on module load. 456 * .text section address and breakpoint on module load.
463 * This is useful for use with gdb and add-symbol-file command. 457 * This is useful for use with gdb and add-symbol-file command.
464 */ 458 */
465static int break_on_load=0; 459static int break_on_load = 0;
466 460
467/* 461/*
468 * Driver major number, defaults to zero to get auto 462 * Driver major number, defaults to zero to get auto
469 * assigned major number. May be forced as module parameter. 463 * assigned major number. May be forced as module parameter.
470 */ 464 */
471static int ttymajor=0; 465static int ttymajor = 0;
472 466
473/* 467/*
474 * Array of user specified options for ISA adapters. 468 * Array of user specified options for ISA adapters.
@@ -712,8 +706,8 @@ static void ldisc_receive_buf(struct tty_struct *tty,
712 return; 706 return;
713 ld = tty_ldisc_ref(tty); 707 ld = tty_ldisc_ref(tty);
714 if (ld) { 708 if (ld) {
715 if (ld->receive_buf) 709 if (ld->ops->receive_buf)
716 ld->receive_buf(tty, data, flags, count); 710 ld->ops->receive_buf(tty, data, flags, count);
717 tty_ldisc_deref(ld); 711 tty_ldisc_deref(ld);
718 } 712 }
719} 713}
@@ -747,22 +741,22 @@ static int open(struct tty_struct *tty, struct file *filp)
747 } 741 }
748 742
749 tty->driver_data = info; 743 tty->driver_data = info;
750 info->tty = tty; 744 info->port.tty = tty;
751 745
752 if (debug_level >= DEBUG_LEVEL_INFO) 746 if (debug_level >= DEBUG_LEVEL_INFO)
753 printk("%s(%d):%s open(), old ref count = %d\n", 747 printk("%s(%d):%s open(), old ref count = %d\n",
754 __FILE__,__LINE__,tty->driver->name, info->count); 748 __FILE__,__LINE__,tty->driver->name, info->port.count);
755 749
756 /* If port is closing, signal caller to try again */ 750 /* If port is closing, signal caller to try again */
757 if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){ 751 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
758 if (info->flags & ASYNC_CLOSING) 752 if (info->port.flags & ASYNC_CLOSING)
759 interruptible_sleep_on(&info->close_wait); 753 interruptible_sleep_on(&info->port.close_wait);
760 retval = ((info->flags & ASYNC_HUP_NOTIFY) ? 754 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
761 -EAGAIN : -ERESTARTSYS); 755 -EAGAIN : -ERESTARTSYS);
762 goto cleanup; 756 goto cleanup;
763 } 757 }
764 758
765 info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 759 info->port.tty->low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
766 760
767 spin_lock_irqsave(&info->netlock, flags); 761 spin_lock_irqsave(&info->netlock, flags);
768 if (info->netcount) { 762 if (info->netcount) {
@@ -770,10 +764,10 @@ static int open(struct tty_struct *tty, struct file *filp)
770 spin_unlock_irqrestore(&info->netlock, flags); 764 spin_unlock_irqrestore(&info->netlock, flags);
771 goto cleanup; 765 goto cleanup;
772 } 766 }
773 info->count++; 767 info->port.count++;
774 spin_unlock_irqrestore(&info->netlock, flags); 768 spin_unlock_irqrestore(&info->netlock, flags);
775 769
776 if (info->count == 1) { 770 if (info->port.count == 1) {
777 /* 1st open on this device, init hardware */ 771 /* 1st open on this device, init hardware */
778 retval = startup(info); 772 retval = startup(info);
779 if (retval < 0) 773 if (retval < 0)
@@ -796,9 +790,9 @@ static int open(struct tty_struct *tty, struct file *filp)
796cleanup: 790cleanup:
797 if (retval) { 791 if (retval) {
798 if (tty->count == 1) 792 if (tty->count == 1)
799 info->tty = NULL; /* tty layer will release tty struct */ 793 info->port.tty = NULL; /* tty layer will release tty struct */
800 if(info->count) 794 if(info->port.count)
801 info->count--; 795 info->port.count--;
802 } 796 }
803 797
804 return retval; 798 return retval;
@@ -816,33 +810,33 @@ static void close(struct tty_struct *tty, struct file *filp)
816 810
817 if (debug_level >= DEBUG_LEVEL_INFO) 811 if (debug_level >= DEBUG_LEVEL_INFO)
818 printk("%s(%d):%s close() entry, count=%d\n", 812 printk("%s(%d):%s close() entry, count=%d\n",
819 __FILE__,__LINE__, info->device_name, info->count); 813 __FILE__,__LINE__, info->device_name, info->port.count);
820 814
821 if (!info->count) 815 if (!info->port.count)
822 return; 816 return;
823 817
824 if (tty_hung_up_p(filp)) 818 if (tty_hung_up_p(filp))
825 goto cleanup; 819 goto cleanup;
826 820
827 if ((tty->count == 1) && (info->count != 1)) { 821 if ((tty->count == 1) && (info->port.count != 1)) {
828 /* 822 /*
829 * tty->count is 1 and the tty structure will be freed. 823 * tty->count is 1 and the tty structure will be freed.
830 * info->count should be one in this case. 824 * info->port.count should be one in this case.
831 * if it's not, correct it so that the port is shutdown. 825 * if it's not, correct it so that the port is shutdown.
832 */ 826 */
833 printk("%s(%d):%s close: bad refcount; tty->count is 1, " 827 printk("%s(%d):%s close: bad refcount; tty->count is 1, "
834 "info->count is %d\n", 828 "info->port.count is %d\n",
835 __FILE__,__LINE__, info->device_name, info->count); 829 __FILE__,__LINE__, info->device_name, info->port.count);
836 info->count = 1; 830 info->port.count = 1;
837 } 831 }
838 832
839 info->count--; 833 info->port.count--;
840 834
841 /* if at least one open remaining, leave hardware active */ 835 /* if at least one open remaining, leave hardware active */
842 if (info->count) 836 if (info->port.count)
843 goto cleanup; 837 goto cleanup;
844 838
845 info->flags |= ASYNC_CLOSING; 839 info->port.flags |= ASYNC_CLOSING;
846 840
847 /* set tty->closing to notify line discipline to 841 /* set tty->closing to notify line discipline to
848 * only process XON/XOFF characters. Only the N_TTY 842 * only process XON/XOFF characters. Only the N_TTY
@@ -852,14 +846,14 @@ static void close(struct tty_struct *tty, struct file *filp)
852 846
853 /* wait for transmit data to clear all layers */ 847 /* wait for transmit data to clear all layers */
854 848
855 if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) { 849 if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) {
856 if (debug_level >= DEBUG_LEVEL_INFO) 850 if (debug_level >= DEBUG_LEVEL_INFO)
857 printk("%s(%d):%s close() calling tty_wait_until_sent\n", 851 printk("%s(%d):%s close() calling tty_wait_until_sent\n",
858 __FILE__,__LINE__, info->device_name ); 852 __FILE__,__LINE__, info->device_name );
859 tty_wait_until_sent(tty, info->closing_wait); 853 tty_wait_until_sent(tty, info->port.closing_wait);
860 } 854 }
861 855
862 if (info->flags & ASYNC_INITIALIZED) 856 if (info->port.flags & ASYNC_INITIALIZED)
863 wait_until_sent(tty, info->timeout); 857 wait_until_sent(tty, info->timeout);
864 858
865 flush_buffer(tty); 859 flush_buffer(tty);
@@ -869,23 +863,23 @@ static void close(struct tty_struct *tty, struct file *filp)
869 shutdown(info); 863 shutdown(info);
870 864
871 tty->closing = 0; 865 tty->closing = 0;
872 info->tty = NULL; 866 info->port.tty = NULL;
873 867
874 if (info->blocked_open) { 868 if (info->port.blocked_open) {
875 if (info->close_delay) { 869 if (info->port.close_delay) {
876 msleep_interruptible(jiffies_to_msecs(info->close_delay)); 870 msleep_interruptible(jiffies_to_msecs(info->port.close_delay));
877 } 871 }
878 wake_up_interruptible(&info->open_wait); 872 wake_up_interruptible(&info->port.open_wait);
879 } 873 }
880 874
881 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 875 info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
882 876
883 wake_up_interruptible(&info->close_wait); 877 wake_up_interruptible(&info->port.close_wait);
884 878
885cleanup: 879cleanup:
886 if (debug_level >= DEBUG_LEVEL_INFO) 880 if (debug_level >= DEBUG_LEVEL_INFO)
887 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__, 881 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
888 tty->driver->name, info->count); 882 tty->driver->name, info->port.count);
889} 883}
890 884
891/* Called by tty_hangup() when a hangup is signaled. 885/* Called by tty_hangup() when a hangup is signaled.
@@ -905,11 +899,11 @@ static void hangup(struct tty_struct *tty)
905 flush_buffer(tty); 899 flush_buffer(tty);
906 shutdown(info); 900 shutdown(info);
907 901
908 info->count = 0; 902 info->port.count = 0;
909 info->flags &= ~ASYNC_NORMAL_ACTIVE; 903 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
910 info->tty = NULL; 904 info->port.tty = NULL;
911 905
912 wake_up_interruptible(&info->open_wait); 906 wake_up_interruptible(&info->port.open_wait);
913} 907}
914 908
915/* Set new termios settings 909/* Set new termios settings
@@ -1123,7 +1117,7 @@ static void wait_until_sent(struct tty_struct *tty, int timeout)
1123 1117
1124 lock_kernel(); 1118 lock_kernel();
1125 1119
1126 if (!(info->flags & ASYNC_INITIALIZED)) 1120 if (!(info->port.flags & ASYNC_INITIALIZED))
1127 goto exit; 1121 goto exit;
1128 1122
1129 orig_jiffies = jiffies; 1123 orig_jiffies = jiffies;
@@ -1636,7 +1630,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
1636 unsigned short new_crctype; 1630 unsigned short new_crctype;
1637 1631
1638 /* return error if TTY interface open */ 1632 /* return error if TTY interface open */
1639 if (info->count) 1633 if (info->port.count)
1640 return -EBUSY; 1634 return -EBUSY;
1641 1635
1642 switch (encoding) 1636 switch (encoding)
@@ -1732,7 +1726,7 @@ static int hdlcdev_open(struct net_device *dev)
1732 1726
1733 /* arbitrate between network and tty opens */ 1727 /* arbitrate between network and tty opens */
1734 spin_lock_irqsave(&info->netlock, flags); 1728 spin_lock_irqsave(&info->netlock, flags);
1735 if (info->count != 0 || info->netcount != 0) { 1729 if (info->port.count != 0 || info->netcount != 0) {
1736 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name); 1730 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
1737 spin_unlock_irqrestore(&info->netlock, flags); 1731 spin_unlock_irqrestore(&info->netlock, flags);
1738 return -EBUSY; 1732 return -EBUSY;
@@ -1818,7 +1812,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1818 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name); 1812 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
1819 1813
1820 /* return error if TTY interface open */ 1814 /* return error if TTY interface open */
1821 if (info->count) 1815 if (info->port.count)
1822 return -EBUSY; 1816 return -EBUSY;
1823 1817
1824 if (cmd != SIOCWANDEV) 1818 if (cmd != SIOCWANDEV)
@@ -2126,7 +2120,7 @@ static void bh_receive(SLMP_INFO *info)
2126 2120
2127static void bh_transmit(SLMP_INFO *info) 2121static void bh_transmit(SLMP_INFO *info)
2128{ 2122{
2129 struct tty_struct *tty = info->tty; 2123 struct tty_struct *tty = info->port.tty;
2130 2124
2131 if ( debug_level >= DEBUG_LEVEL_BH ) 2125 if ( debug_level >= DEBUG_LEVEL_BH )
2132 printk( "%s(%d):%s bh_transmit() entry\n", 2126 printk( "%s(%d):%s bh_transmit() entry\n",
@@ -2176,7 +2170,7 @@ static void isr_timer(SLMP_INFO * info)
2176 2170
2177static void isr_rxint(SLMP_INFO * info) 2171static void isr_rxint(SLMP_INFO * info)
2178{ 2172{
2179 struct tty_struct *tty = info->tty; 2173 struct tty_struct *tty = info->port.tty;
2180 struct mgsl_icount *icount = &info->icount; 2174 struct mgsl_icount *icount = &info->icount;
2181 unsigned char status = read_reg(info, SR1) & info->ie1_value & (FLGD + IDLD + CDCD + BRKD); 2175 unsigned char status = read_reg(info, SR1) & info->ie1_value & (FLGD + IDLD + CDCD + BRKD);
2182 unsigned char status2 = read_reg(info, SR2) & info->ie2_value & OVRN; 2176 unsigned char status2 = read_reg(info, SR2) & info->ie2_value & OVRN;
@@ -2203,7 +2197,7 @@ static void isr_rxint(SLMP_INFO * info)
2203 if (!(status & info->ignore_status_mask1)) { 2197 if (!(status & info->ignore_status_mask1)) {
2204 if (info->read_status_mask1 & BRKD) { 2198 if (info->read_status_mask1 & BRKD) {
2205 tty_insert_flip_char(tty, 0, TTY_BREAK); 2199 tty_insert_flip_char(tty, 0, TTY_BREAK);
2206 if (info->flags & ASYNC_SAK) 2200 if (info->port.flags & ASYNC_SAK)
2207 do_SAK(tty); 2201 do_SAK(tty);
2208 } 2202 }
2209 } 2203 }
@@ -2237,7 +2231,7 @@ static void isr_rxrdy(SLMP_INFO * info)
2237{ 2231{
2238 u16 status; 2232 u16 status;
2239 unsigned char DataByte; 2233 unsigned char DataByte;
2240 struct tty_struct *tty = info->tty; 2234 struct tty_struct *tty = info->port.tty;
2241 struct mgsl_icount *icount = &info->icount; 2235 struct mgsl_icount *icount = &info->icount;
2242 2236
2243 if ( debug_level >= DEBUG_LEVEL_ISR ) 2237 if ( debug_level >= DEBUG_LEVEL_ISR )
@@ -2350,7 +2344,7 @@ static void isr_txeom(SLMP_INFO * info, unsigned char status)
2350 else 2344 else
2351#endif 2345#endif
2352 { 2346 {
2353 if (info->tty && (info->tty->stopped || info->tty->hw_stopped)) { 2347 if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) {
2354 tx_stop(info); 2348 tx_stop(info);
2355 return; 2349 return;
2356 } 2350 }
@@ -2405,7 +2399,7 @@ static void isr_txrdy(SLMP_INFO * info)
2405 return; 2399 return;
2406 } 2400 }
2407 2401
2408 if (info->tty && (info->tty->stopped || info->tty->hw_stopped)) { 2402 if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) {
2409 tx_stop(info); 2403 tx_stop(info);
2410 return; 2404 return;
2411 } 2405 }
@@ -2552,29 +2546,29 @@ static void isr_io_pin( SLMP_INFO *info, u16 status )
2552 wake_up_interruptible(&info->status_event_wait_q); 2546 wake_up_interruptible(&info->status_event_wait_q);
2553 wake_up_interruptible(&info->event_wait_q); 2547 wake_up_interruptible(&info->event_wait_q);
2554 2548
2555 if ( (info->flags & ASYNC_CHECK_CD) && 2549 if ( (info->port.flags & ASYNC_CHECK_CD) &&
2556 (status & MISCSTATUS_DCD_LATCHED) ) { 2550 (status & MISCSTATUS_DCD_LATCHED) ) {
2557 if ( debug_level >= DEBUG_LEVEL_ISR ) 2551 if ( debug_level >= DEBUG_LEVEL_ISR )
2558 printk("%s CD now %s...", info->device_name, 2552 printk("%s CD now %s...", info->device_name,
2559 (status & SerialSignal_DCD) ? "on" : "off"); 2553 (status & SerialSignal_DCD) ? "on" : "off");
2560 if (status & SerialSignal_DCD) 2554 if (status & SerialSignal_DCD)
2561 wake_up_interruptible(&info->open_wait); 2555 wake_up_interruptible(&info->port.open_wait);
2562 else { 2556 else {
2563 if ( debug_level >= DEBUG_LEVEL_ISR ) 2557 if ( debug_level >= DEBUG_LEVEL_ISR )
2564 printk("doing serial hangup..."); 2558 printk("doing serial hangup...");
2565 if (info->tty) 2559 if (info->port.tty)
2566 tty_hangup(info->tty); 2560 tty_hangup(info->port.tty);
2567 } 2561 }
2568 } 2562 }
2569 2563
2570 if ( (info->flags & ASYNC_CTS_FLOW) && 2564 if ( (info->port.flags & ASYNC_CTS_FLOW) &&
2571 (status & MISCSTATUS_CTS_LATCHED) ) { 2565 (status & MISCSTATUS_CTS_LATCHED) ) {
2572 if ( info->tty ) { 2566 if ( info->port.tty ) {
2573 if (info->tty->hw_stopped) { 2567 if (info->port.tty->hw_stopped) {
2574 if (status & SerialSignal_CTS) { 2568 if (status & SerialSignal_CTS) {
2575 if ( debug_level >= DEBUG_LEVEL_ISR ) 2569 if ( debug_level >= DEBUG_LEVEL_ISR )
2576 printk("CTS tx start..."); 2570 printk("CTS tx start...");
2577 info->tty->hw_stopped = 0; 2571 info->port.tty->hw_stopped = 0;
2578 tx_start(info); 2572 tx_start(info);
2579 info->pending_bh |= BH_TRANSMIT; 2573 info->pending_bh |= BH_TRANSMIT;
2580 return; 2574 return;
@@ -2583,7 +2577,7 @@ static void isr_io_pin( SLMP_INFO *info, u16 status )
2583 if (!(status & SerialSignal_CTS)) { 2577 if (!(status & SerialSignal_CTS)) {
2584 if ( debug_level >= DEBUG_LEVEL_ISR ) 2578 if ( debug_level >= DEBUG_LEVEL_ISR )
2585 printk("CTS tx stop..."); 2579 printk("CTS tx stop...");
2586 info->tty->hw_stopped = 1; 2580 info->port.tty->hw_stopped = 1;
2587 tx_stop(info); 2581 tx_stop(info);
2588 } 2582 }
2589 } 2583 }
@@ -2699,7 +2693,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
2699 * do not request bottom half processing if the 2693 * do not request bottom half processing if the
2700 * device is not open in a normal mode. 2694 * device is not open in a normal mode.
2701 */ 2695 */
2702 if ( port && (port->count || port->netcount) && 2696 if ( port && (port->port.count || port->netcount) &&
2703 port->pending_bh && !port->bh_running && 2697 port->pending_bh && !port->bh_running &&
2704 !port->bh_requested ) { 2698 !port->bh_requested ) {
2705 if ( debug_level >= DEBUG_LEVEL_ISR ) 2699 if ( debug_level >= DEBUG_LEVEL_ISR )
@@ -2725,7 +2719,7 @@ static int startup(SLMP_INFO * info)
2725 if ( debug_level >= DEBUG_LEVEL_INFO ) 2719 if ( debug_level >= DEBUG_LEVEL_INFO )
2726 printk("%s(%d):%s tx_releaseup()\n",__FILE__,__LINE__,info->device_name); 2720 printk("%s(%d):%s tx_releaseup()\n",__FILE__,__LINE__,info->device_name);
2727 2721
2728 if (info->flags & ASYNC_INITIALIZED) 2722 if (info->port.flags & ASYNC_INITIALIZED)
2729 return 0; 2723 return 0;
2730 2724
2731 if (!info->tx_buf) { 2725 if (!info->tx_buf) {
@@ -2748,10 +2742,10 @@ static int startup(SLMP_INFO * info)
2748 2742
2749 mod_timer(&info->status_timer, jiffies + msecs_to_jiffies(10)); 2743 mod_timer(&info->status_timer, jiffies + msecs_to_jiffies(10));
2750 2744
2751 if (info->tty) 2745 if (info->port.tty)
2752 clear_bit(TTY_IO_ERROR, &info->tty->flags); 2746 clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
2753 2747
2754 info->flags |= ASYNC_INITIALIZED; 2748 info->port.flags |= ASYNC_INITIALIZED;
2755 2749
2756 return 0; 2750 return 0;
2757} 2751}
@@ -2762,7 +2756,7 @@ static void shutdown(SLMP_INFO * info)
2762{ 2756{
2763 unsigned long flags; 2757 unsigned long flags;
2764 2758
2765 if (!(info->flags & ASYNC_INITIALIZED)) 2759 if (!(info->port.flags & ASYNC_INITIALIZED))
2766 return; 2760 return;
2767 2761
2768 if (debug_level >= DEBUG_LEVEL_INFO) 2762 if (debug_level >= DEBUG_LEVEL_INFO)
@@ -2784,17 +2778,17 @@ static void shutdown(SLMP_INFO * info)
2784 2778
2785 reset_port(info); 2779 reset_port(info);
2786 2780
2787 if (!info->tty || info->tty->termios->c_cflag & HUPCL) { 2781 if (!info->port.tty || info->port.tty->termios->c_cflag & HUPCL) {
2788 info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); 2782 info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS);
2789 set_signals(info); 2783 set_signals(info);
2790 } 2784 }
2791 2785
2792 spin_unlock_irqrestore(&info->lock,flags); 2786 spin_unlock_irqrestore(&info->lock,flags);
2793 2787
2794 if (info->tty) 2788 if (info->port.tty)
2795 set_bit(TTY_IO_ERROR, &info->tty->flags); 2789 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
2796 2790
2797 info->flags &= ~ASYNC_INITIALIZED; 2791 info->port.flags &= ~ASYNC_INITIALIZED;
2798} 2792}
2799 2793
2800static void program_hw(SLMP_INFO *info) 2794static void program_hw(SLMP_INFO *info)
@@ -2825,7 +2819,7 @@ static void program_hw(SLMP_INFO *info)
2825 2819
2826 get_signals(info); 2820 get_signals(info);
2827 2821
2828 if (info->netcount || (info->tty && info->tty->termios->c_cflag & CREAD) ) 2822 if (info->netcount || (info->port.tty && info->port.tty->termios->c_cflag & CREAD) )
2829 rx_start(info); 2823 rx_start(info);
2830 2824
2831 spin_unlock_irqrestore(&info->lock,flags); 2825 spin_unlock_irqrestore(&info->lock,flags);
@@ -2838,14 +2832,14 @@ static void change_params(SLMP_INFO *info)
2838 unsigned cflag; 2832 unsigned cflag;
2839 int bits_per_char; 2833 int bits_per_char;
2840 2834
2841 if (!info->tty || !info->tty->termios) 2835 if (!info->port.tty || !info->port.tty->termios)
2842 return; 2836 return;
2843 2837
2844 if (debug_level >= DEBUG_LEVEL_INFO) 2838 if (debug_level >= DEBUG_LEVEL_INFO)
2845 printk("%s(%d):%s change_params()\n", 2839 printk("%s(%d):%s change_params()\n",
2846 __FILE__,__LINE__, info->device_name ); 2840 __FILE__,__LINE__, info->device_name );
2847 2841
2848 cflag = info->tty->termios->c_cflag; 2842 cflag = info->port.tty->termios->c_cflag;
2849 2843
2850 /* if B0 rate (hangup) specified then negate DTR and RTS */ 2844 /* if B0 rate (hangup) specified then negate DTR and RTS */
2851 /* otherwise assert DTR and RTS */ 2845 /* otherwise assert DTR and RTS */
@@ -2893,7 +2887,7 @@ static void change_params(SLMP_INFO *info)
2893 * current data rate. 2887 * current data rate.
2894 */ 2888 */
2895 if (info->params.data_rate <= 460800) { 2889 if (info->params.data_rate <= 460800) {
2896 info->params.data_rate = tty_get_baud_rate(info->tty); 2890 info->params.data_rate = tty_get_baud_rate(info->port.tty);
2897 } 2891 }
2898 2892
2899 if ( info->params.data_rate ) { 2893 if ( info->params.data_rate ) {
@@ -2903,30 +2897,30 @@ static void change_params(SLMP_INFO *info)
2903 info->timeout += HZ/50; /* Add .02 seconds of slop */ 2897 info->timeout += HZ/50; /* Add .02 seconds of slop */
2904 2898
2905 if (cflag & CRTSCTS) 2899 if (cflag & CRTSCTS)
2906 info->flags |= ASYNC_CTS_FLOW; 2900 info->port.flags |= ASYNC_CTS_FLOW;
2907 else 2901 else
2908 info->flags &= ~ASYNC_CTS_FLOW; 2902 info->port.flags &= ~ASYNC_CTS_FLOW;
2909 2903
2910 if (cflag & CLOCAL) 2904 if (cflag & CLOCAL)
2911 info->flags &= ~ASYNC_CHECK_CD; 2905 info->port.flags &= ~ASYNC_CHECK_CD;
2912 else 2906 else
2913 info->flags |= ASYNC_CHECK_CD; 2907 info->port.flags |= ASYNC_CHECK_CD;
2914 2908
2915 /* process tty input control flags */ 2909 /* process tty input control flags */
2916 2910
2917 info->read_status_mask2 = OVRN; 2911 info->read_status_mask2 = OVRN;
2918 if (I_INPCK(info->tty)) 2912 if (I_INPCK(info->port.tty))
2919 info->read_status_mask2 |= PE | FRME; 2913 info->read_status_mask2 |= PE | FRME;
2920 if (I_BRKINT(info->tty) || I_PARMRK(info->tty)) 2914 if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
2921 info->read_status_mask1 |= BRKD; 2915 info->read_status_mask1 |= BRKD;
2922 if (I_IGNPAR(info->tty)) 2916 if (I_IGNPAR(info->port.tty))
2923 info->ignore_status_mask2 |= PE | FRME; 2917 info->ignore_status_mask2 |= PE | FRME;
2924 if (I_IGNBRK(info->tty)) { 2918 if (I_IGNBRK(info->port.tty)) {
2925 info->ignore_status_mask1 |= BRKD; 2919 info->ignore_status_mask1 |= BRKD;
2926 /* If ignoring parity and break indicators, ignore 2920 /* If ignoring parity and break indicators, ignore
2927 * overruns too. (For real raw support). 2921 * overruns too. (For real raw support).
2928 */ 2922 */
2929 if (I_IGNPAR(info->tty)) 2923 if (I_IGNPAR(info->port.tty))
2930 info->ignore_status_mask2 |= OVRN; 2924 info->ignore_status_mask2 |= OVRN;
2931 } 2925 }
2932 2926
@@ -3346,7 +3340,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3346 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ 3340 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){
3347 /* nonblock mode is set or port is not enabled */ 3341 /* nonblock mode is set or port is not enabled */
3348 /* just verify that callout device is not active */ 3342 /* just verify that callout device is not active */
3349 info->flags |= ASYNC_NORMAL_ACTIVE; 3343 info->port.flags |= ASYNC_NORMAL_ACTIVE;
3350 return 0; 3344 return 0;
3351 } 3345 }
3352 3346
@@ -3355,25 +3349,25 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3355 3349
3356 /* Wait for carrier detect and the line to become 3350 /* Wait for carrier detect and the line to become
3357 * free (i.e., not in use by the callout). While we are in 3351 * free (i.e., not in use by the callout). While we are in
3358 * this loop, info->count is dropped by one, so that 3352 * this loop, info->port.count is dropped by one, so that
3359 * close() knows when to free things. We restore it upon 3353 * close() knows when to free things. We restore it upon
3360 * exit, either normal or abnormal. 3354 * exit, either normal or abnormal.
3361 */ 3355 */
3362 3356
3363 retval = 0; 3357 retval = 0;
3364 add_wait_queue(&info->open_wait, &wait); 3358 add_wait_queue(&info->port.open_wait, &wait);
3365 3359
3366 if (debug_level >= DEBUG_LEVEL_INFO) 3360 if (debug_level >= DEBUG_LEVEL_INFO)
3367 printk("%s(%d):%s block_til_ready() before block, count=%d\n", 3361 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
3368 __FILE__,__LINE__, tty->driver->name, info->count ); 3362 __FILE__,__LINE__, tty->driver->name, info->port.count );
3369 3363
3370 spin_lock_irqsave(&info->lock, flags); 3364 spin_lock_irqsave(&info->lock, flags);
3371 if (!tty_hung_up_p(filp)) { 3365 if (!tty_hung_up_p(filp)) {
3372 extra_count = true; 3366 extra_count = true;
3373 info->count--; 3367 info->port.count--;
3374 } 3368 }
3375 spin_unlock_irqrestore(&info->lock, flags); 3369 spin_unlock_irqrestore(&info->lock, flags);
3376 info->blocked_open++; 3370 info->port.blocked_open++;
3377 3371
3378 while (1) { 3372 while (1) {
3379 if ((tty->termios->c_cflag & CBAUD)) { 3373 if ((tty->termios->c_cflag & CBAUD)) {
@@ -3385,8 +3379,8 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3385 3379
3386 set_current_state(TASK_INTERRUPTIBLE); 3380 set_current_state(TASK_INTERRUPTIBLE);
3387 3381
3388 if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)){ 3382 if (tty_hung_up_p(filp) || !(info->port.flags & ASYNC_INITIALIZED)){
3389 retval = (info->flags & ASYNC_HUP_NOTIFY) ? 3383 retval = (info->port.flags & ASYNC_HUP_NOTIFY) ?
3390 -EAGAIN : -ERESTARTSYS; 3384 -EAGAIN : -ERESTARTSYS;
3391 break; 3385 break;
3392 } 3386 }
@@ -3395,7 +3389,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3395 get_signals(info); 3389 get_signals(info);
3396 spin_unlock_irqrestore(&info->lock,flags); 3390 spin_unlock_irqrestore(&info->lock,flags);
3397 3391
3398 if (!(info->flags & ASYNC_CLOSING) && 3392 if (!(info->port.flags & ASYNC_CLOSING) &&
3399 (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) { 3393 (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) {
3400 break; 3394 break;
3401 } 3395 }
@@ -3407,24 +3401,24 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3407 3401
3408 if (debug_level >= DEBUG_LEVEL_INFO) 3402 if (debug_level >= DEBUG_LEVEL_INFO)
3409 printk("%s(%d):%s block_til_ready() count=%d\n", 3403 printk("%s(%d):%s block_til_ready() count=%d\n",
3410 __FILE__,__LINE__, tty->driver->name, info->count ); 3404 __FILE__,__LINE__, tty->driver->name, info->port.count );
3411 3405
3412 schedule(); 3406 schedule();
3413 } 3407 }
3414 3408
3415 set_current_state(TASK_RUNNING); 3409 set_current_state(TASK_RUNNING);
3416 remove_wait_queue(&info->open_wait, &wait); 3410 remove_wait_queue(&info->port.open_wait, &wait);
3417 3411
3418 if (extra_count) 3412 if (extra_count)
3419 info->count++; 3413 info->port.count++;
3420 info->blocked_open--; 3414 info->port.blocked_open--;
3421 3415
3422 if (debug_level >= DEBUG_LEVEL_INFO) 3416 if (debug_level >= DEBUG_LEVEL_INFO)
3423 printk("%s(%d):%s block_til_ready() after, count=%d\n", 3417 printk("%s(%d):%s block_til_ready() after, count=%d\n",
3424 __FILE__,__LINE__, tty->driver->name, info->count ); 3418 __FILE__,__LINE__, tty->driver->name, info->port.count );
3425 3419
3426 if (!retval) 3420 if (!retval)
3427 info->flags |= ASYNC_NORMAL_ACTIVE; 3421 info->port.flags |= ASYNC_NORMAL_ACTIVE;
3428 3422
3429 return retval; 3423 return retval;
3430} 3424}
@@ -3806,13 +3800,12 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev)
3806 printk("%s(%d) Error can't allocate device instance data for adapter %d, port %d\n", 3800 printk("%s(%d) Error can't allocate device instance data for adapter %d, port %d\n",
3807 __FILE__,__LINE__, adapter_num, port_num); 3801 __FILE__,__LINE__, adapter_num, port_num);
3808 } else { 3802 } else {
3803 tty_port_init(&info->port);
3809 info->magic = MGSL_MAGIC; 3804 info->magic = MGSL_MAGIC;
3810 INIT_WORK(&info->task, bh_handler); 3805 INIT_WORK(&info->task, bh_handler);
3811 info->max_frame_size = 4096; 3806 info->max_frame_size = 4096;
3812 info->close_delay = 5*HZ/10; 3807 info->port.close_delay = 5*HZ/10;
3813 info->closing_wait = 30*HZ; 3808 info->port.closing_wait = 30*HZ;
3814 init_waitqueue_head(&info->open_wait);
3815 init_waitqueue_head(&info->close_wait);
3816 init_waitqueue_head(&info->status_event_wait_q); 3809 init_waitqueue_head(&info->status_event_wait_q);
3817 init_waitqueue_head(&info->event_wait_q); 3810 init_waitqueue_head(&info->event_wait_q);
3818 spin_lock_init(&info->netlock); 3811 spin_lock_init(&info->netlock);
@@ -4883,7 +4876,7 @@ static bool rx_get_frame(SLMP_INFO *info)
4883 unsigned int framesize = 0; 4876 unsigned int framesize = 0;
4884 bool ReturnCode = false; 4877 bool ReturnCode = false;
4885 unsigned long flags; 4878 unsigned long flags;
4886 struct tty_struct *tty = info->tty; 4879 struct tty_struct *tty = info->port.tty;
4887 unsigned char addr_field = 0xff; 4880 unsigned char addr_field = 0xff;
4888 SCADESC *desc; 4881 SCADESC *desc;
4889 SCADESC_EX *desc_ex; 4882 SCADESC_EX *desc_ex;
@@ -5290,11 +5283,11 @@ static bool loopback_test(SLMP_INFO *info)
5290 bool rc = false; 5283 bool rc = false;
5291 unsigned long flags; 5284 unsigned long flags;
5292 5285
5293 struct tty_struct *oldtty = info->tty; 5286 struct tty_struct *oldtty = info->port.tty;
5294 u32 speed = info->params.clock_speed; 5287 u32 speed = info->params.clock_speed;
5295 5288
5296 info->params.clock_speed = 3686400; 5289 info->params.clock_speed = 3686400;
5297 info->tty = NULL; 5290 info->port.tty = NULL;
5298 5291
5299 /* assume failure */ 5292 /* assume failure */
5300 info->init_error = DiagStatus_DmaFailure; 5293 info->init_error = DiagStatus_DmaFailure;
@@ -5338,7 +5331,7 @@ static bool loopback_test(SLMP_INFO *info)
5338 spin_unlock_irqrestore(&info->lock,flags); 5331 spin_unlock_irqrestore(&info->lock,flags);
5339 5332
5340 info->params.clock_speed = speed; 5333 info->params.clock_speed = speed;
5341 info->tty = oldtty; 5334 info->port.tty = oldtty;
5342 5335
5343 return rc; 5336 return rc;
5344} 5337}