diff options
Diffstat (limited to 'drivers/char/synclink.c')
-rw-r--r-- | drivers/char/synclink.c | 195 |
1 files changed, 94 insertions, 101 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 | ||
181 | struct mgsl_struct { | 181 | struct 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 | ||
1135 | static void mgsl_bh_transmit(struct mgsl_struct *info) | 1129 | static 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 | ||
3181 | cleanup: | 3175 | cleanup: |
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) | |||
3484 | cleanup: | 3478 | cleanup: |
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) |