aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/synclink.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/synclink.c')
-rw-r--r--drivers/char/synclink.c246
1 files changed, 117 insertions, 129 deletions
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index ac5080df2565..527d220aa4aa 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -180,19 +180,14 @@ 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;
188 unsigned short closing_wait; /* time to wait before closing */
189 186
190 struct mgsl_icount icount; 187 struct mgsl_icount icount;
191 188
192 struct tty_struct *tty;
193 int timeout; 189 int timeout;
194 int x_char; /* xon/xoff character */ 190 int x_char; /* xon/xoff character */
195 int blocked_open; /* # of blocked opens */
196 u16 read_status_mask; 191 u16 read_status_mask;
197 u16 ignore_status_mask; 192 u16 ignore_status_mask;
198 unsigned char *xmit_buf; 193 unsigned char *xmit_buf;
@@ -200,9 +195,6 @@ struct mgsl_struct {
200 int xmit_tail; 195 int xmit_tail;
201 int xmit_cnt; 196 int xmit_cnt;
202 197
203 wait_queue_head_t open_wait;
204 wait_queue_head_t close_wait;
205
206 wait_queue_head_t status_event_wait_q; 198 wait_queue_head_t status_event_wait_q;
207 wait_queue_head_t event_wait_q; 199 wait_queue_head_t event_wait_q;
208 struct timer_list tx_timer; /* HDLC transmit timeout timer */ 200 struct timer_list tx_timer; /* HDLC transmit timeout timer */
@@ -975,8 +967,8 @@ static void ldisc_receive_buf(struct tty_struct *tty,
975 return; 967 return;
976 ld = tty_ldisc_ref(tty); 968 ld = tty_ldisc_ref(tty);
977 if (ld) { 969 if (ld) {
978 if (ld->receive_buf) 970 if (ld->ops->receive_buf)
979 ld->receive_buf(tty, data, flags, count); 971 ld->ops->receive_buf(tty, data, flags, count);
980 tty_ldisc_deref(ld); 972 tty_ldisc_deref(ld);
981 } 973 }
982} 974}
@@ -1134,7 +1126,7 @@ static void mgsl_bh_receive(struct mgsl_struct *info)
1134 1126
1135static void mgsl_bh_transmit(struct mgsl_struct *info) 1127static void mgsl_bh_transmit(struct mgsl_struct *info)
1136{ 1128{
1137 struct tty_struct *tty = info->tty; 1129 struct tty_struct *tty = info->port.tty;
1138 unsigned long flags; 1130 unsigned long flags;
1139 1131
1140 if ( debug_level >= DEBUG_LEVEL_BH ) 1132 if ( debug_level >= DEBUG_LEVEL_BH )
@@ -1276,7 +1268,7 @@ static void mgsl_isr_transmit_status( struct mgsl_struct *info )
1276 else 1268 else
1277#endif 1269#endif
1278 { 1270 {
1279 if (info->tty->stopped || info->tty->hw_stopped) { 1271 if (info->port.tty->stopped || info->port.tty->hw_stopped) {
1280 usc_stop_transmitter(info); 1272 usc_stop_transmitter(info);
1281 return; 1273 return;
1282 } 1274 }
@@ -1357,29 +1349,29 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )
1357 wake_up_interruptible(&info->status_event_wait_q); 1349 wake_up_interruptible(&info->status_event_wait_q);
1358 wake_up_interruptible(&info->event_wait_q); 1350 wake_up_interruptible(&info->event_wait_q);
1359 1351
1360 if ( (info->flags & ASYNC_CHECK_CD) && 1352 if ( (info->port.flags & ASYNC_CHECK_CD) &&
1361 (status & MISCSTATUS_DCD_LATCHED) ) { 1353 (status & MISCSTATUS_DCD_LATCHED) ) {
1362 if ( debug_level >= DEBUG_LEVEL_ISR ) 1354 if ( debug_level >= DEBUG_LEVEL_ISR )
1363 printk("%s CD now %s...", info->device_name, 1355 printk("%s CD now %s...", info->device_name,
1364 (status & MISCSTATUS_DCD) ? "on" : "off"); 1356 (status & MISCSTATUS_DCD) ? "on" : "off");
1365 if (status & MISCSTATUS_DCD) 1357 if (status & MISCSTATUS_DCD)
1366 wake_up_interruptible(&info->open_wait); 1358 wake_up_interruptible(&info->port.open_wait);
1367 else { 1359 else {
1368 if ( debug_level >= DEBUG_LEVEL_ISR ) 1360 if ( debug_level >= DEBUG_LEVEL_ISR )
1369 printk("doing serial hangup..."); 1361 printk("doing serial hangup...");
1370 if (info->tty) 1362 if (info->port.tty)
1371 tty_hangup(info->tty); 1363 tty_hangup(info->port.tty);
1372 } 1364 }
1373 } 1365 }
1374 1366
1375 if ( (info->flags & ASYNC_CTS_FLOW) && 1367 if ( (info->port.flags & ASYNC_CTS_FLOW) &&
1376 (status & MISCSTATUS_CTS_LATCHED) ) { 1368 (status & MISCSTATUS_CTS_LATCHED) ) {
1377 if (info->tty->hw_stopped) { 1369 if (info->port.tty->hw_stopped) {
1378 if (status & MISCSTATUS_CTS) { 1370 if (status & MISCSTATUS_CTS) {
1379 if ( debug_level >= DEBUG_LEVEL_ISR ) 1371 if ( debug_level >= DEBUG_LEVEL_ISR )
1380 printk("CTS tx start..."); 1372 printk("CTS tx start...");
1381 if (info->tty) 1373 if (info->port.tty)
1382 info->tty->hw_stopped = 0; 1374 info->port.tty->hw_stopped = 0;
1383 usc_start_transmitter(info); 1375 usc_start_transmitter(info);
1384 info->pending_bh |= BH_TRANSMIT; 1376 info->pending_bh |= BH_TRANSMIT;
1385 return; 1377 return;
@@ -1388,8 +1380,8 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )
1388 if (!(status & MISCSTATUS_CTS)) { 1380 if (!(status & MISCSTATUS_CTS)) {
1389 if ( debug_level >= DEBUG_LEVEL_ISR ) 1381 if ( debug_level >= DEBUG_LEVEL_ISR )
1390 printk("CTS tx stop..."); 1382 printk("CTS tx stop...");
1391 if (info->tty) 1383 if (info->port.tty)
1392 info->tty->hw_stopped = 1; 1384 info->port.tty->hw_stopped = 1;
1393 usc_stop_transmitter(info); 1385 usc_stop_transmitter(info);
1394 } 1386 }
1395 } 1387 }
@@ -1423,7 +1415,7 @@ static void mgsl_isr_transmit_data( struct mgsl_struct *info )
1423 1415
1424 usc_ClearIrqPendingBits( info, TRANSMIT_DATA ); 1416 usc_ClearIrqPendingBits( info, TRANSMIT_DATA );
1425 1417
1426 if (info->tty->stopped || info->tty->hw_stopped) { 1418 if (info->port.tty->stopped || info->port.tty->hw_stopped) {
1427 usc_stop_transmitter(info); 1419 usc_stop_transmitter(info);
1428 return; 1420 return;
1429 } 1421 }
@@ -1453,7 +1445,7 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info )
1453 u16 status; 1445 u16 status;
1454 int work = 0; 1446 int work = 0;
1455 unsigned char DataByte; 1447 unsigned char DataByte;
1456 struct tty_struct *tty = info->tty; 1448 struct tty_struct *tty = info->port.tty;
1457 struct mgsl_icount *icount = &info->icount; 1449 struct mgsl_icount *icount = &info->icount;
1458 1450
1459 if ( debug_level >= DEBUG_LEVEL_ISR ) 1451 if ( debug_level >= DEBUG_LEVEL_ISR )
@@ -1514,7 +1506,7 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info )
1514 1506
1515 if (status & RXSTATUS_BREAK_RECEIVED) { 1507 if (status & RXSTATUS_BREAK_RECEIVED) {
1516 flag = TTY_BREAK; 1508 flag = TTY_BREAK;
1517 if (info->flags & ASYNC_SAK) 1509 if (info->port.flags & ASYNC_SAK)
1518 do_SAK(tty); 1510 do_SAK(tty);
1519 } else if (status & RXSTATUS_PARITY_ERROR) 1511 } else if (status & RXSTATUS_PARITY_ERROR)
1520 flag = TTY_PARITY; 1512 flag = TTY_PARITY;
@@ -1771,7 +1763,7 @@ static int startup(struct mgsl_struct * info)
1771 if ( debug_level >= DEBUG_LEVEL_INFO ) 1763 if ( debug_level >= DEBUG_LEVEL_INFO )
1772 printk("%s(%d):mgsl_startup(%s)\n",__FILE__,__LINE__,info->device_name); 1764 printk("%s(%d):mgsl_startup(%s)\n",__FILE__,__LINE__,info->device_name);
1773 1765
1774 if (info->flags & ASYNC_INITIALIZED) 1766 if (info->port.flags & ASYNC_INITIALIZED)
1775 return 0; 1767 return 0;
1776 1768
1777 if (!info->xmit_buf) { 1769 if (!info->xmit_buf) {
@@ -1798,8 +1790,8 @@ static int startup(struct mgsl_struct * info)
1798 retval = mgsl_adapter_test(info); 1790 retval = mgsl_adapter_test(info);
1799 1791
1800 if ( retval ) { 1792 if ( retval ) {
1801 if (capable(CAP_SYS_ADMIN) && info->tty) 1793 if (capable(CAP_SYS_ADMIN) && info->port.tty)
1802 set_bit(TTY_IO_ERROR, &info->tty->flags); 1794 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
1803 mgsl_release_resources(info); 1795 mgsl_release_resources(info);
1804 return retval; 1796 return retval;
1805 } 1797 }
@@ -1807,10 +1799,10 @@ static int startup(struct mgsl_struct * info)
1807 /* program hardware for current parameters */ 1799 /* program hardware for current parameters */
1808 mgsl_change_params(info); 1800 mgsl_change_params(info);
1809 1801
1810 if (info->tty) 1802 if (info->port.tty)
1811 clear_bit(TTY_IO_ERROR, &info->tty->flags); 1803 clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
1812 1804
1813 info->flags |= ASYNC_INITIALIZED; 1805 info->port.flags |= ASYNC_INITIALIZED;
1814 1806
1815 return 0; 1807 return 0;
1816 1808
@@ -1827,7 +1819,7 @@ static void shutdown(struct mgsl_struct * info)
1827{ 1819{
1828 unsigned long flags; 1820 unsigned long flags;
1829 1821
1830 if (!(info->flags & ASYNC_INITIALIZED)) 1822 if (!(info->port.flags & ASYNC_INITIALIZED))
1831 return; 1823 return;
1832 1824
1833 if (debug_level >= DEBUG_LEVEL_INFO) 1825 if (debug_level >= DEBUG_LEVEL_INFO)
@@ -1864,7 +1856,7 @@ static void shutdown(struct mgsl_struct * info)
1864 /* on the ISA adapter. This has no effect for the PCI adapter */ 1856 /* on the ISA adapter. This has no effect for the PCI adapter */
1865 usc_OutReg(info, PCR, (u16)((usc_InReg(info, PCR) | BIT13) | BIT12)); 1857 usc_OutReg(info, PCR, (u16)((usc_InReg(info, PCR) | BIT13) | BIT12));
1866 1858
1867 if (!info->tty || info->tty->termios->c_cflag & HUPCL) { 1859 if (!info->port.tty || info->port.tty->termios->c_cflag & HUPCL) {
1868 info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); 1860 info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS);
1869 usc_set_serial_signals(info); 1861 usc_set_serial_signals(info);
1870 } 1862 }
@@ -1873,10 +1865,10 @@ static void shutdown(struct mgsl_struct * info)
1873 1865
1874 mgsl_release_resources(info); 1866 mgsl_release_resources(info);
1875 1867
1876 if (info->tty) 1868 if (info->port.tty)
1877 set_bit(TTY_IO_ERROR, &info->tty->flags); 1869 set_bit(TTY_IO_ERROR, &info->port.tty->flags);
1878 1870
1879 info->flags &= ~ASYNC_INITIALIZED; 1871 info->port.flags &= ~ASYNC_INITIALIZED;
1880 1872
1881} /* end of shutdown() */ 1873} /* end of shutdown() */
1882 1874
@@ -1908,7 +1900,7 @@ static void mgsl_program_hw(struct mgsl_struct *info)
1908 usc_EnableInterrupts(info, IO_PIN); 1900 usc_EnableInterrupts(info, IO_PIN);
1909 usc_get_serial_signals(info); 1901 usc_get_serial_signals(info);
1910 1902
1911 if (info->netcount || info->tty->termios->c_cflag & CREAD) 1903 if (info->netcount || info->port.tty->termios->c_cflag & CREAD)
1912 usc_start_receiver(info); 1904 usc_start_receiver(info);
1913 1905
1914 spin_unlock_irqrestore(&info->irq_spinlock,flags); 1906 spin_unlock_irqrestore(&info->irq_spinlock,flags);
@@ -1921,14 +1913,14 @@ static void mgsl_change_params(struct mgsl_struct *info)
1921 unsigned cflag; 1913 unsigned cflag;
1922 int bits_per_char; 1914 int bits_per_char;
1923 1915
1924 if (!info->tty || !info->tty->termios) 1916 if (!info->port.tty || !info->port.tty->termios)
1925 return; 1917 return;
1926 1918
1927 if (debug_level >= DEBUG_LEVEL_INFO) 1919 if (debug_level >= DEBUG_LEVEL_INFO)
1928 printk("%s(%d):mgsl_change_params(%s)\n", 1920 printk("%s(%d):mgsl_change_params(%s)\n",
1929 __FILE__,__LINE__, info->device_name ); 1921 __FILE__,__LINE__, info->device_name );
1930 1922
1931 cflag = info->tty->termios->c_cflag; 1923 cflag = info->port.tty->termios->c_cflag;
1932 1924
1933 /* if B0 rate (hangup) specified then negate DTR and RTS */ 1925 /* if B0 rate (hangup) specified then negate DTR and RTS */
1934 /* otherwise assert DTR and RTS */ 1926 /* otherwise assert DTR and RTS */
@@ -1976,7 +1968,7 @@ static void mgsl_change_params(struct mgsl_struct *info)
1976 * current data rate. 1968 * current data rate.
1977 */ 1969 */
1978 if (info->params.data_rate <= 460800) 1970 if (info->params.data_rate <= 460800)
1979 info->params.data_rate = tty_get_baud_rate(info->tty); 1971 info->params.data_rate = tty_get_baud_rate(info->port.tty);
1980 1972
1981 if ( info->params.data_rate ) { 1973 if ( info->params.data_rate ) {
1982 info->timeout = (32*HZ*bits_per_char) / 1974 info->timeout = (32*HZ*bits_per_char) /
@@ -1985,31 +1977,31 @@ static void mgsl_change_params(struct mgsl_struct *info)
1985 info->timeout += HZ/50; /* Add .02 seconds of slop */ 1977 info->timeout += HZ/50; /* Add .02 seconds of slop */
1986 1978
1987 if (cflag & CRTSCTS) 1979 if (cflag & CRTSCTS)
1988 info->flags |= ASYNC_CTS_FLOW; 1980 info->port.flags |= ASYNC_CTS_FLOW;
1989 else 1981 else
1990 info->flags &= ~ASYNC_CTS_FLOW; 1982 info->port.flags &= ~ASYNC_CTS_FLOW;
1991 1983
1992 if (cflag & CLOCAL) 1984 if (cflag & CLOCAL)
1993 info->flags &= ~ASYNC_CHECK_CD; 1985 info->port.flags &= ~ASYNC_CHECK_CD;
1994 else 1986 else
1995 info->flags |= ASYNC_CHECK_CD; 1987 info->port.flags |= ASYNC_CHECK_CD;
1996 1988
1997 /* process tty input control flags */ 1989 /* process tty input control flags */
1998 1990
1999 info->read_status_mask = RXSTATUS_OVERRUN; 1991 info->read_status_mask = RXSTATUS_OVERRUN;
2000 if (I_INPCK(info->tty)) 1992 if (I_INPCK(info->port.tty))
2001 info->read_status_mask |= RXSTATUS_PARITY_ERROR | RXSTATUS_FRAMING_ERROR; 1993 info->read_status_mask |= RXSTATUS_PARITY_ERROR | RXSTATUS_FRAMING_ERROR;
2002 if (I_BRKINT(info->tty) || I_PARMRK(info->tty)) 1994 if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
2003 info->read_status_mask |= RXSTATUS_BREAK_RECEIVED; 1995 info->read_status_mask |= RXSTATUS_BREAK_RECEIVED;
2004 1996
2005 if (I_IGNPAR(info->tty)) 1997 if (I_IGNPAR(info->port.tty))
2006 info->ignore_status_mask |= RXSTATUS_PARITY_ERROR | RXSTATUS_FRAMING_ERROR; 1998 info->ignore_status_mask |= RXSTATUS_PARITY_ERROR | RXSTATUS_FRAMING_ERROR;
2007 if (I_IGNBRK(info->tty)) { 1999 if (I_IGNBRK(info->port.tty)) {
2008 info->ignore_status_mask |= RXSTATUS_BREAK_RECEIVED; 2000 info->ignore_status_mask |= RXSTATUS_BREAK_RECEIVED;
2009 /* If ignoring parity and break indicators, ignore 2001 /* If ignoring parity and break indicators, ignore
2010 * overruns too. (For real raw support). 2002 * overruns too. (For real raw support).
2011 */ 2003 */
2012 if (I_IGNPAR(info->tty)) 2004 if (I_IGNPAR(info->port.tty))
2013 info->ignore_status_mask |= RXSTATUS_OVERRUN; 2005 info->ignore_status_mask |= RXSTATUS_OVERRUN;
2014 } 2006 }
2015 2007
@@ -3113,32 +3105,32 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
3113 3105
3114 if (debug_level >= DEBUG_LEVEL_INFO) 3106 if (debug_level >= DEBUG_LEVEL_INFO)
3115 printk("%s(%d):mgsl_close(%s) entry, count=%d\n", 3107 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
3116 __FILE__,__LINE__, info->device_name, info->count); 3108 __FILE__,__LINE__, info->device_name, info->port.count);
3117 3109
3118 if (!info->count) 3110 if (!info->port.count)
3119 return; 3111 return;
3120 3112
3121 if (tty_hung_up_p(filp)) 3113 if (tty_hung_up_p(filp))
3122 goto cleanup; 3114 goto cleanup;
3123 3115
3124 if ((tty->count == 1) && (info->count != 1)) { 3116 if ((tty->count == 1) && (info->port.count != 1)) {
3125 /* 3117 /*
3126 * tty->count is 1 and the tty structure will be freed. 3118 * tty->count is 1 and the tty structure will be freed.
3127 * info->count should be one in this case. 3119 * info->port.count should be one in this case.
3128 * if it's not, correct it so that the port is shutdown. 3120 * if it's not, correct it so that the port is shutdown.
3129 */ 3121 */
3130 printk("mgsl_close: bad refcount; tty->count is 1, " 3122 printk("mgsl_close: bad refcount; tty->count is 1, "
3131 "info->count is %d\n", info->count); 3123 "info->port.count is %d\n", info->port.count);
3132 info->count = 1; 3124 info->port.count = 1;
3133 } 3125 }
3134 3126
3135 info->count--; 3127 info->port.count--;
3136 3128
3137 /* if at least one open remaining, leave hardware active */ 3129 /* if at least one open remaining, leave hardware active */
3138 if (info->count) 3130 if (info->port.count)
3139 goto cleanup; 3131 goto cleanup;
3140 3132
3141 info->flags |= ASYNC_CLOSING; 3133 info->port.flags |= ASYNC_CLOSING;
3142 3134
3143 /* set tty->closing to notify line discipline to 3135 /* set tty->closing to notify line discipline to
3144 * only process XON/XOFF characters. Only the N_TTY 3136 * only process XON/XOFF characters. Only the N_TTY
@@ -3148,14 +3140,14 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
3148 3140
3149 /* wait for transmit data to clear all layers */ 3141 /* wait for transmit data to clear all layers */
3150 3142
3151 if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) { 3143 if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) {
3152 if (debug_level >= DEBUG_LEVEL_INFO) 3144 if (debug_level >= DEBUG_LEVEL_INFO)
3153 printk("%s(%d):mgsl_close(%s) calling tty_wait_until_sent\n", 3145 printk("%s(%d):mgsl_close(%s) calling tty_wait_until_sent\n",
3154 __FILE__,__LINE__, info->device_name ); 3146 __FILE__,__LINE__, info->device_name );
3155 tty_wait_until_sent(tty, info->closing_wait); 3147 tty_wait_until_sent(tty, info->port.closing_wait);
3156 } 3148 }
3157 3149
3158 if (info->flags & ASYNC_INITIALIZED) 3150 if (info->port.flags & ASYNC_INITIALIZED)
3159 mgsl_wait_until_sent(tty, info->timeout); 3151 mgsl_wait_until_sent(tty, info->timeout);
3160 3152
3161 mgsl_flush_buffer(tty); 3153 mgsl_flush_buffer(tty);
@@ -3165,23 +3157,23 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
3165 shutdown(info); 3157 shutdown(info);
3166 3158
3167 tty->closing = 0; 3159 tty->closing = 0;
3168 info->tty = NULL; 3160 info->port.tty = NULL;
3169 3161
3170 if (info->blocked_open) { 3162 if (info->port.blocked_open) {
3171 if (info->close_delay) { 3163 if (info->port.close_delay) {
3172 msleep_interruptible(jiffies_to_msecs(info->close_delay)); 3164 msleep_interruptible(jiffies_to_msecs(info->port.close_delay));
3173 } 3165 }
3174 wake_up_interruptible(&info->open_wait); 3166 wake_up_interruptible(&info->port.open_wait);
3175 } 3167 }
3176 3168
3177 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 3169 info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
3178 3170
3179 wake_up_interruptible(&info->close_wait); 3171 wake_up_interruptible(&info->port.close_wait);
3180 3172
3181cleanup: 3173cleanup:
3182 if (debug_level >= DEBUG_LEVEL_INFO) 3174 if (debug_level >= DEBUG_LEVEL_INFO)
3183 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__, 3175 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
3184 tty->driver->name, info->count); 3176 tty->driver->name, info->port.count);
3185 3177
3186} /* end of mgsl_close() */ 3178} /* end of mgsl_close() */
3187 3179
@@ -3211,7 +3203,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")) 3203 if (mgsl_paranoia_check(info, tty->name, "mgsl_wait_until_sent"))
3212 return; 3204 return;
3213 3205
3214 if (!(info->flags & ASYNC_INITIALIZED)) 3206 if (!(info->port.flags & ASYNC_INITIALIZED))
3215 goto exit; 3207 goto exit;
3216 3208
3217 orig_jiffies = jiffies; 3209 orig_jiffies = jiffies;
@@ -3283,11 +3275,11 @@ static void mgsl_hangup(struct tty_struct *tty)
3283 mgsl_flush_buffer(tty); 3275 mgsl_flush_buffer(tty);
3284 shutdown(info); 3276 shutdown(info);
3285 3277
3286 info->count = 0; 3278 info->port.count = 0;
3287 info->flags &= ~ASYNC_NORMAL_ACTIVE; 3279 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
3288 info->tty = NULL; 3280 info->port.tty = NULL;
3289 3281
3290 wake_up_interruptible(&info->open_wait); 3282 wake_up_interruptible(&info->port.open_wait);
3291 3283
3292} /* end of mgsl_hangup() */ 3284} /* end of mgsl_hangup() */
3293 3285
@@ -3319,7 +3311,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
3319 3311
3320 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ 3312 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){
3321 /* nonblock mode is set or port is not enabled */ 3313 /* nonblock mode is set or port is not enabled */
3322 info->flags |= ASYNC_NORMAL_ACTIVE; 3314 info->port.flags |= ASYNC_NORMAL_ACTIVE;
3323 return 0; 3315 return 0;
3324 } 3316 }
3325 3317
@@ -3328,25 +3320,25 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
3328 3320
3329 /* Wait for carrier detect and the line to become 3321 /* Wait for carrier detect and the line to become
3330 * free (i.e., not in use by the callout). While we are in 3322 * free (i.e., not in use by the callout). While we are in
3331 * this loop, info->count is dropped by one, so that 3323 * this loop, info->port.count is dropped by one, so that
3332 * mgsl_close() knows when to free things. We restore it upon 3324 * mgsl_close() knows when to free things. We restore it upon
3333 * exit, either normal or abnormal. 3325 * exit, either normal or abnormal.
3334 */ 3326 */
3335 3327
3336 retval = 0; 3328 retval = 0;
3337 add_wait_queue(&info->open_wait, &wait); 3329 add_wait_queue(&info->port.open_wait, &wait);
3338 3330
3339 if (debug_level >= DEBUG_LEVEL_INFO) 3331 if (debug_level >= DEBUG_LEVEL_INFO)
3340 printk("%s(%d):block_til_ready before block on %s count=%d\n", 3332 printk("%s(%d):block_til_ready before block on %s count=%d\n",
3341 __FILE__,__LINE__, tty->driver->name, info->count ); 3333 __FILE__,__LINE__, tty->driver->name, info->port.count );
3342 3334
3343 spin_lock_irqsave(&info->irq_spinlock, flags); 3335 spin_lock_irqsave(&info->irq_spinlock, flags);
3344 if (!tty_hung_up_p(filp)) { 3336 if (!tty_hung_up_p(filp)) {
3345 extra_count = true; 3337 extra_count = true;
3346 info->count--; 3338 info->port.count--;
3347 } 3339 }
3348 spin_unlock_irqrestore(&info->irq_spinlock, flags); 3340 spin_unlock_irqrestore(&info->irq_spinlock, flags);
3349 info->blocked_open++; 3341 info->port.blocked_open++;
3350 3342
3351 while (1) { 3343 while (1) {
3352 if (tty->termios->c_cflag & CBAUD) { 3344 if (tty->termios->c_cflag & CBAUD) {
@@ -3358,8 +3350,8 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
3358 3350
3359 set_current_state(TASK_INTERRUPTIBLE); 3351 set_current_state(TASK_INTERRUPTIBLE);
3360 3352
3361 if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)){ 3353 if (tty_hung_up_p(filp) || !(info->port.flags & ASYNC_INITIALIZED)){
3362 retval = (info->flags & ASYNC_HUP_NOTIFY) ? 3354 retval = (info->port.flags & ASYNC_HUP_NOTIFY) ?
3363 -EAGAIN : -ERESTARTSYS; 3355 -EAGAIN : -ERESTARTSYS;
3364 break; 3356 break;
3365 } 3357 }
@@ -3368,7 +3360,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
3368 usc_get_serial_signals(info); 3360 usc_get_serial_signals(info);
3369 spin_unlock_irqrestore(&info->irq_spinlock,flags); 3361 spin_unlock_irqrestore(&info->irq_spinlock,flags);
3370 3362
3371 if (!(info->flags & ASYNC_CLOSING) && 3363 if (!(info->port.flags & ASYNC_CLOSING) &&
3372 (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) { 3364 (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) {
3373 break; 3365 break;
3374 } 3366 }
@@ -3380,24 +3372,24 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
3380 3372
3381 if (debug_level >= DEBUG_LEVEL_INFO) 3373 if (debug_level >= DEBUG_LEVEL_INFO)
3382 printk("%s(%d):block_til_ready blocking on %s count=%d\n", 3374 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
3383 __FILE__,__LINE__, tty->driver->name, info->count ); 3375 __FILE__,__LINE__, tty->driver->name, info->port.count );
3384 3376
3385 schedule(); 3377 schedule();
3386 } 3378 }
3387 3379
3388 set_current_state(TASK_RUNNING); 3380 set_current_state(TASK_RUNNING);
3389 remove_wait_queue(&info->open_wait, &wait); 3381 remove_wait_queue(&info->port.open_wait, &wait);
3390 3382
3391 if (extra_count) 3383 if (extra_count)
3392 info->count++; 3384 info->port.count++;
3393 info->blocked_open--; 3385 info->port.blocked_open--;
3394 3386
3395 if (debug_level >= DEBUG_LEVEL_INFO) 3387 if (debug_level >= DEBUG_LEVEL_INFO)
3396 printk("%s(%d):block_til_ready after blocking on %s count=%d\n", 3388 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
3397 __FILE__,__LINE__, tty->driver->name, info->count ); 3389 __FILE__,__LINE__, tty->driver->name, info->port.count );
3398 3390
3399 if (!retval) 3391 if (!retval)
3400 info->flags |= ASYNC_NORMAL_ACTIVE; 3392 info->port.flags |= ASYNC_NORMAL_ACTIVE;
3401 3393
3402 return retval; 3394 return retval;
3403 3395
@@ -3435,22 +3427,22 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
3435 return -ENODEV; 3427 return -ENODEV;
3436 3428
3437 tty->driver_data = info; 3429 tty->driver_data = info;
3438 info->tty = tty; 3430 info->port.tty = tty;
3439 3431
3440 if (debug_level >= DEBUG_LEVEL_INFO) 3432 if (debug_level >= DEBUG_LEVEL_INFO)
3441 printk("%s(%d):mgsl_open(%s), old ref count = %d\n", 3433 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
3442 __FILE__,__LINE__,tty->driver->name, info->count); 3434 __FILE__,__LINE__,tty->driver->name, info->port.count);
3443 3435
3444 /* If port is closing, signal caller to try again */ 3436 /* If port is closing, signal caller to try again */
3445 if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){ 3437 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
3446 if (info->flags & ASYNC_CLOSING) 3438 if (info->port.flags & ASYNC_CLOSING)
3447 interruptible_sleep_on(&info->close_wait); 3439 interruptible_sleep_on(&info->port.close_wait);
3448 retval = ((info->flags & ASYNC_HUP_NOTIFY) ? 3440 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
3449 -EAGAIN : -ERESTARTSYS); 3441 -EAGAIN : -ERESTARTSYS);
3450 goto cleanup; 3442 goto cleanup;
3451 } 3443 }
3452 3444
3453 info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 3445 info->port.tty->low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
3454 3446
3455 spin_lock_irqsave(&info->netlock, flags); 3447 spin_lock_irqsave(&info->netlock, flags);
3456 if (info->netcount) { 3448 if (info->netcount) {
@@ -3458,10 +3450,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
3458 spin_unlock_irqrestore(&info->netlock, flags); 3450 spin_unlock_irqrestore(&info->netlock, flags);
3459 goto cleanup; 3451 goto cleanup;
3460 } 3452 }
3461 info->count++; 3453 info->port.count++;
3462 spin_unlock_irqrestore(&info->netlock, flags); 3454 spin_unlock_irqrestore(&info->netlock, flags);
3463 3455
3464 if (info->count == 1) { 3456 if (info->port.count == 1) {
3465 /* 1st open on this device, init hardware */ 3457 /* 1st open on this device, init hardware */
3466 retval = startup(info); 3458 retval = startup(info);
3467 if (retval < 0) 3459 if (retval < 0)
@@ -3484,9 +3476,9 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
3484cleanup: 3476cleanup:
3485 if (retval) { 3477 if (retval) {
3486 if (tty->count == 1) 3478 if (tty->count == 1)
3487 info->tty = NULL; /* tty layer will release tty struct */ 3479 info->port.tty = NULL; /* tty layer will release tty struct */
3488 if(info->count) 3480 if(info->port.count)
3489 info->count--; 3481 info->port.count--;
3490 } 3482 }
3491 3483
3492 return retval; 3484 return retval;
@@ -4332,13 +4324,12 @@ static struct mgsl_struct* mgsl_allocate_device(void)
4332 if (!info) { 4324 if (!info) {
4333 printk("Error can't allocate device instance data\n"); 4325 printk("Error can't allocate device instance data\n");
4334 } else { 4326 } else {
4327 tty_port_init(&info->port);
4335 info->magic = MGSL_MAGIC; 4328 info->magic = MGSL_MAGIC;
4336 INIT_WORK(&info->task, mgsl_bh_handler); 4329 INIT_WORK(&info->task, mgsl_bh_handler);
4337 info->max_frame_size = 4096; 4330 info->max_frame_size = 4096;
4338 info->close_delay = 5*HZ/10; 4331 info->port.close_delay = 5*HZ/10;
4339 info->closing_wait = 30*HZ; 4332 info->port.closing_wait = 30*HZ;
4340 init_waitqueue_head(&info->open_wait);
4341 init_waitqueue_head(&info->close_wait);
4342 init_waitqueue_head(&info->status_event_wait_q); 4333 init_waitqueue_head(&info->status_event_wait_q);
4343 init_waitqueue_head(&info->event_wait_q); 4334 init_waitqueue_head(&info->event_wait_q);
4344 spin_lock_init(&info->irq_spinlock); 4335 spin_lock_init(&info->irq_spinlock);
@@ -6575,7 +6566,7 @@ static bool mgsl_get_rx_frame(struct mgsl_struct *info)
6575 unsigned int framesize = 0; 6566 unsigned int framesize = 0;
6576 bool ReturnCode = false; 6567 bool ReturnCode = false;
6577 unsigned long flags; 6568 unsigned long flags;
6578 struct tty_struct *tty = info->tty; 6569 struct tty_struct *tty = info->port.tty;
6579 bool return_frame = false; 6570 bool return_frame = false;
6580 6571
6581 /* 6572 /*
@@ -6640,9 +6631,8 @@ static bool mgsl_get_rx_frame(struct mgsl_struct *info)
6640 framesize = 0; 6631 framesize = 0;
6641#if SYNCLINK_GENERIC_HDLC 6632#if SYNCLINK_GENERIC_HDLC
6642 { 6633 {
6643 struct net_device_stats *stats = hdlc_stats(info->netdev); 6634 info->netdev->stats.rx_errors++;
6644 stats->rx_errors++; 6635 info->netdev->stats.rx_frame_errors++;
6645 stats->rx_frame_errors++;
6646 } 6636 }
6647#endif 6637#endif
6648 } else 6638 } else
@@ -6774,7 +6764,7 @@ static bool mgsl_get_raw_rx_frame(struct mgsl_struct *info)
6774 unsigned int framesize = 0; 6764 unsigned int framesize = 0;
6775 bool ReturnCode = false; 6765 bool ReturnCode = false;
6776 unsigned long flags; 6766 unsigned long flags;
6777 struct tty_struct *tty = info->tty; 6767 struct tty_struct *tty = info->port.tty;
6778 6768
6779 /* 6769 /*
6780 * current_rx_buffer points to the 1st buffer of the next available 6770 * current_rx_buffer points to the 1st buffer of the next available
@@ -7711,7 +7701,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
7711 unsigned short new_crctype; 7701 unsigned short new_crctype;
7712 7702
7713 /* return error if TTY interface open */ 7703 /* return error if TTY interface open */
7714 if (info->count) 7704 if (info->port.count)
7715 return -EBUSY; 7705 return -EBUSY;
7716 7706
7717 switch (encoding) 7707 switch (encoding)
@@ -7753,7 +7743,6 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
7753static int hdlcdev_xmit(struct sk_buff *skb, struct net_device *dev) 7743static int hdlcdev_xmit(struct sk_buff *skb, struct net_device *dev)
7754{ 7744{
7755 struct mgsl_struct *info = dev_to_port(dev); 7745 struct mgsl_struct *info = dev_to_port(dev);
7756 struct net_device_stats *stats = hdlc_stats(dev);
7757 unsigned long flags; 7746 unsigned long flags;
7758 7747
7759 if (debug_level >= DEBUG_LEVEL_INFO) 7748 if (debug_level >= DEBUG_LEVEL_INFO)
@@ -7767,8 +7756,8 @@ static int hdlcdev_xmit(struct sk_buff *skb, struct net_device *dev)
7767 mgsl_load_tx_dma_buffer(info, skb->data, skb->len); 7756 mgsl_load_tx_dma_buffer(info, skb->data, skb->len);
7768 7757
7769 /* update network statistics */ 7758 /* update network statistics */
7770 stats->tx_packets++; 7759 dev->stats.tx_packets++;
7771 stats->tx_bytes += skb->len; 7760 dev->stats.tx_bytes += skb->len;
7772 7761
7773 /* done with socket buffer, so free it */ 7762 /* done with socket buffer, so free it */
7774 dev_kfree_skb(skb); 7763 dev_kfree_skb(skb);
@@ -7808,7 +7797,7 @@ static int hdlcdev_open(struct net_device *dev)
7808 7797
7809 /* arbitrate between network and tty opens */ 7798 /* arbitrate between network and tty opens */
7810 spin_lock_irqsave(&info->netlock, flags); 7799 spin_lock_irqsave(&info->netlock, flags);
7811 if (info->count != 0 || info->netcount != 0) { 7800 if (info->port.count != 0 || info->netcount != 0) {
7812 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name); 7801 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
7813 spin_unlock_irqrestore(&info->netlock, flags); 7802 spin_unlock_irqrestore(&info->netlock, flags);
7814 return -EBUSY; 7803 return -EBUSY;
@@ -7894,7 +7883,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
7894 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name); 7883 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
7895 7884
7896 /* return error if TTY interface open */ 7885 /* return error if TTY interface open */
7897 if (info->count) 7886 if (info->port.count)
7898 return -EBUSY; 7887 return -EBUSY;
7899 7888
7900 if (cmd != SIOCWANDEV) 7889 if (cmd != SIOCWANDEV)
@@ -7984,14 +7973,13 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
7984static void hdlcdev_tx_timeout(struct net_device *dev) 7973static void hdlcdev_tx_timeout(struct net_device *dev)
7985{ 7974{
7986 struct mgsl_struct *info = dev_to_port(dev); 7975 struct mgsl_struct *info = dev_to_port(dev);
7987 struct net_device_stats *stats = hdlc_stats(dev);
7988 unsigned long flags; 7976 unsigned long flags;
7989 7977
7990 if (debug_level >= DEBUG_LEVEL_INFO) 7978 if (debug_level >= DEBUG_LEVEL_INFO)
7991 printk("hdlcdev_tx_timeout(%s)\n",dev->name); 7979 printk("hdlcdev_tx_timeout(%s)\n",dev->name);
7992 7980
7993 stats->tx_errors++; 7981 dev->stats.tx_errors++;
7994 stats->tx_aborted_errors++; 7982 dev->stats.tx_aborted_errors++;
7995 7983
7996 spin_lock_irqsave(&info->irq_spinlock,flags); 7984 spin_lock_irqsave(&info->irq_spinlock,flags);
7997 usc_stop_transmitter(info); 7985 usc_stop_transmitter(info);
@@ -8024,27 +8012,27 @@ static void hdlcdev_rx(struct mgsl_struct *info, char *buf, int size)
8024{ 8012{
8025 struct sk_buff *skb = dev_alloc_skb(size); 8013 struct sk_buff *skb = dev_alloc_skb(size);
8026 struct net_device *dev = info->netdev; 8014 struct net_device *dev = info->netdev;
8027 struct net_device_stats *stats = hdlc_stats(dev);
8028 8015
8029 if (debug_level >= DEBUG_LEVEL_INFO) 8016 if (debug_level >= DEBUG_LEVEL_INFO)
8030 printk("hdlcdev_rx(%s)\n",dev->name); 8017 printk("hdlcdev_rx(%s)\n", dev->name);
8031 8018
8032 if (skb == NULL) { 8019 if (skb == NULL) {
8033 printk(KERN_NOTICE "%s: can't alloc skb, dropping packet\n", dev->name); 8020 printk(KERN_NOTICE "%s: can't alloc skb, dropping packet\n",
8034 stats->rx_dropped++; 8021 dev->name);
8022 dev->stats.rx_dropped++;
8035 return; 8023 return;
8036 } 8024 }
8037 8025
8038 memcpy(skb_put(skb, size),buf,size); 8026 memcpy(skb_put(skb, size), buf, size);
8039 8027
8040 skb->protocol = hdlc_type_trans(skb, info->netdev); 8028 skb->protocol = hdlc_type_trans(skb, dev);
8041 8029
8042 stats->rx_packets++; 8030 dev->stats.rx_packets++;
8043 stats->rx_bytes += size; 8031 dev->stats.rx_bytes += size;
8044 8032
8045 netif_rx(skb); 8033 netif_rx(skb);
8046 8034
8047 info->netdev->last_rx = jiffies; 8035 dev->last_rx = jiffies;
8048} 8036}
8049 8037
8050/** 8038/**