diff options
Diffstat (limited to 'drivers/isdn')
-rw-r--r-- | drivers/isdn/i4l/isdn_common.c | 5 | ||||
-rw-r--r-- | drivers/isdn/i4l/isdn_tty.c | 466 |
2 files changed, 179 insertions, 292 deletions
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index d9f5524593fb..8c610fa6782b 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c | |||
@@ -46,7 +46,6 @@ static DEFINE_MUTEX(isdn_mutex); | |||
46 | static char *isdn_revision = "$Revision: 1.1.2.3 $"; | 46 | static char *isdn_revision = "$Revision: 1.1.2.3 $"; |
47 | 47 | ||
48 | extern char *isdn_net_revision; | 48 | extern char *isdn_net_revision; |
49 | extern char *isdn_tty_revision; | ||
50 | #ifdef CONFIG_ISDN_PPP | 49 | #ifdef CONFIG_ISDN_PPP |
51 | extern char *isdn_ppp_revision; | 50 | extern char *isdn_ppp_revision; |
52 | #else | 51 | #else |
@@ -2327,8 +2326,6 @@ static int __init isdn_init(void) | |||
2327 | dev->chanmap[i] = -1; | 2326 | dev->chanmap[i] = -1; |
2328 | dev->m_idx[i] = -1; | 2327 | dev->m_idx[i] = -1; |
2329 | strcpy(dev->num[i], "???"); | 2328 | strcpy(dev->num[i], "???"); |
2330 | init_waitqueue_head(&dev->mdm.info[i].open_wait); | ||
2331 | init_waitqueue_head(&dev->mdm.info[i].close_wait); | ||
2332 | } | 2329 | } |
2333 | if (register_chrdev(ISDN_MAJOR, "isdn", &isdn_fops)) { | 2330 | if (register_chrdev(ISDN_MAJOR, "isdn", &isdn_fops)) { |
2334 | printk(KERN_WARNING "isdn: Could not register control devices\n"); | 2331 | printk(KERN_WARNING "isdn: Could not register control devices\n"); |
@@ -2353,8 +2350,6 @@ static int __init isdn_init(void) | |||
2353 | 2350 | ||
2354 | strcpy(tmprev, isdn_revision); | 2351 | strcpy(tmprev, isdn_revision); |
2355 | printk(KERN_NOTICE "ISDN subsystem Rev: %s/", isdn_getrev(tmprev)); | 2352 | printk(KERN_NOTICE "ISDN subsystem Rev: %s/", isdn_getrev(tmprev)); |
2356 | strcpy(tmprev, isdn_tty_revision); | ||
2357 | printk("%s/", isdn_getrev(tmprev)); | ||
2358 | strcpy(tmprev, isdn_net_revision); | 2353 | strcpy(tmprev, isdn_net_revision); |
2359 | printk("%s/", isdn_getrev(tmprev)); | 2354 | printk("%s/", isdn_getrev(tmprev)); |
2360 | strcpy(tmprev, isdn_ppp_revision); | 2355 | strcpy(tmprev, isdn_ppp_revision); |
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 3831abdbc66f..7bc50670d7d9 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* $Id: isdn_tty.c,v 1.1.2.3 2004/02/10 01:07:13 keil Exp $ | 1 | /* |
2 | * | ||
3 | * Linux ISDN subsystem, tty functions and AT-command emulator (linklevel). | 2 | * Linux ISDN subsystem, tty functions and AT-command emulator (linklevel). |
4 | * | 3 | * |
5 | * Copyright 1994-1999 by Fritz Elfert (fritz@isdn4linux.de) | 4 | * Copyright 1994-1999 by Fritz Elfert (fritz@isdn4linux.de) |
@@ -12,6 +11,7 @@ | |||
12 | #undef ISDN_TTY_STAT_DEBUG | 11 | #undef ISDN_TTY_STAT_DEBUG |
13 | 12 | ||
14 | #include <linux/isdn.h> | 13 | #include <linux/isdn.h> |
14 | #include <linux/serial.h> /* ASYNC_* flags */ | ||
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
17 | #include <linux/mutex.h> | 17 | #include <linux/mutex.h> |
@@ -48,9 +48,6 @@ static int bit2si[8] = | |||
48 | static int si2bit[8] = | 48 | static int si2bit[8] = |
49 | {4, 1, 4, 4, 4, 4, 4, 4}; | 49 | {4, 1, 4, 4, 4, 4, 4, 4}; |
50 | 50 | ||
51 | char *isdn_tty_revision = "$Revision: 1.1.2.3 $"; | ||
52 | |||
53 | |||
54 | /* isdn_tty_try_read() is called from within isdn_tty_rcv_skb() | 51 | /* isdn_tty_try_read() is called from within isdn_tty_rcv_skb() |
55 | * to stuff incoming data directly into a tty's flip-buffer. This | 52 | * to stuff incoming data directly into a tty's flip-buffer. This |
56 | * is done to speed up tty-receiving if the receive-queue is empty. | 53 | * is done to speed up tty-receiving if the receive-queue is empty. |
@@ -68,49 +65,54 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb) | |||
68 | struct tty_struct *tty; | 65 | struct tty_struct *tty; |
69 | char last; | 66 | char last; |
70 | 67 | ||
71 | if (info->online) { | 68 | if (!info->online) |
72 | if ((tty = info->tty)) { | 69 | return 0; |
73 | if (info->mcr & UART_MCR_RTS) { | 70 | |
74 | len = skb->len | 71 | tty = info->port.tty; |
72 | if (!tty) | ||
73 | return 0; | ||
74 | |||
75 | if (!(info->mcr & UART_MCR_RTS)) | ||
76 | return 0; | ||
77 | |||
78 | len = skb->len | ||
75 | #ifdef CONFIG_ISDN_AUDIO | 79 | #ifdef CONFIG_ISDN_AUDIO |
76 | + ISDN_AUDIO_SKB_DLECOUNT(skb) | 80 | + ISDN_AUDIO_SKB_DLECOUNT(skb) |
77 | #endif | 81 | #endif |
78 | ; | 82 | ; |
83 | |||
84 | c = tty_buffer_request_room(tty, len); | ||
85 | if (c < len) | ||
86 | return 0; | ||
79 | 87 | ||
80 | c = tty_buffer_request_room(tty, len); | ||
81 | if (c >= len) { | ||
82 | #ifdef CONFIG_ISDN_AUDIO | ||
83 | if (ISDN_AUDIO_SKB_DLECOUNT(skb)) { | ||
84 | int l = skb->len; | ||
85 | unsigned char *dp = skb->data; | ||
86 | while (--l) { | ||
87 | if (*dp == DLE) | ||
88 | tty_insert_flip_char(tty, DLE, 0); | ||
89 | tty_insert_flip_char(tty, *dp++, 0); | ||
90 | } | ||
91 | if (*dp == DLE) | ||
92 | tty_insert_flip_char(tty, DLE, 0); | ||
93 | last = *dp; | ||
94 | } else { | ||
95 | #endif | ||
96 | if (len > 1) | ||
97 | tty_insert_flip_string(tty, skb->data, len - 1); | ||
98 | last = skb->data[len - 1]; | ||
99 | #ifdef CONFIG_ISDN_AUDIO | 88 | #ifdef CONFIG_ISDN_AUDIO |
100 | } | 89 | if (ISDN_AUDIO_SKB_DLECOUNT(skb)) { |
90 | int l = skb->len; | ||
91 | unsigned char *dp = skb->data; | ||
92 | while (--l) { | ||
93 | if (*dp == DLE) | ||
94 | tty_insert_flip_char(tty, DLE, 0); | ||
95 | tty_insert_flip_char(tty, *dp++, 0); | ||
96 | } | ||
97 | if (*dp == DLE) | ||
98 | tty_insert_flip_char(tty, DLE, 0); | ||
99 | last = *dp; | ||
100 | } else { | ||
101 | #endif | 101 | #endif |
102 | if (info->emu.mdmreg[REG_CPPP] & BIT_CPPP) | 102 | if (len > 1) |
103 | tty_insert_flip_char(tty, last, 0xFF); | 103 | tty_insert_flip_string(tty, skb->data, len - 1); |
104 | else | 104 | last = skb->data[len - 1]; |
105 | tty_insert_flip_char(tty, last, TTY_NORMAL); | 105 | #ifdef CONFIG_ISDN_AUDIO |
106 | tty_flip_buffer_push(tty); | ||
107 | kfree_skb(skb); | ||
108 | return 1; | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | } | 106 | } |
113 | return 0; | 107 | #endif |
108 | if (info->emu.mdmreg[REG_CPPP] & BIT_CPPP) | ||
109 | tty_insert_flip_char(tty, last, 0xFF); | ||
110 | else | ||
111 | tty_insert_flip_char(tty, last, TTY_NORMAL); | ||
112 | tty_flip_buffer_push(tty); | ||
113 | kfree_skb(skb); | ||
114 | |||
115 | return 1; | ||
114 | } | 116 | } |
115 | 117 | ||
116 | /* isdn_tty_readmodem() is called periodically from within timer-interrupt. | 118 | /* isdn_tty_readmodem() is called periodically from within timer-interrupt. |
@@ -128,35 +130,39 @@ isdn_tty_readmodem(void) | |||
128 | modem_info *info; | 130 | modem_info *info; |
129 | 131 | ||
130 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { | 132 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { |
131 | if ((midx = dev->m_idx[i]) >= 0) { | 133 | midx = dev->m_idx[i]; |
132 | info = &dev->mdm.info[midx]; | 134 | if (midx < 0) |
133 | if (info->online) { | 135 | continue; |
134 | r = 0; | 136 | |
137 | info = &dev->mdm.info[midx]; | ||
138 | if (!info->online) | ||
139 | continue; | ||
140 | |||
141 | r = 0; | ||
135 | #ifdef CONFIG_ISDN_AUDIO | 142 | #ifdef CONFIG_ISDN_AUDIO |
136 | isdn_audio_eval_dtmf(info); | 143 | isdn_audio_eval_dtmf(info); |
137 | if ((info->vonline & 1) && (info->emu.vpar[1])) | 144 | if ((info->vonline & 1) && (info->emu.vpar[1])) |
138 | isdn_audio_eval_silence(info); | 145 | isdn_audio_eval_silence(info); |
139 | #endif | 146 | #endif |
140 | if ((tty = info->tty)) { | 147 | tty = info->port.tty; |
141 | if (info->mcr & UART_MCR_RTS) { | 148 | if (tty) { |
142 | /* CISCO AsyncPPP Hack */ | 149 | if (info->mcr & UART_MCR_RTS) { |
143 | if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP)) | 150 | /* CISCO AsyncPPP Hack */ |
144 | r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 0); | 151 | if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP)) |
145 | else | 152 | r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 0); |
146 | r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 1); | 153 | else |
147 | if (r) | 154 | r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 1); |
148 | tty_flip_buffer_push(tty); | 155 | if (r) |
149 | } else | 156 | tty_flip_buffer_push(tty); |
150 | r = 1; | 157 | } else |
151 | } else | 158 | r = 1; |
152 | r = 1; | 159 | } else |
153 | if (r) { | 160 | r = 1; |
154 | info->rcvsched = 0; | 161 | if (r) { |
155 | resched = 1; | 162 | info->rcvsched = 0; |
156 | } else | 163 | resched = 1; |
157 | info->rcvsched = 1; | 164 | } else |
158 | } | 165 | info->rcvsched = 1; |
159 | } | ||
160 | } | 166 | } |
161 | if (!resched) | 167 | if (!resched) |
162 | isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 0); | 168 | isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 0); |
@@ -294,7 +300,7 @@ isdn_tty_tint(modem_info *info) | |||
294 | len = skb->len; | 300 | len = skb->len; |
295 | if ((slen = isdn_writebuf_skb_stub(info->isdn_driver, | 301 | if ((slen = isdn_writebuf_skb_stub(info->isdn_driver, |
296 | info->isdn_channel, 1, skb)) == len) { | 302 | info->isdn_channel, 1, skb)) == len) { |
297 | struct tty_struct *tty = info->tty; | 303 | struct tty_struct *tty = info->port.tty; |
298 | info->send_outstanding++; | 304 | info->send_outstanding++; |
299 | info->msr &= ~UART_MSR_CTS; | 305 | info->msr &= ~UART_MSR_CTS; |
300 | info->lsr &= ~UART_LSR_TEMT; | 306 | info->lsr &= ~UART_LSR_TEMT; |
@@ -327,7 +333,7 @@ isdn_tty_countDLE(unsigned char *buf, int len) | |||
327 | static int | 333 | static int |
328 | isdn_tty_handleDLEdown(modem_info *info, atemu *m, int len) | 334 | isdn_tty_handleDLEdown(modem_info *info, atemu *m, int len) |
329 | { | 335 | { |
330 | unsigned char *p = &info->xmit_buf[info->xmit_count]; | 336 | unsigned char *p = &info->port.xmit_buf[info->xmit_count]; |
331 | int count = 0; | 337 | int count = 0; |
332 | 338 | ||
333 | while (len > 0) { | 339 | while (len > 0) { |
@@ -471,7 +477,7 @@ isdn_tty_senddown(modem_info *info) | |||
471 | return; | 477 | return; |
472 | } | 478 | } |
473 | skb_reserve(skb, skb_res); | 479 | skb_reserve(skb, skb_res); |
474 | memcpy(skb_put(skb, buflen), info->xmit_buf, buflen); | 480 | memcpy(skb_put(skb, buflen), info->port.xmit_buf, buflen); |
475 | info->xmit_count = 0; | 481 | info->xmit_count = 0; |
476 | #ifdef CONFIG_ISDN_AUDIO | 482 | #ifdef CONFIG_ISDN_AUDIO |
477 | if (info->vonline & 2) { | 483 | if (info->vonline & 2) { |
@@ -699,7 +705,7 @@ isdn_tty_modem_hup(modem_info *info, int local) | |||
699 | printk(KERN_DEBUG "Mhup ttyI%d\n", info->line); | 705 | printk(KERN_DEBUG "Mhup ttyI%d\n", info->line); |
700 | #endif | 706 | #endif |
701 | info->rcvsched = 0; | 707 | info->rcvsched = 0; |
702 | isdn_tty_flush_buffer(info->tty); | 708 | isdn_tty_flush_buffer(info->port.tty); |
703 | if (info->online) { | 709 | if (info->online) { |
704 | info->last_lhup = local; | 710 | info->last_lhup = local; |
705 | info->online = 0; | 711 | info->online = 0; |
@@ -997,20 +1003,21 @@ isdn_tty_paranoia_check(modem_info *info, char *name, const char *routine) | |||
997 | static void | 1003 | static void |
998 | isdn_tty_change_speed(modem_info *info) | 1004 | isdn_tty_change_speed(modem_info *info) |
999 | { | 1005 | { |
1006 | struct tty_port *port = &info->port; | ||
1000 | uint cflag, | 1007 | uint cflag, |
1001 | cval, | 1008 | cval, |
1002 | quot; | 1009 | quot; |
1003 | int i; | 1010 | int i; |
1004 | 1011 | ||
1005 | if (!info->tty || !info->tty->termios) | 1012 | if (!port->tty || !port->tty->termios) |
1006 | return; | 1013 | return; |
1007 | cflag = info->tty->termios->c_cflag; | 1014 | cflag = port->tty->termios->c_cflag; |
1008 | 1015 | ||
1009 | quot = i = cflag & CBAUD; | 1016 | quot = i = cflag & CBAUD; |
1010 | if (i & CBAUDEX) { | 1017 | if (i & CBAUDEX) { |
1011 | i &= ~CBAUDEX; | 1018 | i &= ~CBAUDEX; |
1012 | if (i < 1 || i > 2) | 1019 | if (i < 1 || i > 2) |
1013 | info->tty->termios->c_cflag &= ~CBAUDEX; | 1020 | port->tty->termios->c_cflag &= ~CBAUDEX; |
1014 | else | 1021 | else |
1015 | i += 15; | 1022 | i += 15; |
1016 | } | 1023 | } |
@@ -1040,20 +1047,20 @@ isdn_tty_change_speed(modem_info *info) | |||
1040 | 1047 | ||
1041 | /* CTS flow control flag and modem status interrupts */ | 1048 | /* CTS flow control flag and modem status interrupts */ |
1042 | if (cflag & CRTSCTS) { | 1049 | if (cflag & CRTSCTS) { |
1043 | info->flags |= ISDN_ASYNC_CTS_FLOW; | 1050 | port->flags |= ASYNC_CTS_FLOW; |
1044 | } else | 1051 | } else |
1045 | info->flags &= ~ISDN_ASYNC_CTS_FLOW; | 1052 | port->flags &= ~ASYNC_CTS_FLOW; |
1046 | if (cflag & CLOCAL) | 1053 | if (cflag & CLOCAL) |
1047 | info->flags &= ~ISDN_ASYNC_CHECK_CD; | 1054 | port->flags &= ~ASYNC_CHECK_CD; |
1048 | else { | 1055 | else { |
1049 | info->flags |= ISDN_ASYNC_CHECK_CD; | 1056 | port->flags |= ASYNC_CHECK_CD; |
1050 | } | 1057 | } |
1051 | } | 1058 | } |
1052 | 1059 | ||
1053 | static int | 1060 | static int |
1054 | isdn_tty_startup(modem_info *info) | 1061 | isdn_tty_startup(modem_info *info) |
1055 | { | 1062 | { |
1056 | if (info->flags & ISDN_ASYNC_INITIALIZED) | 1063 | if (info->port.flags & ASYNC_INITIALIZED) |
1057 | return 0; | 1064 | return 0; |
1058 | isdn_lock_drivers(); | 1065 | isdn_lock_drivers(); |
1059 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1066 | #ifdef ISDN_DEBUG_MODEM_OPEN |
@@ -1063,14 +1070,14 @@ isdn_tty_startup(modem_info *info) | |||
1063 | * Now, initialize the UART | 1070 | * Now, initialize the UART |
1064 | */ | 1071 | */ |
1065 | info->mcr = UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2; | 1072 | info->mcr = UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2; |
1066 | if (info->tty) | 1073 | if (info->port.tty) |
1067 | clear_bit(TTY_IO_ERROR, &info->tty->flags); | 1074 | clear_bit(TTY_IO_ERROR, &info->port.tty->flags); |
1068 | /* | 1075 | /* |
1069 | * and set the speed of the serial port | 1076 | * and set the speed of the serial port |
1070 | */ | 1077 | */ |
1071 | isdn_tty_change_speed(info); | 1078 | isdn_tty_change_speed(info); |
1072 | 1079 | ||
1073 | info->flags |= ISDN_ASYNC_INITIALIZED; | 1080 | info->port.flags |= ASYNC_INITIALIZED; |
1074 | info->msr |= (UART_MSR_DSR | UART_MSR_CTS); | 1081 | info->msr |= (UART_MSR_DSR | UART_MSR_CTS); |
1075 | info->send_outstanding = 0; | 1082 | info->send_outstanding = 0; |
1076 | return 0; | 1083 | return 0; |
@@ -1083,14 +1090,14 @@ isdn_tty_startup(modem_info *info) | |||
1083 | static void | 1090 | static void |
1084 | isdn_tty_shutdown(modem_info *info) | 1091 | isdn_tty_shutdown(modem_info *info) |
1085 | { | 1092 | { |
1086 | if (!(info->flags & ISDN_ASYNC_INITIALIZED)) | 1093 | if (!(info->port.flags & ASYNC_INITIALIZED)) |
1087 | return; | 1094 | return; |
1088 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1095 | #ifdef ISDN_DEBUG_MODEM_OPEN |
1089 | printk(KERN_DEBUG "Shutting down isdnmodem port %d ....\n", info->line); | 1096 | printk(KERN_DEBUG "Shutting down isdnmodem port %d ....\n", info->line); |
1090 | #endif | 1097 | #endif |
1091 | isdn_unlock_drivers(); | 1098 | isdn_unlock_drivers(); |
1092 | info->msr &= ~UART_MSR_RI; | 1099 | info->msr &= ~UART_MSR_RI; |
1093 | if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) { | 1100 | if (!info->port.tty || (info->port.tty->termios->c_cflag & HUPCL)) { |
1094 | info->mcr &= ~(UART_MCR_DTR | UART_MCR_RTS); | 1101 | info->mcr &= ~(UART_MCR_DTR | UART_MCR_RTS); |
1095 | if (info->emu.mdmreg[REG_DTRHUP] & BIT_DTRHUP) { | 1102 | if (info->emu.mdmreg[REG_DTRHUP] & BIT_DTRHUP) { |
1096 | isdn_tty_modem_reset_regs(info, 0); | 1103 | isdn_tty_modem_reset_regs(info, 0); |
@@ -1100,10 +1107,10 @@ isdn_tty_shutdown(modem_info *info) | |||
1100 | isdn_tty_modem_hup(info, 1); | 1107 | isdn_tty_modem_hup(info, 1); |
1101 | } | 1108 | } |
1102 | } | 1109 | } |
1103 | if (info->tty) | 1110 | if (info->port.tty) |
1104 | set_bit(TTY_IO_ERROR, &info->tty->flags); | 1111 | set_bit(TTY_IO_ERROR, &info->port.tty->flags); |
1105 | 1112 | ||
1106 | info->flags &= ~ISDN_ASYNC_INITIALIZED; | 1113 | info->port.flags &= ~ASYNC_INITIALIZED; |
1107 | } | 1114 | } |
1108 | 1115 | ||
1109 | /* isdn_tty_write() is the main send-routine. It is called from the upper | 1116 | /* isdn_tty_write() is the main send-routine. It is called from the upper |
@@ -1146,7 +1153,7 @@ isdn_tty_write(struct tty_struct *tty, const u_char *buf, int count) | |||
1146 | isdn_tty_check_esc(buf, m->mdmreg[REG_ESC], c, | 1153 | isdn_tty_check_esc(buf, m->mdmreg[REG_ESC], c, |
1147 | &(m->pluscount), | 1154 | &(m->pluscount), |
1148 | &(m->lastplus)); | 1155 | &(m->lastplus)); |
1149 | memcpy(&(info->xmit_buf[info->xmit_count]), buf, c); | 1156 | memcpy(&info->port.xmit_buf[info->xmit_count], buf, c); |
1150 | #ifdef CONFIG_ISDN_AUDIO | 1157 | #ifdef CONFIG_ISDN_AUDIO |
1151 | if (info->vonline) { | 1158 | if (info->vonline) { |
1152 | int cc = isdn_tty_handleDLEdown(info, m, c); | 1159 | int cc = isdn_tty_handleDLEdown(info, m, c); |
@@ -1478,107 +1485,6 @@ isdn_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | |||
1478 | * isdn_tty_open() and friends | 1485 | * isdn_tty_open() and friends |
1479 | * ------------------------------------------------------------ | 1486 | * ------------------------------------------------------------ |
1480 | */ | 1487 | */ |
1481 | static int | ||
1482 | isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info *info) | ||
1483 | { | ||
1484 | DECLARE_WAITQUEUE(wait, NULL); | ||
1485 | int do_clocal = 0; | ||
1486 | int retval; | ||
1487 | |||
1488 | /* | ||
1489 | * If the device is in the middle of being closed, then block | ||
1490 | * until it's done, and then try again. | ||
1491 | */ | ||
1492 | if (tty_hung_up_p(filp) || | ||
1493 | (info->flags & ISDN_ASYNC_CLOSING)) { | ||
1494 | if (info->flags & ISDN_ASYNC_CLOSING) | ||
1495 | interruptible_sleep_on(&info->close_wait); | ||
1496 | #ifdef MODEM_DO_RESTART | ||
1497 | if (info->flags & ISDN_ASYNC_HUP_NOTIFY) | ||
1498 | return -EAGAIN; | ||
1499 | else | ||
1500 | return -ERESTARTSYS; | ||
1501 | #else | ||
1502 | return -EAGAIN; | ||
1503 | #endif | ||
1504 | } | ||
1505 | /* | ||
1506 | * If non-blocking mode is set, then make the check up front | ||
1507 | * and then exit. | ||
1508 | */ | ||
1509 | if ((filp->f_flags & O_NONBLOCK) || | ||
1510 | (tty->flags & (1 << TTY_IO_ERROR))) { | ||
1511 | if (info->flags & ISDN_ASYNC_CALLOUT_ACTIVE) | ||
1512 | return -EBUSY; | ||
1513 | info->flags |= ISDN_ASYNC_NORMAL_ACTIVE; | ||
1514 | return 0; | ||
1515 | } | ||
1516 | if (info->flags & ISDN_ASYNC_CALLOUT_ACTIVE) { | ||
1517 | if (info->normal_termios.c_cflag & CLOCAL) | ||
1518 | do_clocal = 1; | ||
1519 | } else { | ||
1520 | if (tty->termios->c_cflag & CLOCAL) | ||
1521 | do_clocal = 1; | ||
1522 | } | ||
1523 | /* | ||
1524 | * Block waiting for the carrier detect and the line to become | ||
1525 | * free (i.e., not in use by the callout). While we are in | ||
1526 | * this loop, info->count is dropped by one, so that | ||
1527 | * isdn_tty_close() knows when to free things. We restore it upon | ||
1528 | * exit, either normal or abnormal. | ||
1529 | */ | ||
1530 | retval = 0; | ||
1531 | add_wait_queue(&info->open_wait, &wait); | ||
1532 | #ifdef ISDN_DEBUG_MODEM_OPEN | ||
1533 | printk(KERN_DEBUG "isdn_tty_block_til_ready before block: ttyi%d, count = %d\n", | ||
1534 | info->line, info->count); | ||
1535 | #endif | ||
1536 | if (!(tty_hung_up_p(filp))) | ||
1537 | info->count--; | ||
1538 | info->blocked_open++; | ||
1539 | while (1) { | ||
1540 | set_current_state(TASK_INTERRUPTIBLE); | ||
1541 | if (tty_hung_up_p(filp) || | ||
1542 | !(info->flags & ISDN_ASYNC_INITIALIZED)) { | ||
1543 | #ifdef MODEM_DO_RESTART | ||
1544 | if (info->flags & ISDN_ASYNC_HUP_NOTIFY) | ||
1545 | retval = -EAGAIN; | ||
1546 | else | ||
1547 | retval = -ERESTARTSYS; | ||
1548 | #else | ||
1549 | retval = -EAGAIN; | ||
1550 | #endif | ||
1551 | break; | ||
1552 | } | ||
1553 | if (!(info->flags & ISDN_ASYNC_CALLOUT_ACTIVE) && | ||
1554 | !(info->flags & ISDN_ASYNC_CLOSING) && | ||
1555 | (do_clocal || (info->msr & UART_MSR_DCD))) { | ||
1556 | break; | ||
1557 | } | ||
1558 | if (signal_pending(current)) { | ||
1559 | retval = -ERESTARTSYS; | ||
1560 | break; | ||
1561 | } | ||
1562 | #ifdef ISDN_DEBUG_MODEM_OPEN | ||
1563 | printk(KERN_DEBUG "isdn_tty_block_til_ready blocking: ttyi%d, count = %d\n", | ||
1564 | info->line, info->count); | ||
1565 | #endif | ||
1566 | schedule(); | ||
1567 | } | ||
1568 | current->state = TASK_RUNNING; | ||
1569 | remove_wait_queue(&info->open_wait, &wait); | ||
1570 | if (!tty_hung_up_p(filp)) | ||
1571 | info->count++; | ||
1572 | info->blocked_open--; | ||
1573 | #ifdef ISDN_DEBUG_MODEM_OPEN | ||
1574 | printk(KERN_DEBUG "isdn_tty_block_til_ready after blocking: ttyi%d, count = %d\n", | ||
1575 | info->line, info->count); | ||
1576 | #endif | ||
1577 | if (retval) | ||
1578 | return retval; | ||
1579 | info->flags |= ISDN_ASYNC_NORMAL_ACTIVE; | ||
1580 | return 0; | ||
1581 | } | ||
1582 | 1488 | ||
1583 | /* | 1489 | /* |
1584 | * This routine is called whenever a serial port is opened. It | 1490 | * This routine is called whenever a serial port is opened. It |
@@ -1589,23 +1495,22 @@ isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info * | |||
1589 | static int | 1495 | static int |
1590 | isdn_tty_open(struct tty_struct *tty, struct file *filp) | 1496 | isdn_tty_open(struct tty_struct *tty, struct file *filp) |
1591 | { | 1497 | { |
1498 | struct tty_port *port; | ||
1592 | modem_info *info; | 1499 | modem_info *info; |
1593 | int retval; | 1500 | int retval; |
1594 | 1501 | ||
1595 | info = &dev->mdm.info[tty->index]; | 1502 | info = &dev->mdm.info[tty->index]; |
1596 | if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_open")) | 1503 | if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_open")) |
1597 | return -ENODEV; | 1504 | return -ENODEV; |
1598 | if (!try_module_get(info->owner)) { | 1505 | port = &info->port; |
1599 | printk(KERN_WARNING "%s: cannot reserve module\n", __func__); | ||
1600 | return -ENODEV; | ||
1601 | } | ||
1602 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1506 | #ifdef ISDN_DEBUG_MODEM_OPEN |
1603 | printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name, | 1507 | printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name, |
1604 | info->count); | 1508 | port->count); |
1605 | #endif | 1509 | #endif |
1606 | info->count++; | 1510 | port->count++; |
1607 | tty->driver_data = info; | 1511 | tty->driver_data = info; |
1608 | info->tty = tty; | 1512 | port->tty = tty; |
1513 | tty->port = port; | ||
1609 | /* | 1514 | /* |
1610 | * Start up serial port | 1515 | * Start up serial port |
1611 | */ | 1516 | */ |
@@ -1614,15 +1519,13 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp) | |||
1614 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1519 | #ifdef ISDN_DEBUG_MODEM_OPEN |
1615 | printk(KERN_DEBUG "isdn_tty_open return after startup\n"); | 1520 | printk(KERN_DEBUG "isdn_tty_open return after startup\n"); |
1616 | #endif | 1521 | #endif |
1617 | module_put(info->owner); | ||
1618 | return retval; | 1522 | return retval; |
1619 | } | 1523 | } |
1620 | retval = isdn_tty_block_til_ready(tty, filp, info); | 1524 | retval = tty_port_block_til_ready(port, tty, filp); |
1621 | if (retval) { | 1525 | if (retval) { |
1622 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1526 | #ifdef ISDN_DEBUG_MODEM_OPEN |
1623 | printk(KERN_DEBUG "isdn_tty_open return after isdn_tty_block_til_ready \n"); | 1527 | printk(KERN_DEBUG "isdn_tty_open return after isdn_tty_block_til_ready \n"); |
1624 | #endif | 1528 | #endif |
1625 | module_put(info->owner); | ||
1626 | return retval; | 1529 | return retval; |
1627 | } | 1530 | } |
1628 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1531 | #ifdef ISDN_DEBUG_MODEM_OPEN |
@@ -1639,6 +1542,7 @@ static void | |||
1639 | isdn_tty_close(struct tty_struct *tty, struct file *filp) | 1542 | isdn_tty_close(struct tty_struct *tty, struct file *filp) |
1640 | { | 1543 | { |
1641 | modem_info *info = (modem_info *) tty->driver_data; | 1544 | modem_info *info = (modem_info *) tty->driver_data; |
1545 | struct tty_port *port = &info->port; | ||
1642 | ulong timeout; | 1546 | ulong timeout; |
1643 | 1547 | ||
1644 | if (!info || isdn_tty_paranoia_check(info, tty->name, "isdn_tty_close")) | 1548 | if (!info || isdn_tty_paranoia_check(info, tty->name, "isdn_tty_close")) |
@@ -1649,7 +1553,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp) | |||
1649 | #endif | 1553 | #endif |
1650 | return; | 1554 | return; |
1651 | } | 1555 | } |
1652 | if ((tty->count == 1) && (info->count != 1)) { | 1556 | if ((tty->count == 1) && (port->count != 1)) { |
1653 | /* | 1557 | /* |
1654 | * Uh, oh. tty->count is 1, which means that the tty | 1558 | * Uh, oh. tty->count is 1, which means that the tty |
1655 | * structure will be freed. Info->count should always | 1559 | * structure will be freed. Info->count should always |
@@ -1658,30 +1562,21 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp) | |||
1658 | * serial port won't be shutdown. | 1562 | * serial port won't be shutdown. |
1659 | */ | 1563 | */ |
1660 | printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, " | 1564 | printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, " |
1661 | "info->count is %d\n", info->count); | 1565 | "info->count is %d\n", port->count); |
1662 | info->count = 1; | 1566 | port->count = 1; |
1663 | } | 1567 | } |
1664 | if (--info->count < 0) { | 1568 | if (--port->count < 0) { |
1665 | printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n", | 1569 | printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n", |
1666 | info->line, info->count); | 1570 | info->line, port->count); |
1667 | info->count = 0; | 1571 | port->count = 0; |
1668 | } | 1572 | } |
1669 | if (info->count) { | 1573 | if (port->count) { |
1670 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1574 | #ifdef ISDN_DEBUG_MODEM_OPEN |
1671 | printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n"); | 1575 | printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n"); |
1672 | #endif | 1576 | #endif |
1673 | module_put(info->owner); | ||
1674 | return; | 1577 | return; |
1675 | } | 1578 | } |
1676 | info->flags |= ISDN_ASYNC_CLOSING; | 1579 | port->flags |= ASYNC_CLOSING; |
1677 | /* | ||
1678 | * Save the termios structure, since this port may have | ||
1679 | * separate termios for callout and dialin. | ||
1680 | */ | ||
1681 | if (info->flags & ISDN_ASYNC_NORMAL_ACTIVE) | ||
1682 | info->normal_termios = *tty->termios; | ||
1683 | if (info->flags & ISDN_ASYNC_CALLOUT_ACTIVE) | ||
1684 | info->callout_termios = *tty->termios; | ||
1685 | 1580 | ||
1686 | tty->closing = 1; | 1581 | tty->closing = 1; |
1687 | /* | 1582 | /* |
@@ -1690,7 +1585,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp) | |||
1690 | * interrupt driver to stop checking the data ready bit in the | 1585 | * interrupt driver to stop checking the data ready bit in the |
1691 | * line status register. | 1586 | * line status register. |
1692 | */ | 1587 | */ |
1693 | if (info->flags & ISDN_ASYNC_INITIALIZED) { | 1588 | if (port->flags & ASYNC_INITIALIZED) { |
1694 | tty_wait_until_sent_from_close(tty, 3000); /* 30 seconds timeout */ | 1589 | tty_wait_until_sent_from_close(tty, 3000); /* 30 seconds timeout */ |
1695 | /* | 1590 | /* |
1696 | * Before we drop DTR, make sure the UART transmitter | 1591 | * Before we drop DTR, make sure the UART transmitter |
@@ -1708,16 +1603,10 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp) | |||
1708 | isdn_tty_shutdown(info); | 1603 | isdn_tty_shutdown(info); |
1709 | isdn_tty_flush_buffer(tty); | 1604 | isdn_tty_flush_buffer(tty); |
1710 | tty_ldisc_flush(tty); | 1605 | tty_ldisc_flush(tty); |
1711 | info->tty = NULL; | 1606 | port->tty = NULL; |
1712 | info->ncarrier = 0; | 1607 | info->ncarrier = 0; |
1713 | tty->closing = 0; | 1608 | |
1714 | module_put(info->owner); | 1609 | tty_port_close_end(port, tty); |
1715 | if (info->blocked_open) { | ||
1716 | msleep_interruptible(500); | ||
1717 | wake_up_interruptible(&info->open_wait); | ||
1718 | } | ||
1719 | info->flags &= ~(ISDN_ASYNC_NORMAL_ACTIVE | ISDN_ASYNC_CLOSING); | ||
1720 | wake_up_interruptible(&info->close_wait); | ||
1721 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1610 | #ifdef ISDN_DEBUG_MODEM_OPEN |
1722 | printk(KERN_DEBUG "isdn_tty_close normal exit\n"); | 1611 | printk(KERN_DEBUG "isdn_tty_close normal exit\n"); |
1723 | #endif | 1612 | #endif |
@@ -1730,14 +1619,15 @@ static void | |||
1730 | isdn_tty_hangup(struct tty_struct *tty) | 1619 | isdn_tty_hangup(struct tty_struct *tty) |
1731 | { | 1620 | { |
1732 | modem_info *info = (modem_info *) tty->driver_data; | 1621 | modem_info *info = (modem_info *) tty->driver_data; |
1622 | struct tty_port *port = &info->port; | ||
1733 | 1623 | ||
1734 | if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup")) | 1624 | if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup")) |
1735 | return; | 1625 | return; |
1736 | isdn_tty_shutdown(info); | 1626 | isdn_tty_shutdown(info); |
1737 | info->count = 0; | 1627 | port->count = 0; |
1738 | info->flags &= ~(ISDN_ASYNC_NORMAL_ACTIVE | ISDN_ASYNC_CALLOUT_ACTIVE); | 1628 | port->flags &= ~ASYNC_NORMAL_ACTIVE; |
1739 | info->tty = NULL; | 1629 | port->tty = NULL; |
1740 | wake_up_interruptible(&info->open_wait); | 1630 | wake_up_interruptible(&port->open_wait); |
1741 | } | 1631 | } |
1742 | 1632 | ||
1743 | /* This routine initializes all emulator-data. | 1633 | /* This routine initializes all emulator-data. |
@@ -1864,6 +1754,16 @@ static const struct tty_operations modem_ops = { | |||
1864 | .tiocmset = isdn_tty_tiocmset, | 1754 | .tiocmset = isdn_tty_tiocmset, |
1865 | }; | 1755 | }; |
1866 | 1756 | ||
1757 | static int isdn_tty_carrier_raised(struct tty_port *port) | ||
1758 | { | ||
1759 | modem_info *info = container_of(port, modem_info, port); | ||
1760 | return info->msr & UART_MSR_DCD; | ||
1761 | } | ||
1762 | |||
1763 | static const struct tty_port_operations isdn_tty_port_ops = { | ||
1764 | .carrier_raised = isdn_tty_carrier_raised, | ||
1765 | }; | ||
1766 | |||
1867 | int | 1767 | int |
1868 | isdn_tty_modem_init(void) | 1768 | isdn_tty_modem_init(void) |
1869 | { | 1769 | { |
@@ -1899,9 +1799,8 @@ isdn_tty_modem_init(void) | |||
1899 | goto err_unregister; | 1799 | goto err_unregister; |
1900 | } | 1800 | } |
1901 | #endif | 1801 | #endif |
1902 | #ifdef MODULE | 1802 | tty_port_init(&info->port); |
1903 | info->owner = THIS_MODULE; | 1803 | info->port.ops = &isdn_tty_port_ops; |
1904 | #endif | ||
1905 | spin_lock_init(&info->readlock); | 1804 | spin_lock_init(&info->readlock); |
1906 | sprintf(info->last_cause, "0000"); | 1805 | sprintf(info->last_cause, "0000"); |
1907 | sprintf(info->last_num, "none"); | 1806 | sprintf(info->last_num, "none"); |
@@ -1913,12 +1812,7 @@ isdn_tty_modem_init(void) | |||
1913 | isdn_tty_modem_reset_regs(info, 1); | 1812 | isdn_tty_modem_reset_regs(info, 1); |
1914 | info->magic = ISDN_ASYNC_MAGIC; | 1813 | info->magic = ISDN_ASYNC_MAGIC; |
1915 | info->line = i; | 1814 | info->line = i; |
1916 | info->tty = NULL; | ||
1917 | info->x_char = 0; | 1815 | info->x_char = 0; |
1918 | info->count = 0; | ||
1919 | info->blocked_open = 0; | ||
1920 | init_waitqueue_head(&info->open_wait); | ||
1921 | init_waitqueue_head(&info->close_wait); | ||
1922 | info->isdn_driver = -1; | 1816 | info->isdn_driver = -1; |
1923 | info->isdn_channel = -1; | 1817 | info->isdn_channel = -1; |
1924 | info->drv_index = -1; | 1818 | info->drv_index = -1; |
@@ -1930,13 +1824,15 @@ isdn_tty_modem_init(void) | |||
1930 | #ifdef CONFIG_ISDN_AUDIO | 1824 | #ifdef CONFIG_ISDN_AUDIO |
1931 | skb_queue_head_init(&info->dtmf_queue); | 1825 | skb_queue_head_init(&info->dtmf_queue); |
1932 | #endif | 1826 | #endif |
1933 | if (!(info->xmit_buf = kmalloc(ISDN_SERIAL_XMIT_MAX + 5, GFP_KERNEL))) { | 1827 | info->port.xmit_buf = kmalloc(ISDN_SERIAL_XMIT_MAX + 5, |
1828 | GFP_KERNEL); | ||
1829 | if (!info->port.xmit_buf) { | ||
1934 | printk(KERN_ERR "Could not allocate modem xmit-buffer\n"); | 1830 | printk(KERN_ERR "Could not allocate modem xmit-buffer\n"); |
1935 | retval = -ENOMEM; | 1831 | retval = -ENOMEM; |
1936 | goto err_unregister; | 1832 | goto err_unregister; |
1937 | } | 1833 | } |
1938 | /* Make room for T.70 header */ | 1834 | /* Make room for T.70 header */ |
1939 | info->xmit_buf += 4; | 1835 | info->port.xmit_buf += 4; |
1940 | } | 1836 | } |
1941 | return 0; | 1837 | return 0; |
1942 | err_unregister: | 1838 | err_unregister: |
@@ -1945,7 +1841,7 @@ err_unregister: | |||
1945 | #ifdef CONFIG_ISDN_TTY_FAX | 1841 | #ifdef CONFIG_ISDN_TTY_FAX |
1946 | kfree(info->fax); | 1842 | kfree(info->fax); |
1947 | #endif | 1843 | #endif |
1948 | kfree(info->xmit_buf - 4); | 1844 | kfree(info->port.xmit_buf - 4); |
1949 | } | 1845 | } |
1950 | tty_unregister_driver(m->tty_modem); | 1846 | tty_unregister_driver(m->tty_modem); |
1951 | err: | 1847 | err: |
@@ -1966,7 +1862,7 @@ isdn_tty_exit(void) | |||
1966 | #ifdef CONFIG_ISDN_TTY_FAX | 1862 | #ifdef CONFIG_ISDN_TTY_FAX |
1967 | kfree(info->fax); | 1863 | kfree(info->fax); |
1968 | #endif | 1864 | #endif |
1969 | kfree(info->xmit_buf - 4); | 1865 | kfree(info->port.xmit_buf - 4); |
1970 | } | 1866 | } |
1971 | tty_unregister_driver(dev->mdm.tty_modem); | 1867 | tty_unregister_driver(dev->mdm.tty_modem); |
1972 | put_tty_driver(dev->mdm.tty_modem); | 1868 | put_tty_driver(dev->mdm.tty_modem); |
@@ -2068,7 +1964,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) | |||
2068 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { | 1964 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { |
2069 | modem_info *info = &dev->mdm.info[i]; | 1965 | modem_info *info = &dev->mdm.info[i]; |
2070 | 1966 | ||
2071 | if (info->count == 0) | 1967 | if (info->port.count == 0) |
2072 | continue; | 1968 | continue; |
2073 | if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */ | 1969 | if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */ |
2074 | (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */ | 1970 | (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */ |
@@ -2076,12 +1972,12 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) | |||
2076 | #ifdef ISDN_DEBUG_MODEM_ICALL | 1972 | #ifdef ISDN_DEBUG_MODEM_ICALL |
2077 | printk(KERN_DEBUG "m_fi: match1 wret=%d\n", wret); | 1973 | printk(KERN_DEBUG "m_fi: match1 wret=%d\n", wret); |
2078 | printk(KERN_DEBUG "m_fi: idx=%d flags=%08lx drv=%d ch=%d usg=%d\n", idx, | 1974 | printk(KERN_DEBUG "m_fi: idx=%d flags=%08lx drv=%d ch=%d usg=%d\n", idx, |
2079 | info->flags, info->isdn_driver, info->isdn_channel, | 1975 | info->port.flags, info->isdn_driver, |
2080 | dev->usage[idx]); | 1976 | info->isdn_channel, dev->usage[idx]); |
2081 | #endif | 1977 | #endif |
2082 | if ( | 1978 | if ( |
2083 | #ifndef FIX_FILE_TRANSFER | 1979 | #ifndef FIX_FILE_TRANSFER |
2084 | (info->flags & ISDN_ASYNC_NORMAL_ACTIVE) && | 1980 | (info->port.flags & ASYNC_NORMAL_ACTIVE) && |
2085 | #endif | 1981 | #endif |
2086 | (info->isdn_driver == -1) && | 1982 | (info->isdn_driver == -1) && |
2087 | (info->isdn_channel == -1) && | 1983 | (info->isdn_channel == -1) && |
@@ -2120,8 +2016,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) | |||
2120 | return (wret == 2) ? 3 : 0; | 2016 | return (wret == 2) ? 3 : 0; |
2121 | } | 2017 | } |
2122 | 2018 | ||
2123 | #define TTY_IS_ACTIVE(info) \ | 2019 | #define TTY_IS_ACTIVE(info) (info->port.flags & ASYNC_NORMAL_ACTIVE) |
2124 | (info->flags & (ISDN_ASYNC_NORMAL_ACTIVE | ISDN_ASYNC_CALLOUT_ACTIVE)) | ||
2125 | 2020 | ||
2126 | int | 2021 | int |
2127 | isdn_tty_stat_callback(int i, isdn_ctrl *c) | 2022 | isdn_tty_stat_callback(int i, isdn_ctrl *c) |
@@ -2212,9 +2107,9 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) | |||
2212 | * for incoming call of this device when | 2107 | * for incoming call of this device when |
2213 | * DCD follow the state of incoming carrier | 2108 | * DCD follow the state of incoming carrier |
2214 | */ | 2109 | */ |
2215 | if (info->blocked_open && | 2110 | if (info->port.blocked_open && |
2216 | (info->emu.mdmreg[REG_DCD] & BIT_DCD)) { | 2111 | (info->emu.mdmreg[REG_DCD] & BIT_DCD)) { |
2217 | wake_up_interruptible(&info->open_wait); | 2112 | wake_up_interruptible(&info->port.open_wait); |
2218 | } | 2113 | } |
2219 | 2114 | ||
2220 | /* Schedule CONNECT-Message to any tty | 2115 | /* Schedule CONNECT-Message to any tty |
@@ -2222,7 +2117,8 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) | |||
2222 | * set DCD-bit of its modem-status. | 2117 | * set DCD-bit of its modem-status. |
2223 | */ | 2118 | */ |
2224 | if (TTY_IS_ACTIVE(info) || | 2119 | if (TTY_IS_ACTIVE(info) || |
2225 | (info->blocked_open && (info->emu.mdmreg[REG_DCD] & BIT_DCD))) { | 2120 | (info->port.blocked_open && |
2121 | (info->emu.mdmreg[REG_DCD] & BIT_DCD))) { | ||
2226 | info->msr |= UART_MSR_DCD; | 2122 | info->msr |= UART_MSR_DCD; |
2227 | info->emu.charge = 0; | 2123 | info->emu.charge = 0; |
2228 | if (info->dialing & 0xf) | 2124 | if (info->dialing & 0xf) |
@@ -2339,8 +2235,8 @@ isdn_tty_at_cout(char *msg, modem_info *info) | |||
2339 | l = strlen(msg); | 2235 | l = strlen(msg); |
2340 | 2236 | ||
2341 | spin_lock_irqsave(&info->readlock, flags); | 2237 | spin_lock_irqsave(&info->readlock, flags); |
2342 | tty = info->tty; | 2238 | tty = info->port.tty; |
2343 | if ((info->flags & ISDN_ASYNC_CLOSING) || (!tty)) { | 2239 | if ((info->port.flags & ASYNC_CLOSING) || (!tty)) { |
2344 | spin_unlock_irqrestore(&info->readlock, flags); | 2240 | spin_unlock_irqrestore(&info->readlock, flags); |
2345 | return; | 2241 | return; |
2346 | } | 2242 | } |
@@ -2490,15 +2386,15 @@ isdn_tty_modem_result(int code, modem_info *info) | |||
2490 | case RESULT_NO_CARRIER: | 2386 | case RESULT_NO_CARRIER: |
2491 | #ifdef ISDN_DEBUG_MODEM_HUP | 2387 | #ifdef ISDN_DEBUG_MODEM_HUP |
2492 | printk(KERN_DEBUG "modem_result: NO CARRIER %d %d\n", | 2388 | printk(KERN_DEBUG "modem_result: NO CARRIER %d %d\n", |
2493 | (info->flags & ISDN_ASYNC_CLOSING), | 2389 | (info->port.flags & ASYNC_CLOSING), |
2494 | (!info->tty)); | 2390 | (!info->port.tty)); |
2495 | #endif | 2391 | #endif |
2496 | m->mdmreg[REG_RINGCNT] = 0; | 2392 | m->mdmreg[REG_RINGCNT] = 0; |
2497 | del_timer(&info->nc_timer); | 2393 | del_timer(&info->nc_timer); |
2498 | info->ncarrier = 0; | 2394 | info->ncarrier = 0; |
2499 | if ((info->flags & ISDN_ASYNC_CLOSING) || (!info->tty)) { | 2395 | if ((info->port.flags & ASYNC_CLOSING) || (!info->port.tty)) |
2500 | return; | 2396 | return; |
2501 | } | 2397 | |
2502 | #ifdef CONFIG_ISDN_AUDIO | 2398 | #ifdef CONFIG_ISDN_AUDIO |
2503 | if (info->vonline & 1) { | 2399 | if (info->vonline & 1) { |
2504 | #ifdef ISDN_DEBUG_MODEM_VOICE | 2400 | #ifdef ISDN_DEBUG_MODEM_VOICE |
@@ -2629,14 +2525,11 @@ isdn_tty_modem_result(int code, modem_info *info) | |||
2629 | } | 2525 | } |
2630 | } | 2526 | } |
2631 | if (code == RESULT_NO_CARRIER) { | 2527 | if (code == RESULT_NO_CARRIER) { |
2632 | if ((info->flags & ISDN_ASYNC_CLOSING) || (!info->tty)) { | 2528 | if ((info->port.flags & ASYNC_CLOSING) || (!info->port.tty)) |
2633 | return; | 2529 | return; |
2634 | } | 2530 | |
2635 | if ((info->flags & ISDN_ASYNC_CHECK_CD) && | 2531 | if (info->port.flags & ASYNC_CHECK_CD) |
2636 | (!((info->flags & ISDN_ASYNC_CALLOUT_ACTIVE) && | 2532 | tty_hangup(info->port.tty); |
2637 | (info->flags & ISDN_ASYNC_CALLOUT_NOHUP)))) { | ||
2638 | tty_hangup(info->tty); | ||
2639 | } | ||
2640 | } | 2533 | } |
2641 | } | 2534 | } |
2642 | 2535 | ||
@@ -3803,19 +3696,19 @@ isdn_tty_modem_escape(void) | |||
3803 | int midx; | 3696 | int midx; |
3804 | 3697 | ||
3805 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) | 3698 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) |
3806 | if (USG_MODEM(dev->usage[i])) | 3699 | if (USG_MODEM(dev->usage[i]) && (midx = dev->m_idx[i]) >= 0) { |
3807 | if ((midx = dev->m_idx[i]) >= 0) { | 3700 | modem_info *info = &dev->mdm.info[midx]; |
3808 | modem_info *info = &dev->mdm.info[midx]; | 3701 | if (info->online) { |
3809 | if (info->online) { | 3702 | ton = 1; |
3810 | ton = 1; | 3703 | if ((info->emu.pluscount == 3) && |
3811 | if ((info->emu.pluscount == 3) && | 3704 | time_after(jiffies, |
3812 | time_after(jiffies , info->emu.lastplus + PLUSWAIT2)) { | 3705 | info->emu.lastplus + PLUSWAIT2)) { |
3813 | info->emu.pluscount = 0; | 3706 | info->emu.pluscount = 0; |
3814 | info->online = 0; | 3707 | info->online = 0; |
3815 | isdn_tty_modem_result(RESULT_OK, info); | 3708 | isdn_tty_modem_result(RESULT_OK, info); |
3816 | } | ||
3817 | } | 3709 | } |
3818 | } | 3710 | } |
3711 | } | ||
3819 | isdn_timer_ctrl(ISDN_TIMER_MODEMPLUS, ton); | 3712 | isdn_timer_ctrl(ISDN_TIMER_MODEMPLUS, ton); |
3820 | } | 3713 | } |
3821 | 3714 | ||
@@ -3873,15 +3766,14 @@ isdn_tty_carrier_timeout(void) | |||
3873 | 3766 | ||
3874 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { | 3767 | for (i = 0; i < ISDN_MAX_CHANNELS; i++) { |
3875 | modem_info *info = &dev->mdm.info[i]; | 3768 | modem_info *info = &dev->mdm.info[i]; |
3876 | if (info->dialing) { | 3769 | if (!info->dialing) |
3877 | if (info->emu.carrierwait++ > info->emu.mdmreg[REG_WAITC]) { | 3770 | continue; |
3878 | info->dialing = 0; | 3771 | if (info->emu.carrierwait++ > info->emu.mdmreg[REG_WAITC]) { |
3879 | isdn_tty_modem_result(RESULT_NO_CARRIER, info); | 3772 | info->dialing = 0; |
3880 | isdn_tty_modem_hup(info, 1); | 3773 | isdn_tty_modem_result(RESULT_NO_CARRIER, info); |
3881 | } | 3774 | isdn_tty_modem_hup(info, 1); |
3882 | else | 3775 | } else |
3883 | ton = 1; | 3776 | ton = 1; |
3884 | } | ||
3885 | } | 3777 | } |
3886 | isdn_timer_ctrl(ISDN_TIMER_CARRIER, ton); | 3778 | isdn_timer_ctrl(ISDN_TIMER_CARRIER, ton); |
3887 | } | 3779 | } |