aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-07-16 16:56:46 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-20 20:12:37 -0400
commit8fb06c771399b8d51d724756411108e9abe2a85a (patch)
tree8f1bfa4d03c545def4968141420c727074d89da2 /drivers
parentf8ae47641611fcdf175ab8bbe89054731b16971d (diff)
synclink: use tty_port
Switch the synclink ports 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')
-rw-r--r--drivers/char/synclink.c195
-rw-r--r--drivers/char/synclink_gt.c201
-rw-r--r--drivers/char/synclinkmp.c203
3 files changed, 289 insertions, 310 deletions
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index 5e4b2e638d0c..734098f7dfa2 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -180,8 +180,7 @@ struct tx_holding_buffer {
180 180
181struct mgsl_struct { 181struct mgsl_struct {
182 int magic; 182 int magic;
183 int flags; 183 struct tty_port port;
184 int count; /* count of opens */
185 int line; 184 int line;
186 int hw_version; 185 int hw_version;
187 unsigned short close_delay; 186 unsigned short close_delay;
@@ -189,10 +188,8 @@ struct mgsl_struct {
189 188
190 struct mgsl_icount icount; 189 struct mgsl_icount icount;
191 190
192 struct tty_struct *tty;
193 int timeout; 191 int timeout;
194 int x_char; /* xon/xoff character */ 192 int x_char; /* xon/xoff character */
195 int blocked_open; /* # of blocked opens */
196 u16 read_status_mask; 193 u16 read_status_mask;
197 u16 ignore_status_mask; 194 u16 ignore_status_mask;
198 unsigned char *xmit_buf; 195 unsigned char *xmit_buf;
@@ -200,9 +197,6 @@ struct mgsl_struct {
200 int xmit_tail; 197 int xmit_tail;
201 int xmit_cnt; 198 int xmit_cnt;
202 199
203 wait_queue_head_t open_wait;
204 wait_queue_head_t close_wait;
205
206 wait_queue_head_t status_event_wait_q; 200 wait_queue_head_t status_event_wait_q;
207 wait_queue_head_t event_wait_q; 201 wait_queue_head_t event_wait_q;
208 struct timer_list tx_timer; /* HDLC transmit timeout timer */ 202 struct timer_list tx_timer; /* HDLC transmit timeout timer */
@@ -1134,7 +1128,7 @@ static void mgsl_bh_receive(struct mgsl_struct *info)
1134 1128
1135static void mgsl_bh_transmit(struct mgsl_struct *info) 1129static void mgsl_bh_transmit(struct mgsl_struct *info)
1136{ 1130{
1137 struct tty_struct *tty = info->tty; 1131 struct tty_struct *tty = info->port.tty;
1138 unsigned long flags; 1132 unsigned long flags;
1139 1133
1140 if ( debug_level >= DEBUG_LEVEL_BH ) 1134 if ( debug_level >= DEBUG_LEVEL_BH )
@@ -1276,7 +1270,7 @@ static void mgsl_isr_transmit_status( struct mgsl_struct *info )
1276 else 1270 else
1277#endif 1271#endif
1278 { 1272 {
1279 if (info->tty->stopped || info->tty->hw_stopped) { 1273 if (info->port.tty->stopped || info->port.tty->hw_stopped) {
1280 usc_stop_transmitter(info); 1274 usc_stop_transmitter(info);
1281 return; 1275 return;
1282 } 1276 }
@@ -1357,29 +1351,29 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )
1357 wake_up_interruptible(&info->status_event_wait_q); 1351 wake_up_interruptible(&info->status_event_wait_q);
1358 wake_up_interruptible(&info->event_wait_q); 1352 wake_up_interruptible(&info->event_wait_q);
1359 1353
1360 if ( (info->flags & ASYNC_CHECK_CD) && 1354 if ( (info->port.flags & ASYNC_CHECK_CD) &&
1361 (status & MISCSTATUS_DCD_LATCHED) ) { 1355 (status & MISCSTATUS_DCD_LATCHED) ) {
1362 if ( debug_level >= DEBUG_LEVEL_ISR ) 1356 if ( debug_level >= DEBUG_LEVEL_ISR )
1363 printk("%s CD now %s...", info->device_name, 1357 printk("%s CD now %s...", info->device_name,
1364 (status & MISCSTATUS_DCD) ? "on" : "off"); 1358 (status & MISCSTATUS_DCD) ? "on" : "off");
1365 if (status & MISCSTATUS_DCD) 1359 if (status & MISCSTATUS_DCD)
1366 wake_up_interruptible(&info->open_wait); 1360 wake_up_interruptible(&info->port.open_wait);
1367 else { 1361 else {
1368 if ( debug_level >= DEBUG_LEVEL_ISR ) 1362 if ( debug_level >= DEBUG_LEVEL_ISR )
1369 printk("doing serial hangup..."); 1363 printk("doing serial hangup...");
1370 if (info->tty) 1364 if (info->port.tty)
1371 tty_hangup(info->tty); 1365 tty_hangup(info->port.tty);
1372 } 1366 }
1373 } 1367 }
1374 1368
1375 if ( (info->flags & ASYNC_CTS_FLOW) && 1369 if ( (info->port.flags & ASYNC_CTS_FLOW) &&
1376 (status & MISCSTATUS_CTS_LATCHED) ) { 1370 (status & MISCSTATUS_CTS_LATCHED) ) {
1377 if (info->tty->hw_stopped) { 1371 if (info->port.tty->hw_stopped) {
1378 if (status & MISCSTATUS_CTS) { 1372 if (status & MISCSTATUS_CTS) {
1379 if ( debug_level >= DEBUG_LEVEL_ISR ) 1373 if ( debug_level >= DEBUG_LEVEL_ISR )
1380 printk("CTS tx start..."); 1374 printk("CTS tx start...");
1381 if (info->tty) 1375 if (info->port.tty)
1382 info->tty->hw_stopped = 0; 1376 info->port.tty->hw_stopped = 0;
1383 usc_start_transmitter(info); 1377 usc_start_transmitter(info);
1384 info->pending_bh |= BH_TRANSMIT; 1378 info->pending_bh |= BH_TRANSMIT;
1385 return; 1379 return;
@@ -1388,8 +1382,8 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )
1388 if (!(status & MISCSTATUS_CTS)) { 1382 if (!(status & MISCSTATUS_CTS)) {
1389 if ( debug_level >= DEBUG_LEVEL_ISR ) 1383 if ( debug_level >= DEBUG_LEVEL_ISR )
1390 printk("CTS tx stop..."); 1384 printk("CTS tx stop...");
1391 if (info->tty) 1385 if (info->port.tty)
1392 info->tty->hw_stopped = 1; 1386 info->port.tty->hw_stopped = 1;
1393 usc_stop_transmitter(info); 1387 usc_stop_transmitter(info);
1394 } 1388 }
1395 } 1389 }
@@ -1423,7 +1417,7 @@ static void mgsl_isr_transmit_data( struct mgsl_struct *info )
1423 1417
1424 usc_ClearIrqPendingBits( info, TRANSMIT_DATA ); 1418 usc_ClearIrqPendingBits( info, TRANSMIT_DATA );
1425 1419
1426 if (info->tty->stopped || info->tty->hw_stopped) { 1420 if (info->port.tty->stopped || info->port.tty->hw_stopped) {
1427 usc_stop_transmitter(info); 1421 usc_stop_transmitter(info);
1428 return; 1422 return;
1429 } 1423 }
@@ -1453,7 +1447,7 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info )
1453 u16 status; 1447 u16 status;
1454 int work = 0; 1448 int work = 0;
1455 unsigned char DataByte; 1449 unsigned char DataByte;
1456 struct tty_struct *tty = info->tty; 1450 struct tty_struct *tty = info->port.tty;
1457 struct mgsl_icount *icount = &info->icount; 1451 struct mgsl_icount *icount = &info->icount;
1458 1452
1459 if ( debug_level >= DEBUG_LEVEL_ISR ) 1453 if ( debug_level >= DEBUG_LEVEL_ISR )
@@ -1514,7 +1508,7 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info )
1514 1508
1515 if (status & RXSTATUS_BREAK_RECEIVED) { 1509 if (status & RXSTATUS_BREAK_RECEIVED) {
1516 flag = TTY_BREAK; 1510 flag = TTY_BREAK;
1517 if (info->flags & ASYNC_SAK) 1511 if (info->port.flags & ASYNC_SAK)
1518 do_SAK(tty); 1512 do_SAK(tty);
1519 } else if (status & RXSTATUS_PARITY_ERROR) 1513 } else if (status & RXSTATUS_PARITY_ERROR)
1520 flag = TTY_PARITY; 1514 flag = TTY_PARITY;
@@ -1771,7 +1765,7 @@ static int startup(struct mgsl_struct * info)
1771 if ( debug_level >= DEBUG_LEVEL_INFO ) 1765 if ( debug_level >= DEBUG_LEVEL_INFO )
1772 printk("%s(%d):mgsl_startup(%s)\n",__FILE__,__LINE__,info->device_name); 1766 printk("%s(%d):mgsl_startup(%s)\n",__FILE__,__LINE__,info->device_name);
1773 1767
1774 if (info->flags & ASYNC_INITIALIZED) 1768 if (info->port.flags & ASYNC_INITIALIZED)
1775 return 0; 1769 return 0;
1776 1770
1777 if (!info->xmit_buf) { 1771 if (!info->xmit_buf) {
@@ -1798,8 +1792,8 @@ static int startup(struct mgsl_struct * info)
1798 retval = mgsl_adapter_test(info); 1792 retval = mgsl_adapter_test(info);
1799 1793
1800 if ( retval ) { 1794 if ( retval ) {
1801 if (capable(CAP_SYS_ADMIN) && info->tty) 1795 if (capable(CAP_SYS_ADMIN) && info->port.tty)
1802 set_bit(TTY_IO_ERROR, &info->tty->flags); 1796 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
1803 mgsl_release_resources(info); 1797 mgsl_release_resources(info);
1804 return retval; 1798 return retval;
1805 } 1799 }
@@ -1807,10 +1801,10 @@ static int startup(struct mgsl_struct * info)
1807 /* program hardware for current parameters */ 1801 /* program hardware for current parameters */
1808 mgsl_change_params(info); 1802 mgsl_change_params(info);
1809 1803
1810 if (info->tty) 1804 if (info->port.tty)
1811 clear_bit(TTY_IO_ERROR, &info->tty->flags); 1805 clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
1812 1806
1813 info->flags |= ASYNC_INITIALIZED; 1807 info->port.flags |= ASYNC_INITIALIZED;
1814 1808
1815 return 0; 1809 return 0;
1816 1810
@@ -1827,7 +1821,7 @@ static void shutdown(struct mgsl_struct * info)
1827{ 1821{
1828 unsigned long flags; 1822 unsigned long flags;
1829 1823
1830 if (!(info->flags & ASYNC_INITIALIZED)) 1824 if (!(info->port.flags & ASYNC_INITIALIZED))
1831 return; 1825 return;
1832 1826
1833 if (debug_level >= DEBUG_LEVEL_INFO) 1827 if (debug_level >= DEBUG_LEVEL_INFO)
@@ -1864,7 +1858,7 @@ static void shutdown(struct mgsl_struct * info)
1864 /* on the ISA adapter. This has no effect for the PCI adapter */ 1858 /* on the ISA adapter. This has no effect for the PCI adapter */
1865 usc_OutReg(info, PCR, (u16)((usc_InReg(info, PCR) | BIT13) | BIT12)); 1859 usc_OutReg(info, PCR, (u16)((usc_InReg(info, PCR) | BIT13) | BIT12));
1866 1860
1867 if (!info->tty || info->tty->termios->c_cflag & HUPCL) { 1861 if (!info->port.tty || info->port.tty->termios->c_cflag & HUPCL) {
1868 info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); 1862 info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS);
1869 usc_set_serial_signals(info); 1863 usc_set_serial_signals(info);
1870 } 1864 }
@@ -1873,10 +1867,10 @@ static void shutdown(struct mgsl_struct * info)
1873 1867
1874 mgsl_release_resources(info); 1868 mgsl_release_resources(info);
1875 1869
1876 if (info->tty) 1870 if (info->port.tty)
1877 set_bit(TTY_IO_ERROR, &info->tty->flags); 1871 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
1878 1872
1879 info->flags &= ~ASYNC_INITIALIZED; 1873 info->port.flags &= ~ASYNC_INITIALIZED;
1880 1874
1881} /* end of shutdown() */ 1875} /* end of shutdown() */
1882 1876
@@ -1908,7 +1902,7 @@ static void mgsl_program_hw(struct mgsl_struct *info)
1908 usc_EnableInterrupts(info, IO_PIN); 1902 usc_EnableInterrupts(info, IO_PIN);
1909 usc_get_serial_signals(info); 1903 usc_get_serial_signals(info);
1910 1904
1911 if (info->netcount || info->tty->termios->c_cflag & CREAD) 1905 if (info->netcount || info->port.tty->termios->c_cflag & CREAD)
1912 usc_start_receiver(info); 1906 usc_start_receiver(info);
1913 1907
1914 spin_unlock_irqrestore(&info->irq_spinlock,flags); 1908 spin_unlock_irqrestore(&info->irq_spinlock,flags);
@@ -1921,14 +1915,14 @@ static void mgsl_change_params(struct mgsl_struct *info)
1921 unsigned cflag; 1915 unsigned cflag;
1922 int bits_per_char; 1916 int bits_per_char;
1923 1917
1924 if (!info->tty || !info->tty->termios) 1918 if (!info->port.tty || !info->port.tty->termios)
1925 return; 1919 return;
1926 1920
1927 if (debug_level >= DEBUG_LEVEL_INFO) 1921 if (debug_level >= DEBUG_LEVEL_INFO)
1928 printk("%s(%d):mgsl_change_params(%s)\n", 1922 printk("%s(%d):mgsl_change_params(%s)\n",
1929 __FILE__,__LINE__, info->device_name ); 1923 __FILE__,__LINE__, info->device_name );
1930 1924
1931 cflag = info->tty->termios->c_cflag; 1925 cflag = info->port.tty->termios->c_cflag;
1932 1926
1933 /* if B0 rate (hangup) specified then negate DTR and RTS */ 1927 /* if B0 rate (hangup) specified then negate DTR and RTS */
1934 /* otherwise assert DTR and RTS */ 1928 /* otherwise assert DTR and RTS */
@@ -1976,7 +1970,7 @@ static void mgsl_change_params(struct mgsl_struct *info)
1976 * current data rate. 1970 * current data rate.
1977 */ 1971 */
1978 if (info->params.data_rate <= 460800) 1972 if (info->params.data_rate <= 460800)
1979 info->params.data_rate = tty_get_baud_rate(info->tty); 1973 info->params.data_rate = tty_get_baud_rate(info->port.tty);
1980 1974
1981 if ( info->params.data_rate ) { 1975 if ( info->params.data_rate ) {
1982 info->timeout = (32*HZ*bits_per_char) / 1976 info->timeout = (32*HZ*bits_per_char) /
@@ -1985,31 +1979,31 @@ static void mgsl_change_params(struct mgsl_struct *info)
1985 info->timeout += HZ/50; /* Add .02 seconds of slop */ 1979 info->timeout += HZ/50; /* Add .02 seconds of slop */
1986 1980
1987 if (cflag & CRTSCTS) 1981 if (cflag & CRTSCTS)
1988 info->flags |= ASYNC_CTS_FLOW; 1982 info->port.flags |= ASYNC_CTS_FLOW;
1989 else 1983 else
1990 info->flags &= ~ASYNC_CTS_FLOW; 1984 info->port.flags &= ~ASYNC_CTS_FLOW;
1991 1985
1992 if (cflag & CLOCAL) 1986 if (cflag & CLOCAL)
1993 info->flags &= ~ASYNC_CHECK_CD; 1987 info->port.flags &= ~ASYNC_CHECK_CD;
1994 else 1988 else
1995 info->flags |= ASYNC_CHECK_CD; 1989 info->port.flags |= ASYNC_CHECK_CD;
1996 1990
1997 /* process tty input control flags */ 1991 /* process tty input control flags */
1998 1992
1999 info->read_status_mask = RXSTATUS_OVERRUN; 1993 info->read_status_mask = RXSTATUS_OVERRUN;
2000 if (I_INPCK(info->tty)) 1994 if (I_INPCK(info->port.tty))
2001 info->read_status_mask |= RXSTATUS_PARITY_ERROR | RXSTATUS_FRAMING_ERROR; 1995 info->read_status_mask |= RXSTATUS_PARITY_ERROR | RXSTATUS_FRAMING_ERROR;
2002 if (I_BRKINT(info->tty) || I_PARMRK(info->tty)) 1996 if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
2003 info->read_status_mask |= RXSTATUS_BREAK_RECEIVED; 1997 info->read_status_mask |= RXSTATUS_BREAK_RECEIVED;
2004 1998
2005 if (I_IGNPAR(info->tty)) 1999 if (I_IGNPAR(info->port.tty))
2006 info->ignore_status_mask |= RXSTATUS_PARITY_ERROR | RXSTATUS_FRAMING_ERROR; 2000 info->ignore_status_mask |= RXSTATUS_PARITY_ERROR | RXSTATUS_FRAMING_ERROR;
2007 if (I_IGNBRK(info->tty)) { 2001 if (I_IGNBRK(info->port.tty)) {
2008 info->ignore_status_mask |= RXSTATUS_BREAK_RECEIVED; 2002 info->ignore_status_mask |= RXSTATUS_BREAK_RECEIVED;
2009 /* If ignoring parity and break indicators, ignore 2003 /* If ignoring parity and break indicators, ignore
2010 * overruns too. (For real raw support). 2004 * overruns too. (For real raw support).
2011 */ 2005 */
2012 if (I_IGNPAR(info->tty)) 2006 if (I_IGNPAR(info->port.tty))
2013 info->ignore_status_mask |= RXSTATUS_OVERRUN; 2007 info->ignore_status_mask |= RXSTATUS_OVERRUN;
2014 } 2008 }
2015 2009
@@ -3113,32 +3107,32 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
3113 3107
3114 if (debug_level >= DEBUG_LEVEL_INFO) 3108 if (debug_level >= DEBUG_LEVEL_INFO)
3115 printk("%s(%d):mgsl_close(%s) entry, count=%d\n", 3109 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
3116 __FILE__,__LINE__, info->device_name, info->count); 3110 __FILE__,__LINE__, info->device_name, info->port.count);
3117 3111
3118 if (!info->count) 3112 if (!info->port.count)
3119 return; 3113 return;
3120 3114
3121 if (tty_hung_up_p(filp)) 3115 if (tty_hung_up_p(filp))
3122 goto cleanup; 3116 goto cleanup;
3123 3117
3124 if ((tty->count == 1) && (info->count != 1)) { 3118 if ((tty->count == 1) && (info->port.count != 1)) {
3125 /* 3119 /*
3126 * tty->count is 1 and the tty structure will be freed. 3120 * tty->count is 1 and the tty structure will be freed.
3127 * info->count should be one in this case. 3121 * info->port.count should be one in this case.
3128 * if it's not, correct it so that the port is shutdown. 3122 * if it's not, correct it so that the port is shutdown.
3129 */ 3123 */
3130 printk("mgsl_close: bad refcount; tty->count is 1, " 3124 printk("mgsl_close: bad refcount; tty->count is 1, "
3131 "info->count is %d\n", info->count); 3125 "info->port.count is %d\n", info->port.count);
3132 info->count = 1; 3126 info->port.count = 1;
3133 } 3127 }
3134 3128
3135 info->count--; 3129 info->port.count--;
3136 3130
3137 /* if at least one open remaining, leave hardware active */ 3131 /* if at least one open remaining, leave hardware active */
3138 if (info->count) 3132 if (info->port.count)
3139 goto cleanup; 3133 goto cleanup;
3140 3134
3141 info->flags |= ASYNC_CLOSING; 3135 info->port.flags |= ASYNC_CLOSING;
3142 3136
3143 /* set tty->closing to notify line discipline to 3137 /* set tty->closing to notify line discipline to
3144 * only process XON/XOFF characters. Only the N_TTY 3138 * only process XON/XOFF characters. Only the N_TTY
@@ -3155,7 +3149,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
3155 tty_wait_until_sent(tty, info->closing_wait); 3149 tty_wait_until_sent(tty, info->closing_wait);
3156 } 3150 }
3157 3151
3158 if (info->flags & ASYNC_INITIALIZED) 3152 if (info->port.flags & ASYNC_INITIALIZED)
3159 mgsl_wait_until_sent(tty, info->timeout); 3153 mgsl_wait_until_sent(tty, info->timeout);
3160 3154
3161 mgsl_flush_buffer(tty); 3155 mgsl_flush_buffer(tty);
@@ -3165,23 +3159,23 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
3165 shutdown(info); 3159 shutdown(info);
3166 3160
3167 tty->closing = 0; 3161 tty->closing = 0;
3168 info->tty = NULL; 3162 info->port.tty = NULL;
3169 3163
3170 if (info->blocked_open) { 3164 if (info->port.blocked_open) {
3171 if (info->close_delay) { 3165 if (info->close_delay) {
3172 msleep_interruptible(jiffies_to_msecs(info->close_delay)); 3166 msleep_interruptible(jiffies_to_msecs(info->close_delay));
3173 } 3167 }
3174 wake_up_interruptible(&info->open_wait); 3168 wake_up_interruptible(&info->port.open_wait);
3175 } 3169 }
3176 3170
3177 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 3171 info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
3178 3172
3179 wake_up_interruptible(&info->close_wait); 3173 wake_up_interruptible(&info->port.close_wait);
3180 3174
3181cleanup: 3175cleanup:
3182 if (debug_level >= DEBUG_LEVEL_INFO) 3176 if (debug_level >= DEBUG_LEVEL_INFO)
3183 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__, 3177 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
3184 tty->driver->name, info->count); 3178 tty->driver->name, info->port.count);
3185 3179
3186} /* end of mgsl_close() */ 3180} /* end of mgsl_close() */
3187 3181
@@ -3211,7 +3205,7 @@ static void mgsl_wait_until_sent(struct tty_struct *tty, int timeout)
3211 if (mgsl_paranoia_check(info, tty->name, "mgsl_wait_until_sent")) 3205 if (mgsl_paranoia_check(info, tty->name, "mgsl_wait_until_sent"))
3212 return; 3206 return;
3213 3207
3214 if (!(info->flags & ASYNC_INITIALIZED)) 3208 if (!(info->port.flags & ASYNC_INITIALIZED))
3215 goto exit; 3209 goto exit;
3216 3210
3217 orig_jiffies = jiffies; 3211 orig_jiffies = jiffies;
@@ -3283,11 +3277,11 @@ static void mgsl_hangup(struct tty_struct *tty)
3283 mgsl_flush_buffer(tty); 3277 mgsl_flush_buffer(tty);
3284 shutdown(info); 3278 shutdown(info);
3285 3279
3286 info->count = 0; 3280 info->port.count = 0;
3287 info->flags &= ~ASYNC_NORMAL_ACTIVE; 3281 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
3288 info->tty = NULL; 3282 info->port.tty = NULL;
3289 3283
3290 wake_up_interruptible(&info->open_wait); 3284 wake_up_interruptible(&info->port.open_wait);
3291 3285
3292} /* end of mgsl_hangup() */ 3286} /* end of mgsl_hangup() */
3293 3287
@@ -3319,7 +3313,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
3319 3313
3320 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ 3314 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){
3321 /* nonblock mode is set or port is not enabled */ 3315 /* nonblock mode is set or port is not enabled */
3322 info->flags |= ASYNC_NORMAL_ACTIVE; 3316 info->port.flags |= ASYNC_NORMAL_ACTIVE;
3323 return 0; 3317 return 0;
3324 } 3318 }
3325 3319
@@ -3328,25 +3322,25 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
3328 3322
3329 /* Wait for carrier detect and the line to become 3323 /* Wait for carrier detect and the line to become
3330 * free (i.e., not in use by the callout). While we are in 3324 * free (i.e., not in use by the callout). While we are in
3331 * this loop, info->count is dropped by one, so that 3325 * this loop, info->port.count is dropped by one, so that
3332 * mgsl_close() knows when to free things. We restore it upon 3326 * mgsl_close() knows when to free things. We restore it upon
3333 * exit, either normal or abnormal. 3327 * exit, either normal or abnormal.
3334 */ 3328 */
3335 3329
3336 retval = 0; 3330 retval = 0;
3337 add_wait_queue(&info->open_wait, &wait); 3331 add_wait_queue(&info->port.open_wait, &wait);
3338 3332
3339 if (debug_level >= DEBUG_LEVEL_INFO) 3333 if (debug_level >= DEBUG_LEVEL_INFO)
3340 printk("%s(%d):block_til_ready before block on %s count=%d\n", 3334 printk("%s(%d):block_til_ready before block on %s count=%d\n",
3341 __FILE__,__LINE__, tty->driver->name, info->count ); 3335 __FILE__,__LINE__, tty->driver->name, info->port.count );
3342 3336
3343 spin_lock_irqsave(&info->irq_spinlock, flags); 3337 spin_lock_irqsave(&info->irq_spinlock, flags);
3344 if (!tty_hung_up_p(filp)) { 3338 if (!tty_hung_up_p(filp)) {
3345 extra_count = true; 3339 extra_count = true;
3346 info->count--; 3340 info->port.count--;
3347 } 3341 }
3348 spin_unlock_irqrestore(&info->irq_spinlock, flags); 3342 spin_unlock_irqrestore(&info->irq_spinlock, flags);
3349 info->blocked_open++; 3343 info->port.blocked_open++;
3350 3344
3351 while (1) { 3345 while (1) {
3352 if (tty->termios->c_cflag & CBAUD) { 3346 if (tty->termios->c_cflag & CBAUD) {
@@ -3358,8 +3352,8 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
3358 3352
3359 set_current_state(TASK_INTERRUPTIBLE); 3353 set_current_state(TASK_INTERRUPTIBLE);
3360 3354
3361 if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)){ 3355 if (tty_hung_up_p(filp) || !(info->port.flags & ASYNC_INITIALIZED)){
3362 retval = (info->flags & ASYNC_HUP_NOTIFY) ? 3356 retval = (info->port.flags & ASYNC_HUP_NOTIFY) ?
3363 -EAGAIN : -ERESTARTSYS; 3357 -EAGAIN : -ERESTARTSYS;
3364 break; 3358 break;
3365 } 3359 }
@@ -3368,7 +3362,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
3368 usc_get_serial_signals(info); 3362 usc_get_serial_signals(info);
3369 spin_unlock_irqrestore(&info->irq_spinlock,flags); 3363 spin_unlock_irqrestore(&info->irq_spinlock,flags);
3370 3364
3371 if (!(info->flags & ASYNC_CLOSING) && 3365 if (!(info->port.flags & ASYNC_CLOSING) &&
3372 (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) { 3366 (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) {
3373 break; 3367 break;
3374 } 3368 }
@@ -3380,24 +3374,24 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
3380 3374
3381 if (debug_level >= DEBUG_LEVEL_INFO) 3375 if (debug_level >= DEBUG_LEVEL_INFO)
3382 printk("%s(%d):block_til_ready blocking on %s count=%d\n", 3376 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
3383 __FILE__,__LINE__, tty->driver->name, info->count ); 3377 __FILE__,__LINE__, tty->driver->name, info->port.count );
3384 3378
3385 schedule(); 3379 schedule();
3386 } 3380 }
3387 3381
3388 set_current_state(TASK_RUNNING); 3382 set_current_state(TASK_RUNNING);
3389 remove_wait_queue(&info->open_wait, &wait); 3383 remove_wait_queue(&info->port.open_wait, &wait);
3390 3384
3391 if (extra_count) 3385 if (extra_count)
3392 info->count++; 3386 info->port.count++;
3393 info->blocked_open--; 3387 info->port.blocked_open--;
3394 3388
3395 if (debug_level >= DEBUG_LEVEL_INFO) 3389 if (debug_level >= DEBUG_LEVEL_INFO)
3396 printk("%s(%d):block_til_ready after blocking on %s count=%d\n", 3390 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
3397 __FILE__,__LINE__, tty->driver->name, info->count ); 3391 __FILE__,__LINE__, tty->driver->name, info->port.count );
3398 3392
3399 if (!retval) 3393 if (!retval)
3400 info->flags |= ASYNC_NORMAL_ACTIVE; 3394 info->port.flags |= ASYNC_NORMAL_ACTIVE;
3401 3395
3402 return retval; 3396 return retval;
3403 3397
@@ -3435,22 +3429,22 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
3435 return -ENODEV; 3429 return -ENODEV;
3436 3430
3437 tty->driver_data = info; 3431 tty->driver_data = info;
3438 info->tty = tty; 3432 info->port.tty = tty;
3439 3433
3440 if (debug_level >= DEBUG_LEVEL_INFO) 3434 if (debug_level >= DEBUG_LEVEL_INFO)
3441 printk("%s(%d):mgsl_open(%s), old ref count = %d\n", 3435 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
3442 __FILE__,__LINE__,tty->driver->name, info->count); 3436 __FILE__,__LINE__,tty->driver->name, info->port.count);
3443 3437
3444 /* If port is closing, signal caller to try again */ 3438 /* If port is closing, signal caller to try again */
3445 if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){ 3439 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
3446 if (info->flags & ASYNC_CLOSING) 3440 if (info->port.flags & ASYNC_CLOSING)
3447 interruptible_sleep_on(&info->close_wait); 3441 interruptible_sleep_on(&info->port.close_wait);
3448 retval = ((info->flags & ASYNC_HUP_NOTIFY) ? 3442 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
3449 -EAGAIN : -ERESTARTSYS); 3443 -EAGAIN : -ERESTARTSYS);
3450 goto cleanup; 3444 goto cleanup;
3451 } 3445 }
3452 3446
3453 info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 3447 info->port.tty->low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
3454 3448
3455 spin_lock_irqsave(&info->netlock, flags); 3449 spin_lock_irqsave(&info->netlock, flags);
3456 if (info->netcount) { 3450 if (info->netcount) {
@@ -3458,10 +3452,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
3458 spin_unlock_irqrestore(&info->netlock, flags); 3452 spin_unlock_irqrestore(&info->netlock, flags);
3459 goto cleanup; 3453 goto cleanup;
3460 } 3454 }
3461 info->count++; 3455 info->port.count++;
3462 spin_unlock_irqrestore(&info->netlock, flags); 3456 spin_unlock_irqrestore(&info->netlock, flags);
3463 3457
3464 if (info->count == 1) { 3458 if (info->port.count == 1) {
3465 /* 1st open on this device, init hardware */ 3459 /* 1st open on this device, init hardware */
3466 retval = startup(info); 3460 retval = startup(info);
3467 if (retval < 0) 3461 if (retval < 0)
@@ -3484,9 +3478,9 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
3484cleanup: 3478cleanup:
3485 if (retval) { 3479 if (retval) {
3486 if (tty->count == 1) 3480 if (tty->count == 1)
3487 info->tty = NULL; /* tty layer will release tty struct */ 3481 info->port.tty = NULL; /* tty layer will release tty struct */
3488 if(info->count) 3482 if(info->port.count)
3489 info->count--; 3483 info->port.count--;
3490 } 3484 }
3491 3485
3492 return retval; 3486 return retval;
@@ -4337,8 +4331,7 @@ static struct mgsl_struct* mgsl_allocate_device(void)
4337 info->max_frame_size = 4096; 4331 info->max_frame_size = 4096;
4338 info->close_delay = 5*HZ/10; 4332 info->close_delay = 5*HZ/10;
4339 info->closing_wait = 30*HZ; 4333 info->closing_wait = 30*HZ;
4340 init_waitqueue_head(&info->open_wait); 4334 tty_port_init(&info->port);
4341 init_waitqueue_head(&info->close_wait);
4342 init_waitqueue_head(&info->status_event_wait_q); 4335 init_waitqueue_head(&info->status_event_wait_q);
4343 init_waitqueue_head(&info->event_wait_q); 4336 init_waitqueue_head(&info->event_wait_q);
4344 spin_lock_init(&info->irq_spinlock); 4337 spin_lock_init(&info->irq_spinlock);
@@ -6575,7 +6568,7 @@ static bool mgsl_get_rx_frame(struct mgsl_struct *info)
6575 unsigned int framesize = 0; 6568 unsigned int framesize = 0;
6576 bool ReturnCode = false; 6569 bool ReturnCode = false;
6577 unsigned long flags; 6570 unsigned long flags;
6578 struct tty_struct *tty = info->tty; 6571 struct tty_struct *tty = info->port.tty;
6579 bool return_frame = false; 6572 bool return_frame = false;
6580 6573
6581 /* 6574 /*
@@ -6774,7 +6767,7 @@ static bool mgsl_get_raw_rx_frame(struct mgsl_struct *info)
6774 unsigned int framesize = 0; 6767 unsigned int framesize = 0;
6775 bool ReturnCode = false; 6768 bool ReturnCode = false;
6776 unsigned long flags; 6769 unsigned long flags;
6777 struct tty_struct *tty = info->tty; 6770 struct tty_struct *tty = info->port.tty;
6778 6771
6779 /* 6772 /*
6780 * current_rx_buffer points to the 1st buffer of the next available 6773 * current_rx_buffer points to the 1st buffer of the next available
@@ -7711,7 +7704,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
7711 unsigned short new_crctype; 7704 unsigned short new_crctype;
7712 7705
7713 /* return error if TTY interface open */ 7706 /* return error if TTY interface open */
7714 if (info->count) 7707 if (info->port.count)
7715 return -EBUSY; 7708 return -EBUSY;
7716 7709
7717 switch (encoding) 7710 switch (encoding)
@@ -7808,7 +7801,7 @@ static int hdlcdev_open(struct net_device *dev)
7808 7801
7809 /* arbitrate between network and tty opens */ 7802 /* arbitrate between network and tty opens */
7810 spin_lock_irqsave(&info->netlock, flags); 7803 spin_lock_irqsave(&info->netlock, flags);
7811 if (info->count != 0 || info->netcount != 0) { 7804 if (info->port.count != 0 || info->netcount != 0) {
7812 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name); 7805 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
7813 spin_unlock_irqrestore(&info->netlock, flags); 7806 spin_unlock_irqrestore(&info->netlock, flags);
7814 return -EBUSY; 7807 return -EBUSY;
@@ -7894,7 +7887,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
7894 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name); 7887 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
7895 7888
7896 /* return error if TTY interface open */ 7889 /* return error if TTY interface open */
7897 if (info->count) 7890 if (info->port.count)
7898 return -EBUSY; 7891 return -EBUSY;
7899 7892
7900 if (cmd != SIOCWANDEV) 7893 if (cmd != SIOCWANDEV)
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index e473778cd6fa..fc71d9819165 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,17 @@ 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; 264 unsigned short close_delay;
266 unsigned short closing_wait; /* time to wait before closing */ 265 unsigned short closing_wait; /* time to wait before closing */
267 266
268 struct mgsl_icount icount; 267 struct mgsl_icount icount;
269 268
270 struct tty_struct *tty;
271 int timeout; 269 int timeout;
272 int x_char; /* xon/xoff character */ 270 int x_char; /* xon/xoff character */
273 int blocked_open; /* # of blocked opens */
274 unsigned int read_status_mask; 271 unsigned int read_status_mask;
275 unsigned int ignore_status_mask; 272 unsigned int ignore_status_mask;
276 273
277 wait_queue_head_t open_wait;
278 wait_queue_head_t close_wait;
279
280 wait_queue_head_t status_event_wait_q; 274 wait_queue_head_t status_event_wait_q;
281 wait_queue_head_t event_wait_q; 275 wait_queue_head_t event_wait_q;
282 struct timer_list tx_timer; 276 struct timer_list tx_timer;
@@ -672,20 +666,20 @@ static int open(struct tty_struct *tty, struct file *filp)
672 } 666 }
673 667
674 tty->driver_data = info; 668 tty->driver_data = info;
675 info->tty = tty; 669 info->port.tty = tty;
676 670
677 DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->count)); 671 DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
678 672
679 /* If port is closing, signal caller to try again */ 673 /* If port is closing, signal caller to try again */
680 if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){ 674 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
681 if (info->flags & ASYNC_CLOSING) 675 if (info->port.flags & ASYNC_CLOSING)
682 interruptible_sleep_on(&info->close_wait); 676 interruptible_sleep_on(&info->port.close_wait);
683 retval = ((info->flags & ASYNC_HUP_NOTIFY) ? 677 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
684 -EAGAIN : -ERESTARTSYS); 678 -EAGAIN : -ERESTARTSYS);
685 goto cleanup; 679 goto cleanup;
686 } 680 }
687 681
688 info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 682 info->port.tty->low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
689 683
690 spin_lock_irqsave(&info->netlock, flags); 684 spin_lock_irqsave(&info->netlock, flags);
691 if (info->netcount) { 685 if (info->netcount) {
@@ -693,10 +687,10 @@ static int open(struct tty_struct *tty, struct file *filp)
693 spin_unlock_irqrestore(&info->netlock, flags); 687 spin_unlock_irqrestore(&info->netlock, flags);
694 goto cleanup; 688 goto cleanup;
695 } 689 }
696 info->count++; 690 info->port.count++;
697 spin_unlock_irqrestore(&info->netlock, flags); 691 spin_unlock_irqrestore(&info->netlock, flags);
698 692
699 if (info->count == 1) { 693 if (info->port.count == 1) {
700 /* 1st open on this device, init hardware */ 694 /* 1st open on this device, init hardware */
701 retval = startup(info); 695 retval = startup(info);
702 if (retval < 0) 696 if (retval < 0)
@@ -714,9 +708,9 @@ static int open(struct tty_struct *tty, struct file *filp)
714cleanup: 708cleanup:
715 if (retval) { 709 if (retval) {
716 if (tty->count == 1) 710 if (tty->count == 1)
717 info->tty = NULL; /* tty layer will release tty struct */ 711 info->port.tty = NULL; /* tty layer will release tty struct */
718 if(info->count) 712 if(info->port.count)
719 info->count--; 713 info->port.count--;
720 } 714 }
721 715
722 DBGINFO(("%s open rc=%d\n", info->device_name, retval)); 716 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
@@ -729,32 +723,32 @@ static void close(struct tty_struct *tty, struct file *filp)
729 723
730 if (sanity_check(info, tty->name, "close")) 724 if (sanity_check(info, tty->name, "close"))
731 return; 725 return;
732 DBGINFO(("%s close entry, count=%d\n", info->device_name, info->count)); 726 DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
733 727
734 if (!info->count) 728 if (!info->port.count)
735 return; 729 return;
736 730
737 if (tty_hung_up_p(filp)) 731 if (tty_hung_up_p(filp))
738 goto cleanup; 732 goto cleanup;
739 733
740 if ((tty->count == 1) && (info->count != 1)) { 734 if ((tty->count == 1) && (info->port.count != 1)) {
741 /* 735 /*
742 * tty->count is 1 and the tty structure will be freed. 736 * tty->count is 1 and the tty structure will be freed.
743 * info->count should be one in this case. 737 * info->port.count should be one in this case.
744 * if it's not, correct it so that the port is shutdown. 738 * if it's not, correct it so that the port is shutdown.
745 */ 739 */
746 DBGERR(("%s close: bad refcount; tty->count=1, " 740 DBGERR(("%s close: bad refcount; tty->count=1, "
747 "info->count=%d\n", info->device_name, info->count)); 741 "info->port.count=%d\n", info->device_name, info->port.count));
748 info->count = 1; 742 info->port.count = 1;
749 } 743 }
750 744
751 info->count--; 745 info->port.count--;
752 746
753 /* if at least one open remaining, leave hardware active */ 747 /* if at least one open remaining, leave hardware active */
754 if (info->count) 748 if (info->port.count)
755 goto cleanup; 749 goto cleanup;
756 750
757 info->flags |= ASYNC_CLOSING; 751 info->port.flags |= ASYNC_CLOSING;
758 752
759 /* set tty->closing to notify line discipline to 753 /* set tty->closing to notify line discipline to
760 * only process XON/XOFF characters. Only the N_TTY 754 * only process XON/XOFF characters. Only the N_TTY
@@ -769,7 +763,7 @@ static void close(struct tty_struct *tty, struct file *filp)
769 tty_wait_until_sent(tty, info->closing_wait); 763 tty_wait_until_sent(tty, info->closing_wait);
770 } 764 }
771 765
772 if (info->flags & ASYNC_INITIALIZED) 766 if (info->port.flags & ASYNC_INITIALIZED)
773 wait_until_sent(tty, info->timeout); 767 wait_until_sent(tty, info->timeout);
774 flush_buffer(tty); 768 flush_buffer(tty);
775 tty_ldisc_flush(tty); 769 tty_ldisc_flush(tty);
@@ -777,21 +771,21 @@ static void close(struct tty_struct *tty, struct file *filp)
777 shutdown(info); 771 shutdown(info);
778 772
779 tty->closing = 0; 773 tty->closing = 0;
780 info->tty = NULL; 774 info->port.tty = NULL;
781 775
782 if (info->blocked_open) { 776 if (info->port.blocked_open) {
783 if (info->close_delay) { 777 if (info->close_delay) {
784 msleep_interruptible(jiffies_to_msecs(info->close_delay)); 778 msleep_interruptible(jiffies_to_msecs(info->close_delay));
785 } 779 }
786 wake_up_interruptible(&info->open_wait); 780 wake_up_interruptible(&info->port.open_wait);
787 } 781 }
788 782
789 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 783 info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
790 784
791 wake_up_interruptible(&info->close_wait); 785 wake_up_interruptible(&info->port.close_wait);
792 786
793cleanup: 787cleanup:
794 DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->count)); 788 DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
795} 789}
796 790
797static void hangup(struct tty_struct *tty) 791static void hangup(struct tty_struct *tty)
@@ -805,11 +799,11 @@ static void hangup(struct tty_struct *tty)
805 flush_buffer(tty); 799 flush_buffer(tty);
806 shutdown(info); 800 shutdown(info);
807 801
808 info->count = 0; 802 info->port.count = 0;
809 info->flags &= ~ASYNC_NORMAL_ACTIVE; 803 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
810 info->tty = NULL; 804 info->port.tty = NULL;
811 805
812 wake_up_interruptible(&info->open_wait); 806 wake_up_interruptible(&info->port.open_wait);
813} 807}
814 808
815static void set_termios(struct tty_struct *tty, struct ktermios *old_termios) 809static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
@@ -959,7 +953,7 @@ static void wait_until_sent(struct tty_struct *tty, int timeout)
959 if (sanity_check(info, tty->name, "wait_until_sent")) 953 if (sanity_check(info, tty->name, "wait_until_sent"))
960 return; 954 return;
961 DBGINFO(("%s wait_until_sent entry\n", info->device_name)); 955 DBGINFO(("%s wait_until_sent entry\n", info->device_name));
962 if (!(info->flags & ASYNC_INITIALIZED)) 956 if (!(info->port.flags & ASYNC_INITIALIZED))
963 goto exit; 957 goto exit;
964 958
965 orig_jiffies = jiffies; 959 orig_jiffies = jiffies;
@@ -1500,7 +1494,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
1500 unsigned short new_crctype; 1494 unsigned short new_crctype;
1501 1495
1502 /* return error if TTY interface open */ 1496 /* return error if TTY interface open */
1503 if (info->count) 1497 if (info->port.count)
1504 return -EBUSY; 1498 return -EBUSY;
1505 1499
1506 DBGINFO(("%s hdlcdev_attach\n", info->device_name)); 1500 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
@@ -1600,7 +1594,7 @@ static int hdlcdev_open(struct net_device *dev)
1600 1594
1601 /* arbitrate between network and tty opens */ 1595 /* arbitrate between network and tty opens */
1602 spin_lock_irqsave(&info->netlock, flags); 1596 spin_lock_irqsave(&info->netlock, flags);
1603 if (info->count != 0 || info->netcount != 0) { 1597 if (info->port.count != 0 || info->netcount != 0) {
1604 DBGINFO(("%s hdlc_open busy\n", dev->name)); 1598 DBGINFO(("%s hdlc_open busy\n", dev->name));
1605 spin_unlock_irqrestore(&info->netlock, flags); 1599 spin_unlock_irqrestore(&info->netlock, flags);
1606 return -EBUSY; 1600 return -EBUSY;
@@ -1685,7 +1679,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1685 DBGINFO(("%s hdlcdev_ioctl\n", dev->name)); 1679 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
1686 1680
1687 /* return error if TTY interface open */ 1681 /* return error if TTY interface open */
1688 if (info->count) 1682 if (info->port.count)
1689 return -EBUSY; 1683 return -EBUSY;
1690 1684
1691 if (cmd != SIOCWANDEV) 1685 if (cmd != SIOCWANDEV)
@@ -1906,7 +1900,7 @@ static void hdlcdev_exit(struct slgt_info *info)
1906 */ 1900 */
1907static void rx_async(struct slgt_info *info) 1901static void rx_async(struct slgt_info *info)
1908{ 1902{
1909 struct tty_struct *tty = info->tty; 1903 struct tty_struct *tty = info->port.tty;
1910 struct mgsl_icount *icount = &info->icount; 1904 struct mgsl_icount *icount = &info->icount;
1911 unsigned int start, end; 1905 unsigned int start, end;
1912 unsigned char *p; 1906 unsigned char *p;
@@ -2057,7 +2051,7 @@ static void bh_handler(struct work_struct *work)
2057 2051
2058static void bh_transmit(struct slgt_info *info) 2052static void bh_transmit(struct slgt_info *info)
2059{ 2053{
2060 struct tty_struct *tty = info->tty; 2054 struct tty_struct *tty = info->port.tty;
2061 2055
2062 DBGBH(("%s bh_transmit\n", info->device_name)); 2056 DBGBH(("%s bh_transmit\n", info->device_name));
2063 if (tty) 2057 if (tty)
@@ -2103,17 +2097,17 @@ static void cts_change(struct slgt_info *info, unsigned short status)
2103 wake_up_interruptible(&info->event_wait_q); 2097 wake_up_interruptible(&info->event_wait_q);
2104 info->pending_bh |= BH_STATUS; 2098 info->pending_bh |= BH_STATUS;
2105 2099
2106 if (info->flags & ASYNC_CTS_FLOW) { 2100 if (info->port.flags & ASYNC_CTS_FLOW) {
2107 if (info->tty) { 2101 if (info->port.tty) {
2108 if (info->tty->hw_stopped) { 2102 if (info->port.tty->hw_stopped) {
2109 if (info->signals & SerialSignal_CTS) { 2103 if (info->signals & SerialSignal_CTS) {
2110 info->tty->hw_stopped = 0; 2104 info->port.tty->hw_stopped = 0;
2111 info->pending_bh |= BH_TRANSMIT; 2105 info->pending_bh |= BH_TRANSMIT;
2112 return; 2106 return;
2113 } 2107 }
2114 } else { 2108 } else {
2115 if (!(info->signals & SerialSignal_CTS)) 2109 if (!(info->signals & SerialSignal_CTS))
2116 info->tty->hw_stopped = 1; 2110 info->port.tty->hw_stopped = 1;
2117 } 2111 }
2118 } 2112 }
2119 } 2113 }
@@ -2146,12 +2140,12 @@ static void dcd_change(struct slgt_info *info, unsigned short status)
2146 wake_up_interruptible(&info->event_wait_q); 2140 wake_up_interruptible(&info->event_wait_q);
2147 info->pending_bh |= BH_STATUS; 2141 info->pending_bh |= BH_STATUS;
2148 2142
2149 if (info->flags & ASYNC_CHECK_CD) { 2143 if (info->port.flags & ASYNC_CHECK_CD) {
2150 if (info->signals & SerialSignal_DCD) 2144 if (info->signals & SerialSignal_DCD)
2151 wake_up_interruptible(&info->open_wait); 2145 wake_up_interruptible(&info->port.open_wait);
2152 else { 2146 else {
2153 if (info->tty) 2147 if (info->port.tty)
2154 tty_hangup(info->tty); 2148 tty_hangup(info->port.tty);
2155 } 2149 }
2156 } 2150 }
2157} 2151}
@@ -2194,12 +2188,12 @@ static void isr_serial(struct slgt_info *info)
2194 if ((status & IRQ_RXBREAK) && (status & RXBREAK)) { 2188 if ((status & IRQ_RXBREAK) && (status & RXBREAK)) {
2195 info->icount.brk++; 2189 info->icount.brk++;
2196 /* process break detection if tty control allows */ 2190 /* process break detection if tty control allows */
2197 if (info->tty) { 2191 if (info->port.tty) {
2198 if (!(status & info->ignore_status_mask)) { 2192 if (!(status & info->ignore_status_mask)) {
2199 if (info->read_status_mask & MASK_BREAK) { 2193 if (info->read_status_mask & MASK_BREAK) {
2200 tty_insert_flip_char(info->tty, 0, TTY_BREAK); 2194 tty_insert_flip_char(info->port.tty, 0, TTY_BREAK);
2201 if (info->flags & ASYNC_SAK) 2195 if (info->port.flags & ASYNC_SAK)
2202 do_SAK(info->tty); 2196 do_SAK(info->port.tty);
2203 } 2197 }
2204 } 2198 }
2205 } 2199 }
@@ -2319,7 +2313,7 @@ static void isr_txeom(struct slgt_info *info, unsigned short status)
2319 else 2313 else
2320#endif 2314#endif
2321 { 2315 {
2322 if (info->tty && (info->tty->stopped || info->tty->hw_stopped)) { 2316 if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) {
2323 tx_stop(info); 2317 tx_stop(info);
2324 return; 2318 return;
2325 } 2319 }
@@ -2395,7 +2389,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
2395 for(i=0; i < info->port_count ; i++) { 2389 for(i=0; i < info->port_count ; i++) {
2396 struct slgt_info *port = info->port_array[i]; 2390 struct slgt_info *port = info->port_array[i];
2397 2391
2398 if (port && (port->count || port->netcount) && 2392 if (port && (port->port.count || port->netcount) &&
2399 port->pending_bh && !port->bh_running && 2393 port->pending_bh && !port->bh_running &&
2400 !port->bh_requested) { 2394 !port->bh_requested) {
2401 DBGISR(("%s bh queued\n", port->device_name)); 2395 DBGISR(("%s bh queued\n", port->device_name));
@@ -2414,7 +2408,7 @@ static int startup(struct slgt_info *info)
2414{ 2408{
2415 DBGINFO(("%s startup\n", info->device_name)); 2409 DBGINFO(("%s startup\n", info->device_name));
2416 2410
2417 if (info->flags & ASYNC_INITIALIZED) 2411 if (info->port.flags & ASYNC_INITIALIZED)
2418 return 0; 2412 return 0;
2419 2413
2420 if (!info->tx_buf) { 2414 if (!info->tx_buf) {
@@ -2432,10 +2426,10 @@ static int startup(struct slgt_info *info)
2432 /* program hardware for current parameters */ 2426 /* program hardware for current parameters */
2433 change_params(info); 2427 change_params(info);
2434 2428
2435 if (info->tty) 2429 if (info->port.tty)
2436 clear_bit(TTY_IO_ERROR, &info->tty->flags); 2430 clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
2437 2431
2438 info->flags |= ASYNC_INITIALIZED; 2432 info->port.flags |= ASYNC_INITIALIZED;
2439 2433
2440 return 0; 2434 return 0;
2441} 2435}
@@ -2447,7 +2441,7 @@ static void shutdown(struct slgt_info *info)
2447{ 2441{
2448 unsigned long flags; 2442 unsigned long flags;
2449 2443
2450 if (!(info->flags & ASYNC_INITIALIZED)) 2444 if (!(info->port.flags & ASYNC_INITIALIZED))
2451 return; 2445 return;
2452 2446
2453 DBGINFO(("%s shutdown\n", info->device_name)); 2447 DBGINFO(("%s shutdown\n", info->device_name));
@@ -2470,7 +2464,7 @@ static void shutdown(struct slgt_info *info)
2470 2464
2471 slgt_irq_off(info, IRQ_ALL | IRQ_MASTER); 2465 slgt_irq_off(info, IRQ_ALL | IRQ_MASTER);
2472 2466
2473 if (!info->tty || info->tty->termios->c_cflag & HUPCL) { 2467 if (!info->port.tty || info->port.tty->termios->c_cflag & HUPCL) {
2474 info->signals &= ~(SerialSignal_DTR + SerialSignal_RTS); 2468 info->signals &= ~(SerialSignal_DTR + SerialSignal_RTS);
2475 set_signals(info); 2469 set_signals(info);
2476 } 2470 }
@@ -2479,10 +2473,10 @@ static void shutdown(struct slgt_info *info)
2479 2473
2480 spin_unlock_irqrestore(&info->lock,flags); 2474 spin_unlock_irqrestore(&info->lock,flags);
2481 2475
2482 if (info->tty) 2476 if (info->port.tty)
2483 set_bit(TTY_IO_ERROR, &info->tty->flags); 2477 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
2484 2478
2485 info->flags &= ~ASYNC_INITIALIZED; 2479 info->port.flags &= ~ASYNC_INITIALIZED;
2486} 2480}
2487 2481
2488static void program_hw(struct slgt_info *info) 2482static void program_hw(struct slgt_info *info)
@@ -2511,7 +2505,7 @@ static void program_hw(struct slgt_info *info)
2511 get_signals(info); 2505 get_signals(info);
2512 2506
2513 if (info->netcount || 2507 if (info->netcount ||
2514 (info->tty && info->tty->termios->c_cflag & CREAD)) 2508 (info->port.tty && info->port.tty->termios->c_cflag & CREAD))
2515 rx_start(info); 2509 rx_start(info);
2516 2510
2517 spin_unlock_irqrestore(&info->lock,flags); 2511 spin_unlock_irqrestore(&info->lock,flags);
@@ -2525,11 +2519,11 @@ static void change_params(struct slgt_info *info)
2525 unsigned cflag; 2519 unsigned cflag;
2526 int bits_per_char; 2520 int bits_per_char;
2527 2521
2528 if (!info->tty || !info->tty->termios) 2522 if (!info->port.tty || !info->port.tty->termios)
2529 return; 2523 return;
2530 DBGINFO(("%s change_params\n", info->device_name)); 2524 DBGINFO(("%s change_params\n", info->device_name));
2531 2525
2532 cflag = info->tty->termios->c_cflag; 2526 cflag = info->port.tty->termios->c_cflag;
2533 2527
2534 /* if B0 rate (hangup) specified then negate DTR and RTS */ 2528 /* if B0 rate (hangup) specified then negate DTR and RTS */
2535 /* otherwise assert DTR and RTS */ 2529 /* otherwise assert DTR and RTS */
@@ -2561,7 +2555,7 @@ static void change_params(struct slgt_info *info)
2561 bits_per_char = info->params.data_bits + 2555 bits_per_char = info->params.data_bits +
2562 info->params.stop_bits + 1; 2556 info->params.stop_bits + 1;
2563 2557
2564 info->params.data_rate = tty_get_baud_rate(info->tty); 2558 info->params.data_rate = tty_get_baud_rate(info->port.tty);
2565 2559
2566 if (info->params.data_rate) { 2560 if (info->params.data_rate) {
2567 info->timeout = (32*HZ*bits_per_char) / 2561 info->timeout = (32*HZ*bits_per_char) /
@@ -2570,30 +2564,30 @@ static void change_params(struct slgt_info *info)
2570 info->timeout += HZ/50; /* Add .02 seconds of slop */ 2564 info->timeout += HZ/50; /* Add .02 seconds of slop */
2571 2565
2572 if (cflag & CRTSCTS) 2566 if (cflag & CRTSCTS)
2573 info->flags |= ASYNC_CTS_FLOW; 2567 info->port.flags |= ASYNC_CTS_FLOW;
2574 else 2568 else
2575 info->flags &= ~ASYNC_CTS_FLOW; 2569 info->port.flags &= ~ASYNC_CTS_FLOW;
2576 2570
2577 if (cflag & CLOCAL) 2571 if (cflag & CLOCAL)
2578 info->flags &= ~ASYNC_CHECK_CD; 2572 info->port.flags &= ~ASYNC_CHECK_CD;
2579 else 2573 else
2580 info->flags |= ASYNC_CHECK_CD; 2574 info->port.flags |= ASYNC_CHECK_CD;
2581 2575
2582 /* process tty input control flags */ 2576 /* process tty input control flags */
2583 2577
2584 info->read_status_mask = IRQ_RXOVER; 2578 info->read_status_mask = IRQ_RXOVER;
2585 if (I_INPCK(info->tty)) 2579 if (I_INPCK(info->port.tty))
2586 info->read_status_mask |= MASK_PARITY | MASK_FRAMING; 2580 info->read_status_mask |= MASK_PARITY | MASK_FRAMING;
2587 if (I_BRKINT(info->tty) || I_PARMRK(info->tty)) 2581 if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
2588 info->read_status_mask |= MASK_BREAK; 2582 info->read_status_mask |= MASK_BREAK;
2589 if (I_IGNPAR(info->tty)) 2583 if (I_IGNPAR(info->port.tty))
2590 info->ignore_status_mask |= MASK_PARITY | MASK_FRAMING; 2584 info->ignore_status_mask |= MASK_PARITY | MASK_FRAMING;
2591 if (I_IGNBRK(info->tty)) { 2585 if (I_IGNBRK(info->port.tty)) {
2592 info->ignore_status_mask |= MASK_BREAK; 2586 info->ignore_status_mask |= MASK_BREAK;
2593 /* If ignoring parity and break indicators, ignore 2587 /* If ignoring parity and break indicators, ignore
2594 * overruns too. (For real raw support). 2588 * overruns too. (For real raw support).
2595 */ 2589 */
2596 if (I_IGNPAR(info->tty)) 2590 if (I_IGNPAR(info->port.tty))
2597 info->ignore_status_mask |= MASK_OVERRUN; 2591 info->ignore_status_mask |= MASK_OVERRUN;
2598 } 2592 }
2599 2593
@@ -3144,7 +3138,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3144 3138
3145 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ 3139 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){
3146 /* nonblock mode is set or port is not enabled */ 3140 /* nonblock mode is set or port is not enabled */
3147 info->flags |= ASYNC_NORMAL_ACTIVE; 3141 info->port.flags |= ASYNC_NORMAL_ACTIVE;
3148 return 0; 3142 return 0;
3149 } 3143 }
3150 3144
@@ -3153,21 +3147,21 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3153 3147
3154 /* Wait for carrier detect and the line to become 3148 /* Wait for carrier detect and the line to become
3155 * free (i.e., not in use by the callout). While we are in 3149 * free (i.e., not in use by the callout). While we are in
3156 * this loop, info->count is dropped by one, so that 3150 * this loop, info->port.count is dropped by one, so that
3157 * close() knows when to free things. We restore it upon 3151 * close() knows when to free things. We restore it upon
3158 * exit, either normal or abnormal. 3152 * exit, either normal or abnormal.
3159 */ 3153 */
3160 3154
3161 retval = 0; 3155 retval = 0;
3162 add_wait_queue(&info->open_wait, &wait); 3156 add_wait_queue(&info->port.open_wait, &wait);
3163 3157
3164 spin_lock_irqsave(&info->lock, flags); 3158 spin_lock_irqsave(&info->lock, flags);
3165 if (!tty_hung_up_p(filp)) { 3159 if (!tty_hung_up_p(filp)) {
3166 extra_count = true; 3160 extra_count = true;
3167 info->count--; 3161 info->port.count--;
3168 } 3162 }
3169 spin_unlock_irqrestore(&info->lock, flags); 3163 spin_unlock_irqrestore(&info->lock, flags);
3170 info->blocked_open++; 3164 info->port.blocked_open++;
3171 3165
3172 while (1) { 3166 while (1) {
3173 if ((tty->termios->c_cflag & CBAUD)) { 3167 if ((tty->termios->c_cflag & CBAUD)) {
@@ -3179,8 +3173,8 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3179 3173
3180 set_current_state(TASK_INTERRUPTIBLE); 3174 set_current_state(TASK_INTERRUPTIBLE);
3181 3175
3182 if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)){ 3176 if (tty_hung_up_p(filp) || !(info->port.flags & ASYNC_INITIALIZED)){
3183 retval = (info->flags & ASYNC_HUP_NOTIFY) ? 3177 retval = (info->port.flags & ASYNC_HUP_NOTIFY) ?
3184 -EAGAIN : -ERESTARTSYS; 3178 -EAGAIN : -ERESTARTSYS;
3185 break; 3179 break;
3186 } 3180 }
@@ -3189,7 +3183,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3189 get_signals(info); 3183 get_signals(info);
3190 spin_unlock_irqrestore(&info->lock,flags); 3184 spin_unlock_irqrestore(&info->lock,flags);
3191 3185
3192 if (!(info->flags & ASYNC_CLOSING) && 3186 if (!(info->port.flags & ASYNC_CLOSING) &&
3193 (do_clocal || (info->signals & SerialSignal_DCD)) ) { 3187 (do_clocal || (info->signals & SerialSignal_DCD)) ) {
3194 break; 3188 break;
3195 } 3189 }
@@ -3204,14 +3198,14 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3204 } 3198 }
3205 3199
3206 set_current_state(TASK_RUNNING); 3200 set_current_state(TASK_RUNNING);
3207 remove_wait_queue(&info->open_wait, &wait); 3201 remove_wait_queue(&info->port.open_wait, &wait);
3208 3202
3209 if (extra_count) 3203 if (extra_count)
3210 info->count++; 3204 info->port.count++;
3211 info->blocked_open--; 3205 info->port.blocked_open--;
3212 3206
3213 if (!retval) 3207 if (!retval)
3214 info->flags |= ASYNC_NORMAL_ACTIVE; 3208 info->port.flags |= ASYNC_NORMAL_ACTIVE;
3215 3209
3216 DBGINFO(("%s block_til_ready ready, rc=%d\n", tty->driver->name, retval)); 3210 DBGINFO(("%s block_til_ready ready, rc=%d\n", tty->driver->name, retval));
3217 return retval; 3211 return retval;
@@ -3460,8 +3454,7 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev
3460 info->raw_rx_size = DMABUFSIZE; 3454 info->raw_rx_size = DMABUFSIZE;
3461 info->close_delay = 5*HZ/10; 3455 info->close_delay = 5*HZ/10;
3462 info->closing_wait = 30*HZ; 3456 info->closing_wait = 30*HZ;
3463 init_waitqueue_head(&info->open_wait); 3457 tty_port_init(&info->port);
3464 init_waitqueue_head(&info->close_wait);
3465 init_waitqueue_head(&info->status_event_wait_q); 3458 init_waitqueue_head(&info->status_event_wait_q);
3466 init_waitqueue_head(&info->event_wait_q); 3459 init_waitqueue_head(&info->event_wait_q);
3467 spin_lock_init(&info->netlock); 3460 spin_lock_init(&info->netlock);
@@ -4505,7 +4498,7 @@ static bool rx_get_frame(struct slgt_info *info)
4505 unsigned short status; 4498 unsigned short status;
4506 unsigned int framesize = 0; 4499 unsigned int framesize = 0;
4507 unsigned long flags; 4500 unsigned long flags;
4508 struct tty_struct *tty = info->tty; 4501 struct tty_struct *tty = info->port.tty;
4509 unsigned char addr_field = 0xff; 4502 unsigned char addr_field = 0xff;
4510 unsigned int crc_size = 0; 4503 unsigned int crc_size = 0;
4511 4504
@@ -4656,7 +4649,7 @@ static bool rx_get_buf(struct slgt_info *info)
4656 DBGDATA(info, info->rbufs[i].buf, count, "rx"); 4649 DBGDATA(info, info->rbufs[i].buf, count, "rx");
4657 DBGINFO(("rx_get_buf size=%d\n", count)); 4650 DBGINFO(("rx_get_buf size=%d\n", count));
4658 if (count) 4651 if (count)
4659 ldisc_receive_buf(info->tty, info->rbufs[i].buf, 4652 ldisc_receive_buf(info->port.tty, info->rbufs[i].buf,
4660 info->flag_buf, count); 4653 info->flag_buf, count);
4661 free_rbufs(info, i, i); 4654 free_rbufs(info, i, i);
4662 return true; 4655 return true;
@@ -4765,11 +4758,11 @@ static int irq_test(struct slgt_info *info)
4765{ 4758{
4766 unsigned long timeout; 4759 unsigned long timeout;
4767 unsigned long flags; 4760 unsigned long flags;
4768 struct tty_struct *oldtty = info->tty; 4761 struct tty_struct *oldtty = info->port.tty;
4769 u32 speed = info->params.data_rate; 4762 u32 speed = info->params.data_rate;
4770 4763
4771 info->params.data_rate = 921600; 4764 info->params.data_rate = 921600;
4772 info->tty = NULL; 4765 info->port.tty = NULL;
4773 4766
4774 spin_lock_irqsave(&info->lock, flags); 4767 spin_lock_irqsave(&info->lock, flags);
4775 async_mode(info); 4768 async_mode(info);
@@ -4797,7 +4790,7 @@ static int irq_test(struct slgt_info *info)
4797 spin_unlock_irqrestore(&info->lock,flags); 4790 spin_unlock_irqrestore(&info->lock,flags);
4798 4791
4799 info->params.data_rate = speed; 4792 info->params.data_rate = speed;
4800 info->tty = oldtty; 4793 info->port.tty = oldtty;
4801 4794
4802 info->init_error = info->irq_occurred ? 0 : DiagStatus_IrqFailure; 4795 info->init_error = info->irq_occurred ? 0 : DiagStatus_IrqFailure;
4803 return info->irq_occurred ? 0 : -ENODEV; 4796 return info->irq_occurred ? 0 : -ENODEV;
@@ -4837,7 +4830,7 @@ static int loopback_test(struct slgt_info *info)
4837 int rc = -ENODEV; 4830 int rc = -ENODEV;
4838 unsigned long flags; 4831 unsigned long flags;
4839 4832
4840 struct tty_struct *oldtty = info->tty; 4833 struct tty_struct *oldtty = info->port.tty;
4841 MGSL_PARAMS params; 4834 MGSL_PARAMS params;
4842 4835
4843 memcpy(&params, &info->params, sizeof(params)); 4836 memcpy(&params, &info->params, sizeof(params));
@@ -4845,7 +4838,7 @@ static int loopback_test(struct slgt_info *info)
4845 info->params.mode = MGSL_MODE_ASYNC; 4838 info->params.mode = MGSL_MODE_ASYNC;
4846 info->params.data_rate = 921600; 4839 info->params.data_rate = 921600;
4847 info->params.loopback = 1; 4840 info->params.loopback = 1;
4848 info->tty = NULL; 4841 info->port.tty = NULL;
4849 4842
4850 /* build and send transmit frame */ 4843 /* build and send transmit frame */
4851 for (count = 0; count < TESTFRAMESIZE; ++count) 4844 for (count = 0; count < TESTFRAMESIZE; ++count)
@@ -4883,7 +4876,7 @@ static int loopback_test(struct slgt_info *info)
4883 spin_unlock_irqrestore(&info->lock,flags); 4876 spin_unlock_irqrestore(&info->lock,flags);
4884 4877
4885 memcpy(&info->params, &params, sizeof(info->params)); 4878 memcpy(&info->params, &params, sizeof(info->params));
4886 info->tty = oldtty; 4879 info->port.tty = oldtty;
4887 4880
4888 info->init_error = rc ? DiagStatus_DmaFailure : 0; 4881 info->init_error = rc ? DiagStatus_DmaFailure : 0;
4889 return rc; 4882 return rc;
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index 5341b5aaf8bc..5b5b292d046b 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.
@@ -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
@@ -859,7 +853,7 @@ static void close(struct tty_struct *tty, struct file *filp)
859 tty_wait_until_sent(tty, info->closing_wait); 853 tty_wait_until_sent(tty, info->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->close_delay) {
876 msleep_interruptible(jiffies_to_msecs(info->close_delay)); 870 msleep_interruptible(jiffies_to_msecs(info->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)
@@ -1733,7 +1727,7 @@ static int hdlcdev_open(struct net_device *dev)
1733 1727
1734 /* arbitrate between network and tty opens */ 1728 /* arbitrate between network and tty opens */
1735 spin_lock_irqsave(&info->netlock, flags); 1729 spin_lock_irqsave(&info->netlock, flags);
1736 if (info->count != 0 || info->netcount != 0) { 1730 if (info->port.count != 0 || info->netcount != 0) {
1737 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name); 1731 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
1738 spin_unlock_irqrestore(&info->netlock, flags); 1732 spin_unlock_irqrestore(&info->netlock, flags);
1739 return -EBUSY; 1733 return -EBUSY;
@@ -1819,7 +1813,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1819 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name); 1813 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
1820 1814
1821 /* return error if TTY interface open */ 1815 /* return error if TTY interface open */
1822 if (info->count) 1816 if (info->port.count)
1823 return -EBUSY; 1817 return -EBUSY;
1824 1818
1825 if (cmd != SIOCWANDEV) 1819 if (cmd != SIOCWANDEV)
@@ -2128,7 +2122,7 @@ static void bh_receive(SLMP_INFO *info)
2128 2122
2129static void bh_transmit(SLMP_INFO *info) 2123static void bh_transmit(SLMP_INFO *info)
2130{ 2124{
2131 struct tty_struct *tty = info->tty; 2125 struct tty_struct *tty = info->port.tty;
2132 2126
2133 if ( debug_level >= DEBUG_LEVEL_BH ) 2127 if ( debug_level >= DEBUG_LEVEL_BH )
2134 printk( "%s(%d):%s bh_transmit() entry\n", 2128 printk( "%s(%d):%s bh_transmit() entry\n",
@@ -2178,7 +2172,7 @@ static void isr_timer(SLMP_INFO * info)
2178 2172
2179static void isr_rxint(SLMP_INFO * info) 2173static void isr_rxint(SLMP_INFO * info)
2180{ 2174{
2181 struct tty_struct *tty = info->tty; 2175 struct tty_struct *tty = info->port.tty;
2182 struct mgsl_icount *icount = &info->icount; 2176 struct mgsl_icount *icount = &info->icount;
2183 unsigned char status = read_reg(info, SR1) & info->ie1_value & (FLGD + IDLD + CDCD + BRKD); 2177 unsigned char status = read_reg(info, SR1) & info->ie1_value & (FLGD + IDLD + CDCD + BRKD);
2184 unsigned char status2 = read_reg(info, SR2) & info->ie2_value & OVRN; 2178 unsigned char status2 = read_reg(info, SR2) & info->ie2_value & OVRN;
@@ -2205,7 +2199,7 @@ static void isr_rxint(SLMP_INFO * info)
2205 if (!(status & info->ignore_status_mask1)) { 2199 if (!(status & info->ignore_status_mask1)) {
2206 if (info->read_status_mask1 & BRKD) { 2200 if (info->read_status_mask1 & BRKD) {
2207 tty_insert_flip_char(tty, 0, TTY_BREAK); 2201 tty_insert_flip_char(tty, 0, TTY_BREAK);
2208 if (info->flags & ASYNC_SAK) 2202 if (info->port.flags & ASYNC_SAK)
2209 do_SAK(tty); 2203 do_SAK(tty);
2210 } 2204 }
2211 } 2205 }
@@ -2239,7 +2233,7 @@ static void isr_rxrdy(SLMP_INFO * info)
2239{ 2233{
2240 u16 status; 2234 u16 status;
2241 unsigned char DataByte; 2235 unsigned char DataByte;
2242 struct tty_struct *tty = info->tty; 2236 struct tty_struct *tty = info->port.tty;
2243 struct mgsl_icount *icount = &info->icount; 2237 struct mgsl_icount *icount = &info->icount;
2244 2238
2245 if ( debug_level >= DEBUG_LEVEL_ISR ) 2239 if ( debug_level >= DEBUG_LEVEL_ISR )
@@ -2352,7 +2346,7 @@ static void isr_txeom(SLMP_INFO * info, unsigned char status)
2352 else 2346 else
2353#endif 2347#endif
2354 { 2348 {
2355 if (info->tty && (info->tty->stopped || info->tty->hw_stopped)) { 2349 if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) {
2356 tx_stop(info); 2350 tx_stop(info);
2357 return; 2351 return;
2358 } 2352 }
@@ -2407,7 +2401,7 @@ static void isr_txrdy(SLMP_INFO * info)
2407 return; 2401 return;
2408 } 2402 }
2409 2403
2410 if (info->tty && (info->tty->stopped || info->tty->hw_stopped)) { 2404 if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) {
2411 tx_stop(info); 2405 tx_stop(info);
2412 return; 2406 return;
2413 } 2407 }
@@ -2554,29 +2548,29 @@ static void isr_io_pin( SLMP_INFO *info, u16 status )
2554 wake_up_interruptible(&info->status_event_wait_q); 2548 wake_up_interruptible(&info->status_event_wait_q);
2555 wake_up_interruptible(&info->event_wait_q); 2549 wake_up_interruptible(&info->event_wait_q);
2556 2550
2557 if ( (info->flags & ASYNC_CHECK_CD) && 2551 if ( (info->port.flags & ASYNC_CHECK_CD) &&
2558 (status & MISCSTATUS_DCD_LATCHED) ) { 2552 (status & MISCSTATUS_DCD_LATCHED) ) {
2559 if ( debug_level >= DEBUG_LEVEL_ISR ) 2553 if ( debug_level >= DEBUG_LEVEL_ISR )
2560 printk("%s CD now %s...", info->device_name, 2554 printk("%s CD now %s...", info->device_name,
2561 (status & SerialSignal_DCD) ? "on" : "off"); 2555 (status & SerialSignal_DCD) ? "on" : "off");
2562 if (status & SerialSignal_DCD) 2556 if (status & SerialSignal_DCD)
2563 wake_up_interruptible(&info->open_wait); 2557 wake_up_interruptible(&info->port.open_wait);
2564 else { 2558 else {
2565 if ( debug_level >= DEBUG_LEVEL_ISR ) 2559 if ( debug_level >= DEBUG_LEVEL_ISR )
2566 printk("doing serial hangup..."); 2560 printk("doing serial hangup...");
2567 if (info->tty) 2561 if (info->port.tty)
2568 tty_hangup(info->tty); 2562 tty_hangup(info->port.tty);
2569 } 2563 }
2570 } 2564 }
2571 2565
2572 if ( (info->flags & ASYNC_CTS_FLOW) && 2566 if ( (info->port.flags & ASYNC_CTS_FLOW) &&
2573 (status & MISCSTATUS_CTS_LATCHED) ) { 2567 (status & MISCSTATUS_CTS_LATCHED) ) {
2574 if ( info->tty ) { 2568 if ( info->port.tty ) {
2575 if (info->tty->hw_stopped) { 2569 if (info->port.tty->hw_stopped) {
2576 if (status & SerialSignal_CTS) { 2570 if (status & SerialSignal_CTS) {
2577 if ( debug_level >= DEBUG_LEVEL_ISR ) 2571 if ( debug_level >= DEBUG_LEVEL_ISR )
2578 printk("CTS tx start..."); 2572 printk("CTS tx start...");
2579 info->tty->hw_stopped = 0; 2573 info->port.tty->hw_stopped = 0;
2580 tx_start(info); 2574 tx_start(info);
2581 info->pending_bh |= BH_TRANSMIT; 2575 info->pending_bh |= BH_TRANSMIT;
2582 return; 2576 return;
@@ -2585,7 +2579,7 @@ static void isr_io_pin( SLMP_INFO *info, u16 status )
2585 if (!(status & SerialSignal_CTS)) { 2579 if (!(status & SerialSignal_CTS)) {
2586 if ( debug_level >= DEBUG_LEVEL_ISR ) 2580 if ( debug_level >= DEBUG_LEVEL_ISR )
2587 printk("CTS tx stop..."); 2581 printk("CTS tx stop...");
2588 info->tty->hw_stopped = 1; 2582 info->port.tty->hw_stopped = 1;
2589 tx_stop(info); 2583 tx_stop(info);
2590 } 2584 }
2591 } 2585 }
@@ -2701,7 +2695,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
2701 * do not request bottom half processing if the 2695 * do not request bottom half processing if the
2702 * device is not open in a normal mode. 2696 * device is not open in a normal mode.
2703 */ 2697 */
2704 if ( port && (port->count || port->netcount) && 2698 if ( port && (port->port.count || port->netcount) &&
2705 port->pending_bh && !port->bh_running && 2699 port->pending_bh && !port->bh_running &&
2706 !port->bh_requested ) { 2700 !port->bh_requested ) {
2707 if ( debug_level >= DEBUG_LEVEL_ISR ) 2701 if ( debug_level >= DEBUG_LEVEL_ISR )
@@ -2727,7 +2721,7 @@ static int startup(SLMP_INFO * info)
2727 if ( debug_level >= DEBUG_LEVEL_INFO ) 2721 if ( debug_level >= DEBUG_LEVEL_INFO )
2728 printk("%s(%d):%s tx_releaseup()\n",__FILE__,__LINE__,info->device_name); 2722 printk("%s(%d):%s tx_releaseup()\n",__FILE__,__LINE__,info->device_name);
2729 2723
2730 if (info->flags & ASYNC_INITIALIZED) 2724 if (info->port.flags & ASYNC_INITIALIZED)
2731 return 0; 2725 return 0;
2732 2726
2733 if (!info->tx_buf) { 2727 if (!info->tx_buf) {
@@ -2750,10 +2744,10 @@ static int startup(SLMP_INFO * info)
2750 2744
2751 mod_timer(&info->status_timer, jiffies + msecs_to_jiffies(10)); 2745 mod_timer(&info->status_timer, jiffies + msecs_to_jiffies(10));
2752 2746
2753 if (info->tty) 2747 if (info->port.tty)
2754 clear_bit(TTY_IO_ERROR, &info->tty->flags); 2748 clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
2755 2749
2756 info->flags |= ASYNC_INITIALIZED; 2750 info->port.flags |= ASYNC_INITIALIZED;
2757 2751
2758 return 0; 2752 return 0;
2759} 2753}
@@ -2764,7 +2758,7 @@ static void shutdown(SLMP_INFO * info)
2764{ 2758{
2765 unsigned long flags; 2759 unsigned long flags;
2766 2760
2767 if (!(info->flags & ASYNC_INITIALIZED)) 2761 if (!(info->port.flags & ASYNC_INITIALIZED))
2768 return; 2762 return;
2769 2763
2770 if (debug_level >= DEBUG_LEVEL_INFO) 2764 if (debug_level >= DEBUG_LEVEL_INFO)
@@ -2786,17 +2780,17 @@ static void shutdown(SLMP_INFO * info)
2786 2780
2787 reset_port(info); 2781 reset_port(info);
2788 2782
2789 if (!info->tty || info->tty->termios->c_cflag & HUPCL) { 2783 if (!info->port.tty || info->port.tty->termios->c_cflag & HUPCL) {
2790 info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); 2784 info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS);
2791 set_signals(info); 2785 set_signals(info);
2792 } 2786 }
2793 2787
2794 spin_unlock_irqrestore(&info->lock,flags); 2788 spin_unlock_irqrestore(&info->lock,flags);
2795 2789
2796 if (info->tty) 2790 if (info->port.tty)
2797 set_bit(TTY_IO_ERROR, &info->tty->flags); 2791 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
2798 2792
2799 info->flags &= ~ASYNC_INITIALIZED; 2793 info->port.flags &= ~ASYNC_INITIALIZED;
2800} 2794}
2801 2795
2802static void program_hw(SLMP_INFO *info) 2796static void program_hw(SLMP_INFO *info)
@@ -2827,7 +2821,7 @@ static void program_hw(SLMP_INFO *info)
2827 2821
2828 get_signals(info); 2822 get_signals(info);
2829 2823
2830 if (info->netcount || (info->tty && info->tty->termios->c_cflag & CREAD) ) 2824 if (info->netcount || (info->port.tty && info->port.tty->termios->c_cflag & CREAD) )
2831 rx_start(info); 2825 rx_start(info);
2832 2826
2833 spin_unlock_irqrestore(&info->lock,flags); 2827 spin_unlock_irqrestore(&info->lock,flags);
@@ -2840,14 +2834,14 @@ static void change_params(SLMP_INFO *info)
2840 unsigned cflag; 2834 unsigned cflag;
2841 int bits_per_char; 2835 int bits_per_char;
2842 2836
2843 if (!info->tty || !info->tty->termios) 2837 if (!info->port.tty || !info->port.tty->termios)
2844 return; 2838 return;
2845 2839
2846 if (debug_level >= DEBUG_LEVEL_INFO) 2840 if (debug_level >= DEBUG_LEVEL_INFO)
2847 printk("%s(%d):%s change_params()\n", 2841 printk("%s(%d):%s change_params()\n",
2848 __FILE__,__LINE__, info->device_name ); 2842 __FILE__,__LINE__, info->device_name );
2849 2843
2850 cflag = info->tty->termios->c_cflag; 2844 cflag = info->port.tty->termios->c_cflag;
2851 2845
2852 /* if B0 rate (hangup) specified then negate DTR and RTS */ 2846 /* if B0 rate (hangup) specified then negate DTR and RTS */
2853 /* otherwise assert DTR and RTS */ 2847 /* otherwise assert DTR and RTS */
@@ -2895,7 +2889,7 @@ static void change_params(SLMP_INFO *info)
2895 * current data rate. 2889 * current data rate.
2896 */ 2890 */
2897 if (info->params.data_rate <= 460800) { 2891 if (info->params.data_rate <= 460800) {
2898 info->params.data_rate = tty_get_baud_rate(info->tty); 2892 info->params.data_rate = tty_get_baud_rate(info->port.tty);
2899 } 2893 }
2900 2894
2901 if ( info->params.data_rate ) { 2895 if ( info->params.data_rate ) {
@@ -2905,30 +2899,30 @@ static void change_params(SLMP_INFO *info)
2905 info->timeout += HZ/50; /* Add .02 seconds of slop */ 2899 info->timeout += HZ/50; /* Add .02 seconds of slop */
2906 2900
2907 if (cflag & CRTSCTS) 2901 if (cflag & CRTSCTS)
2908 info->flags |= ASYNC_CTS_FLOW; 2902 info->port.flags |= ASYNC_CTS_FLOW;
2909 else 2903 else
2910 info->flags &= ~ASYNC_CTS_FLOW; 2904 info->port.flags &= ~ASYNC_CTS_FLOW;
2911 2905
2912 if (cflag & CLOCAL) 2906 if (cflag & CLOCAL)
2913 info->flags &= ~ASYNC_CHECK_CD; 2907 info->port.flags &= ~ASYNC_CHECK_CD;
2914 else 2908 else
2915 info->flags |= ASYNC_CHECK_CD; 2909 info->port.flags |= ASYNC_CHECK_CD;
2916 2910
2917 /* process tty input control flags */ 2911 /* process tty input control flags */
2918 2912
2919 info->read_status_mask2 = OVRN; 2913 info->read_status_mask2 = OVRN;
2920 if (I_INPCK(info->tty)) 2914 if (I_INPCK(info->port.tty))
2921 info->read_status_mask2 |= PE | FRME; 2915 info->read_status_mask2 |= PE | FRME;
2922 if (I_BRKINT(info->tty) || I_PARMRK(info->tty)) 2916 if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
2923 info->read_status_mask1 |= BRKD; 2917 info->read_status_mask1 |= BRKD;
2924 if (I_IGNPAR(info->tty)) 2918 if (I_IGNPAR(info->port.tty))
2925 info->ignore_status_mask2 |= PE | FRME; 2919 info->ignore_status_mask2 |= PE | FRME;
2926 if (I_IGNBRK(info->tty)) { 2920 if (I_IGNBRK(info->port.tty)) {
2927 info->ignore_status_mask1 |= BRKD; 2921 info->ignore_status_mask1 |= BRKD;
2928 /* If ignoring parity and break indicators, ignore 2922 /* If ignoring parity and break indicators, ignore
2929 * overruns too. (For real raw support). 2923 * overruns too. (For real raw support).
2930 */ 2924 */
2931 if (I_IGNPAR(info->tty)) 2925 if (I_IGNPAR(info->port.tty))
2932 info->ignore_status_mask2 |= OVRN; 2926 info->ignore_status_mask2 |= OVRN;
2933 } 2927 }
2934 2928
@@ -3348,7 +3342,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3348 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ 3342 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){
3349 /* nonblock mode is set or port is not enabled */ 3343 /* nonblock mode is set or port is not enabled */
3350 /* just verify that callout device is not active */ 3344 /* just verify that callout device is not active */
3351 info->flags |= ASYNC_NORMAL_ACTIVE; 3345 info->port.flags |= ASYNC_NORMAL_ACTIVE;
3352 return 0; 3346 return 0;
3353 } 3347 }
3354 3348
@@ -3357,25 +3351,25 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3357 3351
3358 /* Wait for carrier detect and the line to become 3352 /* Wait for carrier detect and the line to become
3359 * free (i.e., not in use by the callout). While we are in 3353 * free (i.e., not in use by the callout). While we are in
3360 * this loop, info->count is dropped by one, so that 3354 * this loop, info->port.count is dropped by one, so that
3361 * close() knows when to free things. We restore it upon 3355 * close() knows when to free things. We restore it upon
3362 * exit, either normal or abnormal. 3356 * exit, either normal or abnormal.
3363 */ 3357 */
3364 3358
3365 retval = 0; 3359 retval = 0;
3366 add_wait_queue(&info->open_wait, &wait); 3360 add_wait_queue(&info->port.open_wait, &wait);
3367 3361
3368 if (debug_level >= DEBUG_LEVEL_INFO) 3362 if (debug_level >= DEBUG_LEVEL_INFO)
3369 printk("%s(%d):%s block_til_ready() before block, count=%d\n", 3363 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
3370 __FILE__,__LINE__, tty->driver->name, info->count ); 3364 __FILE__,__LINE__, tty->driver->name, info->port.count );
3371 3365
3372 spin_lock_irqsave(&info->lock, flags); 3366 spin_lock_irqsave(&info->lock, flags);
3373 if (!tty_hung_up_p(filp)) { 3367 if (!tty_hung_up_p(filp)) {
3374 extra_count = true; 3368 extra_count = true;
3375 info->count--; 3369 info->port.count--;
3376 } 3370 }
3377 spin_unlock_irqrestore(&info->lock, flags); 3371 spin_unlock_irqrestore(&info->lock, flags);
3378 info->blocked_open++; 3372 info->port.blocked_open++;
3379 3373
3380 while (1) { 3374 while (1) {
3381 if ((tty->termios->c_cflag & CBAUD)) { 3375 if ((tty->termios->c_cflag & CBAUD)) {
@@ -3387,8 +3381,8 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3387 3381
3388 set_current_state(TASK_INTERRUPTIBLE); 3382 set_current_state(TASK_INTERRUPTIBLE);
3389 3383
3390 if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)){ 3384 if (tty_hung_up_p(filp) || !(info->port.flags & ASYNC_INITIALIZED)){
3391 retval = (info->flags & ASYNC_HUP_NOTIFY) ? 3385 retval = (info->port.flags & ASYNC_HUP_NOTIFY) ?
3392 -EAGAIN : -ERESTARTSYS; 3386 -EAGAIN : -ERESTARTSYS;
3393 break; 3387 break;
3394 } 3388 }
@@ -3397,7 +3391,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3397 get_signals(info); 3391 get_signals(info);
3398 spin_unlock_irqrestore(&info->lock,flags); 3392 spin_unlock_irqrestore(&info->lock,flags);
3399 3393
3400 if (!(info->flags & ASYNC_CLOSING) && 3394 if (!(info->port.flags & ASYNC_CLOSING) &&
3401 (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) { 3395 (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) {
3402 break; 3396 break;
3403 } 3397 }
@@ -3409,24 +3403,24 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3409 3403
3410 if (debug_level >= DEBUG_LEVEL_INFO) 3404 if (debug_level >= DEBUG_LEVEL_INFO)
3411 printk("%s(%d):%s block_til_ready() count=%d\n", 3405 printk("%s(%d):%s block_til_ready() count=%d\n",
3412 __FILE__,__LINE__, tty->driver->name, info->count ); 3406 __FILE__,__LINE__, tty->driver->name, info->port.count );
3413 3407
3414 schedule(); 3408 schedule();
3415 } 3409 }
3416 3410
3417 set_current_state(TASK_RUNNING); 3411 set_current_state(TASK_RUNNING);
3418 remove_wait_queue(&info->open_wait, &wait); 3412 remove_wait_queue(&info->port.open_wait, &wait);
3419 3413
3420 if (extra_count) 3414 if (extra_count)
3421 info->count++; 3415 info->port.count++;
3422 info->blocked_open--; 3416 info->port.blocked_open--;
3423 3417
3424 if (debug_level >= DEBUG_LEVEL_INFO) 3418 if (debug_level >= DEBUG_LEVEL_INFO)
3425 printk("%s(%d):%s block_til_ready() after, count=%d\n", 3419 printk("%s(%d):%s block_til_ready() after, count=%d\n",
3426 __FILE__,__LINE__, tty->driver->name, info->count ); 3420 __FILE__,__LINE__, tty->driver->name, info->port.count );
3427 3421
3428 if (!retval) 3422 if (!retval)
3429 info->flags |= ASYNC_NORMAL_ACTIVE; 3423 info->port.flags |= ASYNC_NORMAL_ACTIVE;
3430 3424
3431 return retval; 3425 return retval;
3432} 3426}
@@ -3813,8 +3807,7 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev)
3813 info->max_frame_size = 4096; 3807 info->max_frame_size = 4096;
3814 info->close_delay = 5*HZ/10; 3808 info->close_delay = 5*HZ/10;
3815 info->closing_wait = 30*HZ; 3809 info->closing_wait = 30*HZ;
3816 init_waitqueue_head(&info->open_wait); 3810 tty_port_init(&info->port);
3817 init_waitqueue_head(&info->close_wait);
3818 init_waitqueue_head(&info->status_event_wait_q); 3811 init_waitqueue_head(&info->status_event_wait_q);
3819 init_waitqueue_head(&info->event_wait_q); 3812 init_waitqueue_head(&info->event_wait_q);
3820 spin_lock_init(&info->netlock); 3813 spin_lock_init(&info->netlock);
@@ -4885,7 +4878,7 @@ static bool rx_get_frame(SLMP_INFO *info)
4885 unsigned int framesize = 0; 4878 unsigned int framesize = 0;
4886 bool ReturnCode = false; 4879 bool ReturnCode = false;
4887 unsigned long flags; 4880 unsigned long flags;
4888 struct tty_struct *tty = info->tty; 4881 struct tty_struct *tty = info->port.tty;
4889 unsigned char addr_field = 0xff; 4882 unsigned char addr_field = 0xff;
4890 SCADESC *desc; 4883 SCADESC *desc;
4891 SCADESC_EX *desc_ex; 4884 SCADESC_EX *desc_ex;
@@ -5293,11 +5286,11 @@ static bool loopback_test(SLMP_INFO *info)
5293 bool rc = false; 5286 bool rc = false;
5294 unsigned long flags; 5287 unsigned long flags;
5295 5288
5296 struct tty_struct *oldtty = info->tty; 5289 struct tty_struct *oldtty = info->port.tty;
5297 u32 speed = info->params.clock_speed; 5290 u32 speed = info->params.clock_speed;
5298 5291
5299 info->params.clock_speed = 3686400; 5292 info->params.clock_speed = 3686400;
5300 info->tty = NULL; 5293 info->port.tty = NULL;
5301 5294
5302 /* assume failure */ 5295 /* assume failure */
5303 info->init_error = DiagStatus_DmaFailure; 5296 info->init_error = DiagStatus_DmaFailure;
@@ -5341,7 +5334,7 @@ static bool loopback_test(SLMP_INFO *info)
5341 spin_unlock_irqrestore(&info->lock,flags); 5334 spin_unlock_irqrestore(&info->lock,flags);
5342 5335
5343 info->params.clock_speed = speed; 5336 info->params.clock_speed = speed;
5344 info->tty = oldtty; 5337 info->port.tty = oldtty;
5345 5338
5346 return rc; 5339 return rc;
5347} 5340}