blob: 4270bfd59a7f09e1398b8509d82b829aec398246 [file] [log] [blame]
David Sterba099dc4f2008-02-07 10:57:12 +01001/*
2 * IPWireless 3G PCMCIA Network Driver
3 *
4 * Original code
5 * by Stephen Blackheath <stephen@blacksapphire.com>,
6 * Ben Martel <benm@symmetric.co.nz>
7 *
8 * Copyrighted as follows:
9 * Copyright (C) 2004 by Symmetric Systems Ltd (NZ)
10 *
11 * Various driver changes and rewrites, port to new kernels
12 * Copyright (C) 2006-2007 Jiri Kosina
13 *
14 * Misc code cleanups and updates
15 * Copyright (C) 2007 David Sterba
16 */
17
18#include <linux/init.h>
19#include <linux/kernel.h>
20#include <linux/module.h>
21#include <linux/mutex.h>
22#include <linux/ppp_defs.h>
23#include <linux/if.h>
Paul Mackerras4b32da2b2012-03-04 12:56:55 +000024#include <linux/ppp-ioctl.h>
David Sterba099dc4f2008-02-07 10:57:12 +010025#include <linux/sched.h>
26#include <linux/serial.h>
27#include <linux/slab.h>
28#include <linux/tty.h>
29#include <linux/tty_driver.h>
30#include <linux/tty_flip.h>
31#include <linux/uaccess.h>
David Sterba099dc4f2008-02-07 10:57:12 +010032
33#include "tty.h"
34#include "network.h"
35#include "hardware.h"
36#include "main.h"
37
38#define IPWIRELESS_PCMCIA_START (0)
39#define IPWIRELESS_PCMCIA_MINORS (24)
40#define IPWIRELESS_PCMCIA_MINOR_RANGE (8)
41
42#define TTYTYPE_MODEM (0)
43#define TTYTYPE_MONITOR (1)
44#define TTYTYPE_RAS_RAW (2)
45
46struct ipw_tty {
47 int index;
48 struct ipw_hardware *hardware;
49 unsigned int channel_idx;
50 unsigned int secondary_channel_idx;
51 int tty_type;
52 struct ipw_network *network;
53 struct tty_struct *linux_tty;
54 int open_count;
55 unsigned int control_lines;
56 struct mutex ipw_tty_mutex;
57 int tx_bytes_queued;
58 int closing;
59};
60
61static struct ipw_tty *ttys[IPWIRELESS_PCMCIA_MINORS];
62
63static struct tty_driver *ipw_tty_driver;
64
65static char *tty_type_name(int tty_type)
66{
67 static char *channel_names[] = {
68 "modem",
69 "monitor",
70 "RAS-raw"
71 };
72
73 return channel_names[tty_type];
74}
75
Jiri Slabyecaa3bd2012-03-05 14:52:02 +010076static struct ipw_tty *get_tty(int index)
David Sterba099dc4f2008-02-07 10:57:12 +010077{
Jiri Slabyecaa3bd2012-03-05 14:52:02 +010078 /*
79 * The 'ras_raw' channel is only available when 'loopback' mode
80 * is enabled.
81 * Number of minor starts with 16 (_RANGE * _RAS_RAW).
82 */
83 if (!ipwireless_loopback && index >=
84 IPWIRELESS_PCMCIA_MINOR_RANGE * TTYTYPE_RAS_RAW)
David Sterba099dc4f2008-02-07 10:57:12 +010085 return NULL;
David Sterba099dc4f2008-02-07 10:57:12 +010086
Jiri Slabyecaa3bd2012-03-05 14:52:02 +010087 return ttys[index];
David Sterba099dc4f2008-02-07 10:57:12 +010088}
89
90static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
91{
Jiri Slabyecaa3bd2012-03-05 14:52:02 +010092 struct ipw_tty *tty = get_tty(linux_tty->index);
David Sterba099dc4f2008-02-07 10:57:12 +010093
94 if (!tty)
95 return -ENODEV;
96
97 mutex_lock(&tty->ipw_tty_mutex);
98
99 if (tty->closing) {
100 mutex_unlock(&tty->ipw_tty_mutex);
101 return -ENODEV;
102 }
103 if (tty->open_count == 0)
104 tty->tx_bytes_queued = 0;
105
106 tty->open_count++;
107
108 tty->linux_tty = linux_tty;
109 linux_tty->driver_data = tty;
110 linux_tty->low_latency = 1;
111
112 if (tty->tty_type == TTYTYPE_MODEM)
113 ipwireless_ppp_open(tty->network);
114
115 mutex_unlock(&tty->ipw_tty_mutex);
116
117 return 0;
118}
119
120static void do_ipw_close(struct ipw_tty *tty)
121{
122 tty->open_count--;
123
124 if (tty->open_count == 0) {
125 struct tty_struct *linux_tty = tty->linux_tty;
126
127 if (linux_tty != NULL) {
128 tty->linux_tty = NULL;
129 linux_tty->driver_data = NULL;
130
131 if (tty->tty_type == TTYTYPE_MODEM)
132 ipwireless_ppp_close(tty->network);
133 }
134 }
135}
136
137static void ipw_hangup(struct tty_struct *linux_tty)
138{
139 struct ipw_tty *tty = linux_tty->driver_data;
140
141 if (!tty)
142 return;
143
144 mutex_lock(&tty->ipw_tty_mutex);
145 if (tty->open_count == 0) {
146 mutex_unlock(&tty->ipw_tty_mutex);
147 return;
148 }
149
150 do_ipw_close(tty);
151
152 mutex_unlock(&tty->ipw_tty_mutex);
153}
154
155static void ipw_close(struct tty_struct *linux_tty, struct file *filp)
156{
157 ipw_hangup(linux_tty);
158}
159
160/* Take data received from hardware, and send it out the tty */
161void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
162 unsigned int length)
163{
164 struct tty_struct *linux_tty;
165 int work = 0;
166
167 mutex_lock(&tty->ipw_tty_mutex);
168 linux_tty = tty->linux_tty;
169 if (linux_tty == NULL) {
170 mutex_unlock(&tty->ipw_tty_mutex);
171 return;
172 }
173
174 if (!tty->open_count) {
175 mutex_unlock(&tty->ipw_tty_mutex);
176 return;
177 }
178 mutex_unlock(&tty->ipw_tty_mutex);
179
180 work = tty_insert_flip_string(linux_tty, data, length);
181
182 if (work != length)
183 printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME
184 ": %d chars not inserted to flip buffer!\n",
185 length - work);
186
187 /*
188 * This may sleep if ->low_latency is set
189 */
190 if (work)
191 tty_flip_buffer_push(linux_tty);
192}
193
194static void ipw_write_packet_sent_callback(void *callback_data,
195 unsigned int packet_length)
196{
197 struct ipw_tty *tty = callback_data;
198
199 /*
200 * Packet has been sent, so we subtract the number of bytes from our
201 * tally of outstanding TX bytes.
202 */
203 tty->tx_bytes_queued -= packet_length;
204}
205
206static int ipw_write(struct tty_struct *linux_tty,
207 const unsigned char *buf, int count)
208{
209 struct ipw_tty *tty = linux_tty->driver_data;
210 int room, ret;
211
212 if (!tty)
213 return -ENODEV;
214
215 mutex_lock(&tty->ipw_tty_mutex);
216 if (!tty->open_count) {
217 mutex_unlock(&tty->ipw_tty_mutex);
218 return -EINVAL;
219 }
220
221 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
222 if (room < 0)
223 room = 0;
224 /* Don't allow caller to write any more than we have room for */
225 if (count > room)
226 count = room;
227
228 if (count == 0) {
229 mutex_unlock(&tty->ipw_tty_mutex);
230 return 0;
231 }
232
233 ret = ipwireless_send_packet(tty->hardware, IPW_CHANNEL_RAS,
David Sterbaff3e9902008-07-28 16:53:11 +0200234 buf, count,
David Sterba099dc4f2008-02-07 10:57:12 +0100235 ipw_write_packet_sent_callback, tty);
236 if (ret == -1) {
237 mutex_unlock(&tty->ipw_tty_mutex);
238 return 0;
239 }
240
241 tty->tx_bytes_queued += count;
242 mutex_unlock(&tty->ipw_tty_mutex);
243
244 return count;
245}
246
247static int ipw_write_room(struct tty_struct *linux_tty)
248{
249 struct ipw_tty *tty = linux_tty->driver_data;
250 int room;
251
Alan Cox5aaa70a2008-10-13 10:38:07 +0100252 /* FIXME: Exactly how is the tty object locked here .. */
David Sterba099dc4f2008-02-07 10:57:12 +0100253 if (!tty)
254 return -ENODEV;
255
256 if (!tty->open_count)
257 return -EINVAL;
258
259 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
260 if (room < 0)
261 room = 0;
262
263 return room;
264}
265
266static int ipwireless_get_serial_info(struct ipw_tty *tty,
267 struct serial_struct __user *retinfo)
268{
269 struct serial_struct tmp;
270
271 if (!retinfo)
272 return (-EFAULT);
273
274 memset(&tmp, 0, sizeof(tmp));
275 tmp.type = PORT_UNKNOWN;
276 tmp.line = tty->index;
277 tmp.port = 0;
278 tmp.irq = 0;
279 tmp.flags = 0;
280 tmp.baud_base = 115200;
281 tmp.close_delay = 0;
282 tmp.closing_wait = 0;
283 tmp.custom_divisor = 0;
284 tmp.hub6 = 0;
285 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
286 return -EFAULT;
287
288 return 0;
289}
290
291static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
292{
293 struct ipw_tty *tty = linux_tty->driver_data;
294
295 if (!tty)
Alan Cox23198fd2009-07-20 16:05:27 +0100296 return 0;
David Sterba099dc4f2008-02-07 10:57:12 +0100297
298 if (!tty->open_count)
Alan Cox23198fd2009-07-20 16:05:27 +0100299 return 0;
David Sterba099dc4f2008-02-07 10:57:12 +0100300
301 return tty->tx_bytes_queued;
302}
303
304static int get_control_lines(struct ipw_tty *tty)
305{
306 unsigned int my = tty->control_lines;
307 unsigned int out = 0;
308
309 if (my & IPW_CONTROL_LINE_RTS)
310 out |= TIOCM_RTS;
311 if (my & IPW_CONTROL_LINE_DTR)
312 out |= TIOCM_DTR;
313 if (my & IPW_CONTROL_LINE_CTS)
314 out |= TIOCM_CTS;
315 if (my & IPW_CONTROL_LINE_DSR)
316 out |= TIOCM_DSR;
317 if (my & IPW_CONTROL_LINE_DCD)
318 out |= TIOCM_CD;
319
320 return out;
321}
322
323static int set_control_lines(struct ipw_tty *tty, unsigned int set,
324 unsigned int clear)
325{
326 int ret;
327
328 if (set & TIOCM_RTS) {
329 ret = ipwireless_set_RTS(tty->hardware, tty->channel_idx, 1);
330 if (ret)
331 return ret;
332 if (tty->secondary_channel_idx != -1) {
333 ret = ipwireless_set_RTS(tty->hardware,
334 tty->secondary_channel_idx, 1);
335 if (ret)
336 return ret;
337 }
338 }
339 if (set & TIOCM_DTR) {
340 ret = ipwireless_set_DTR(tty->hardware, tty->channel_idx, 1);
341 if (ret)
342 return ret;
343 if (tty->secondary_channel_idx != -1) {
344 ret = ipwireless_set_DTR(tty->hardware,
345 tty->secondary_channel_idx, 1);
346 if (ret)
347 return ret;
348 }
349 }
350 if (clear & TIOCM_RTS) {
351 ret = ipwireless_set_RTS(tty->hardware, tty->channel_idx, 0);
352 if (tty->secondary_channel_idx != -1) {
353 ret = ipwireless_set_RTS(tty->hardware,
354 tty->secondary_channel_idx, 0);
355 if (ret)
356 return ret;
357 }
358 }
359 if (clear & TIOCM_DTR) {
360 ret = ipwireless_set_DTR(tty->hardware, tty->channel_idx, 0);
361 if (tty->secondary_channel_idx != -1) {
362 ret = ipwireless_set_DTR(tty->hardware,
363 tty->secondary_channel_idx, 0);
364 if (ret)
365 return ret;
366 }
367 }
368 return 0;
369}
370
Alan Cox60b33c12011-02-14 16:26:14 +0000371static int ipw_tiocmget(struct tty_struct *linux_tty)
David Sterba099dc4f2008-02-07 10:57:12 +0100372{
373 struct ipw_tty *tty = linux_tty->driver_data;
Alan Cox5aaa70a2008-10-13 10:38:07 +0100374 /* FIXME: Exactly how is the tty object locked here .. */
David Sterba099dc4f2008-02-07 10:57:12 +0100375
376 if (!tty)
377 return -ENODEV;
378
379 if (!tty->open_count)
380 return -EINVAL;
381
382 return get_control_lines(tty);
383}
384
385static int
Alan Cox20b9d172011-02-14 16:26:50 +0000386ipw_tiocmset(struct tty_struct *linux_tty,
David Sterba099dc4f2008-02-07 10:57:12 +0100387 unsigned int set, unsigned int clear)
388{
389 struct ipw_tty *tty = linux_tty->driver_data;
Alan Cox5aaa70a2008-10-13 10:38:07 +0100390 /* FIXME: Exactly how is the tty object locked here .. */
David Sterba099dc4f2008-02-07 10:57:12 +0100391
392 if (!tty)
393 return -ENODEV;
394
395 if (!tty->open_count)
396 return -EINVAL;
397
398 return set_control_lines(tty, set, clear);
399}
400
Alan Cox6caa76b2011-02-14 16:27:22 +0000401static int ipw_ioctl(struct tty_struct *linux_tty,
David Sterba099dc4f2008-02-07 10:57:12 +0100402 unsigned int cmd, unsigned long arg)
403{
404 struct ipw_tty *tty = linux_tty->driver_data;
405
406 if (!tty)
407 return -ENODEV;
408
409 if (!tty->open_count)
410 return -EINVAL;
411
Alan Cox5aaa70a2008-10-13 10:38:07 +0100412 /* FIXME: Exactly how is the tty object locked here .. */
413
David Sterba099dc4f2008-02-07 10:57:12 +0100414 switch (cmd) {
415 case TIOCGSERIAL:
416 return ipwireless_get_serial_info(tty, (void __user *) arg);
417
418 case TIOCSSERIAL:
419 return 0; /* Keeps the PCMCIA scripts happy. */
420 }
421
422 if (tty->tty_type == TTYTYPE_MODEM) {
423 switch (cmd) {
424 case PPPIOCGCHAN:
425 {
426 int chan = ipwireless_ppp_channel_index(
427 tty->network);
428
429 if (chan < 0)
430 return -ENODEV;
431 if (put_user(chan, (int __user *) arg))
432 return -EFAULT;
433 }
434 return 0;
435
436 case PPPIOCGUNIT:
437 {
438 int unit = ipwireless_ppp_unit_number(
439 tty->network);
440
441 if (unit < 0)
442 return -ENODEV;
443 if (put_user(unit, (int __user *) arg))
444 return -EFAULT;
445 }
446 return 0;
447
David Sterba099dc4f2008-02-07 10:57:12 +0100448 case FIONREAD:
449 {
450 int val = 0;
451
452 if (put_user(val, (int __user *) arg))
453 return -EFAULT;
454 }
455 return 0;
Alan Cox5aaa70a2008-10-13 10:38:07 +0100456 case TCFLSH:
457 return tty_perform_flush(linux_tty, arg);
David Sterba099dc4f2008-02-07 10:57:12 +0100458 }
459 }
Alan Cox6caa76b2011-02-14 16:27:22 +0000460 return -ENOIOCTLCMD;
David Sterba099dc4f2008-02-07 10:57:12 +0100461}
462
Dominik Brodowskib498ada2010-03-20 19:43:26 +0100463static int add_tty(int j,
David Sterba099dc4f2008-02-07 10:57:12 +0100464 struct ipw_hardware *hardware,
465 struct ipw_network *network, int channel_idx,
466 int secondary_channel_idx, int tty_type)
467{
468 ttys[j] = kzalloc(sizeof(struct ipw_tty), GFP_KERNEL);
469 if (!ttys[j])
470 return -ENOMEM;
471 ttys[j]->index = j;
472 ttys[j]->hardware = hardware;
473 ttys[j]->channel_idx = channel_idx;
474 ttys[j]->secondary_channel_idx = secondary_channel_idx;
475 ttys[j]->network = network;
476 ttys[j]->tty_type = tty_type;
477 mutex_init(&ttys[j]->ipw_tty_mutex);
478
479 tty_register_device(ipw_tty_driver, j, NULL);
480 ipwireless_associate_network_tty(network, channel_idx, ttys[j]);
481
482 if (secondary_channel_idx != -1)
483 ipwireless_associate_network_tty(network,
484 secondary_channel_idx,
485 ttys[j]);
Jiri Slabye6df3cc2012-04-02 13:54:32 +0200486 /* check if we provide raw device (if loopback is enabled) */
487 if (get_tty(j))
488 printk(KERN_INFO IPWIRELESS_PCCARD_NAME
489 ": registering %s device ttyIPWp%d\n",
490 tty_type_name(tty_type), j);
491
David Sterba099dc4f2008-02-07 10:57:12 +0100492 return 0;
493}
494
495struct ipw_tty *ipwireless_tty_create(struct ipw_hardware *hardware,
Dominik Brodowskib498ada2010-03-20 19:43:26 +0100496 struct ipw_network *network)
David Sterba099dc4f2008-02-07 10:57:12 +0100497{
498 int i, j;
499
500 for (i = 0; i < IPWIRELESS_PCMCIA_MINOR_RANGE; i++) {
501 int allfree = 1;
502
503 for (j = i; j < IPWIRELESS_PCMCIA_MINORS;
504 j += IPWIRELESS_PCMCIA_MINOR_RANGE)
505 if (ttys[j] != NULL) {
506 allfree = 0;
507 break;
508 }
509
510 if (allfree) {
511 j = i;
512
Dominik Brodowskib498ada2010-03-20 19:43:26 +0100513 if (add_tty(j, hardware, network,
David Sterba099dc4f2008-02-07 10:57:12 +0100514 IPW_CHANNEL_DIALLER, IPW_CHANNEL_RAS,
515 TTYTYPE_MODEM))
516 return NULL;
517
518 j += IPWIRELESS_PCMCIA_MINOR_RANGE;
Dominik Brodowskib498ada2010-03-20 19:43:26 +0100519 if (add_tty(j, hardware, network,
David Sterba099dc4f2008-02-07 10:57:12 +0100520 IPW_CHANNEL_DIALLER, -1,
521 TTYTYPE_MONITOR))
522 return NULL;
523
524 j += IPWIRELESS_PCMCIA_MINOR_RANGE;
Dominik Brodowskib498ada2010-03-20 19:43:26 +0100525 if (add_tty(j, hardware, network,
David Sterba099dc4f2008-02-07 10:57:12 +0100526 IPW_CHANNEL_RAS, -1,
527 TTYTYPE_RAS_RAW))
528 return NULL;
529
David Sterba099dc4f2008-02-07 10:57:12 +0100530 return ttys[i];
531 }
532 }
533 return NULL;
534}
535
536/*
537 * Must be called before ipwireless_network_free().
538 */
539void ipwireless_tty_free(struct ipw_tty *tty)
540{
541 int j;
542 struct ipw_network *network = ttys[tty->index]->network;
543
544 for (j = tty->index; j < IPWIRELESS_PCMCIA_MINORS;
545 j += IPWIRELESS_PCMCIA_MINOR_RANGE) {
546 struct ipw_tty *ttyj = ttys[j];
547
548 if (ttyj) {
549 mutex_lock(&ttyj->ipw_tty_mutex);
Jiri Slabye6df3cc2012-04-02 13:54:32 +0200550 if (get_tty(j))
551 printk(KERN_INFO IPWIRELESS_PCCARD_NAME
552 ": deregistering %s device ttyIPWp%d\n",
553 tty_type_name(ttyj->tty_type), j);
David Sterba099dc4f2008-02-07 10:57:12 +0100554 ttyj->closing = 1;
555 if (ttyj->linux_tty != NULL) {
556 mutex_unlock(&ttyj->ipw_tty_mutex);
Jiri Slabyde3a60a2012-04-02 13:54:31 +0200557 tty_vhangup(ttyj->linux_tty);
Alan Cox5aaa70a2008-10-13 10:38:07 +0100558 /* FIXME: Exactly how is the tty object locked here
559 against a parallel ioctl etc */
Jiri Slabyde3a60a2012-04-02 13:54:31 +0200560 /* FIXME2: hangup does not mean all processes
561 * are gone */
David Sterba099dc4f2008-02-07 10:57:12 +0100562 mutex_lock(&ttyj->ipw_tty_mutex);
563 }
564 while (ttyj->open_count)
565 do_ipw_close(ttyj);
566 ipwireless_disassociate_network_ttys(network,
567 ttyj->channel_idx);
568 tty_unregister_device(ipw_tty_driver, j);
569 ttys[j] = NULL;
570 mutex_unlock(&ttyj->ipw_tty_mutex);
571 kfree(ttyj);
572 }
573 }
574}
575
Alexey Dobriyan1cceefd2009-10-03 00:12:06 +0400576static const struct tty_operations tty_ops = {
David Sterba099dc4f2008-02-07 10:57:12 +0100577 .open = ipw_open,
578 .close = ipw_close,
579 .hangup = ipw_hangup,
580 .write = ipw_write,
581 .write_room = ipw_write_room,
582 .ioctl = ipw_ioctl,
583 .chars_in_buffer = ipw_chars_in_buffer,
584 .tiocmget = ipw_tiocmget,
585 .tiocmset = ipw_tiocmset,
586};
587
588int ipwireless_tty_init(void)
589{
590 int result;
591
592 ipw_tty_driver = alloc_tty_driver(IPWIRELESS_PCMCIA_MINORS);
593 if (!ipw_tty_driver)
594 return -ENOMEM;
595
David Sterba099dc4f2008-02-07 10:57:12 +0100596 ipw_tty_driver->driver_name = IPWIRELESS_PCCARD_NAME;
597 ipw_tty_driver->name = "ttyIPWp";
598 ipw_tty_driver->major = 0;
599 ipw_tty_driver->minor_start = IPWIRELESS_PCMCIA_START;
600 ipw_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
601 ipw_tty_driver->subtype = SERIAL_TYPE_NORMAL;
602 ipw_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
603 ipw_tty_driver->init_termios = tty_std_termios;
604 ipw_tty_driver->init_termios.c_cflag =
605 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
606 ipw_tty_driver->init_termios.c_ispeed = 9600;
607 ipw_tty_driver->init_termios.c_ospeed = 9600;
608 tty_set_operations(ipw_tty_driver, &tty_ops);
609 result = tty_register_driver(ipw_tty_driver);
610 if (result) {
611 printk(KERN_ERR IPWIRELESS_PCCARD_NAME
612 ": failed to register tty driver\n");
613 put_tty_driver(ipw_tty_driver);
614 return result;
615 }
616
617 return 0;
618}
619
620void ipwireless_tty_release(void)
621{
622 int ret;
623
624 ret = tty_unregister_driver(ipw_tty_driver);
625 put_tty_driver(ipw_tty_driver);
626 if (ret != 0)
627 printk(KERN_ERR IPWIRELESS_PCCARD_NAME
628 ": tty_unregister_driver failed with code %d\n", ret);
629}
630
631int ipwireless_tty_is_modem(struct ipw_tty *tty)
632{
633 return tty->tty_type == TTYTYPE_MODEM;
634}
635
636void
637ipwireless_tty_notify_control_line_change(struct ipw_tty *tty,
638 unsigned int channel_idx,
639 unsigned int control_lines,
640 unsigned int changed_mask)
641{
642 unsigned int old_control_lines = tty->control_lines;
643
644 tty->control_lines = (tty->control_lines & ~changed_mask)
645 | (control_lines & changed_mask);
646
647 /*
648 * If DCD is de-asserted, we close the tty so pppd can tell that we
649 * have gone offline.
650 */
651 if ((old_control_lines & IPW_CONTROL_LINE_DCD)
652 && !(tty->control_lines & IPW_CONTROL_LINE_DCD)
653 && tty->linux_tty) {
654 tty_hangup(tty->linux_tty);
655 }
656}
657