aboutsummaryrefslogtreecommitdiffstats
path: root/net/irda/ircomm/ircomm_tty_attach.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/irda/ircomm/ircomm_tty_attach.c')
-rw-r--r--net/irda/ircomm/ircomm_tty_attach.c236
1 files changed, 118 insertions, 118 deletions
diff --git a/net/irda/ircomm/ircomm_tty_attach.c b/net/irda/ircomm/ircomm_tty_attach.c
index 99f5eddbb4b..8d7ba93e4e0 100644
--- a/net/irda/ircomm/ircomm_tty_attach.c
+++ b/net/irda/ircomm/ircomm_tty_attach.c
@@ -1,32 +1,32 @@
1/********************************************************************* 1/*********************************************************************
2 * 2 *
3 * Filename: ircomm_tty_attach.c 3 * Filename: ircomm_tty_attach.c
4 * Version: 4 * Version:
5 * Description: Code for attaching the serial driver to IrCOMM 5 * Description: Code for attaching the serial driver to IrCOMM
6 * Status: Experimental. 6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no> 7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Sat Jun 5 17:42:00 1999 8 * Created at: Sat Jun 5 17:42:00 1999
9 * Modified at: Tue Jan 4 14:20:49 2000 9 * Modified at: Tue Jan 4 14:20:49 2000
10 * Modified by: Dag Brattli <dagb@cs.uit.no> 10 * Modified by: Dag Brattli <dagb@cs.uit.no>
11 * 11 *
12 * Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved. 12 * Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved.
13 * Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com> 13 * Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com>
14 * 14 *
15 * This program is free software; you can redistribute it and/or 15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as 16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of 17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version. 18 * the License, or (at your option) any later version.
19 * 19 *
20 * This program is distributed in the hope that it will be useful, 20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 23 * GNU General Public License for more details.
24 * 24 *
25 * You should have received a copy of the GNU General Public License 25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software 26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 * MA 02111-1307 USA 28 * MA 02111-1307 USA
29 * 29 *
30 ********************************************************************/ 30 ********************************************************************/
31 31
32#include <linux/sched.h> 32#include <linux/sched.h>
@@ -50,35 +50,35 @@ static void ircomm_tty_ias_register(struct ircomm_tty_cb *self);
50static void ircomm_tty_discovery_indication(discinfo_t *discovery, 50static void ircomm_tty_discovery_indication(discinfo_t *discovery,
51 DISCOVERY_MODE mode, 51 DISCOVERY_MODE mode,
52 void *priv); 52 void *priv);
53static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id, 53static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id,
54 struct ias_value *value, void *priv); 54 struct ias_value *value, void *priv);
55static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self, 55static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self,
56 int timeout); 56 int timeout);
57static void ircomm_tty_watchdog_timer_expired(void *data); 57static void ircomm_tty_watchdog_timer_expired(void *data);
58 58
59static int ircomm_tty_state_idle(struct ircomm_tty_cb *self, 59static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
60 IRCOMM_TTY_EVENT event, 60 IRCOMM_TTY_EVENT event,
61 struct sk_buff *skb, 61 struct sk_buff *skb,
62 struct ircomm_tty_info *info); 62 struct ircomm_tty_info *info);
63static int ircomm_tty_state_search(struct ircomm_tty_cb *self, 63static int ircomm_tty_state_search(struct ircomm_tty_cb *self,
64 IRCOMM_TTY_EVENT event, 64 IRCOMM_TTY_EVENT event,
65 struct sk_buff *skb, 65 struct sk_buff *skb,
66 struct ircomm_tty_info *info); 66 struct ircomm_tty_info *info);
67static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self, 67static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self,
68 IRCOMM_TTY_EVENT event, 68 IRCOMM_TTY_EVENT event,
69 struct sk_buff *skb, 69 struct sk_buff *skb,
70 struct ircomm_tty_info *info); 70 struct ircomm_tty_info *info);
71static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self, 71static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self,
72 IRCOMM_TTY_EVENT event, 72 IRCOMM_TTY_EVENT event,
73 struct sk_buff *skb, 73 struct sk_buff *skb,
74 struct ircomm_tty_info *info); 74 struct ircomm_tty_info *info);
75static int ircomm_tty_state_setup(struct ircomm_tty_cb *self, 75static int ircomm_tty_state_setup(struct ircomm_tty_cb *self,
76 IRCOMM_TTY_EVENT event, 76 IRCOMM_TTY_EVENT event,
77 struct sk_buff *skb, 77 struct sk_buff *skb,
78 struct ircomm_tty_info *info); 78 struct ircomm_tty_info *info);
79static int ircomm_tty_state_ready(struct ircomm_tty_cb *self, 79static int ircomm_tty_state_ready(struct ircomm_tty_cb *self,
80 IRCOMM_TTY_EVENT event, 80 IRCOMM_TTY_EVENT event,
81 struct sk_buff *skb, 81 struct sk_buff *skb,
82 struct ircomm_tty_info *info); 82 struct ircomm_tty_info *info);
83 83
84char *ircomm_tty_state[] = { 84char *ircomm_tty_state[] = {
@@ -111,7 +111,7 @@ static char *ircomm_tty_event[] = {
111#endif /* CONFIG_IRDA_DEBUG */ 111#endif /* CONFIG_IRDA_DEBUG */
112 112
113static int (*state[])(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event, 113static int (*state[])(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event,
114 struct sk_buff *skb, struct ircomm_tty_info *info) = 114 struct sk_buff *skb, struct ircomm_tty_info *info) =
115{ 115{
116 ircomm_tty_state_idle, 116 ircomm_tty_state_idle,
117 ircomm_tty_state_search, 117 ircomm_tty_state_search,
@@ -125,7 +125,7 @@ static int (*state[])(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event,
125 * Function ircomm_tty_attach_cable (driver) 125 * Function ircomm_tty_attach_cable (driver)
126 * 126 *
127 * Try to attach cable (IrCOMM link). This function will only return 127 * Try to attach cable (IrCOMM link). This function will only return
128 * when the link has been connected, or if an error condition occurs. 128 * when the link has been connected, or if an error condition occurs.
129 * If success, the return value is the resulting service type. 129 * If success, the return value is the resulting service type.
130 */ 130 */
131int ircomm_tty_attach_cable(struct ircomm_tty_cb *self) 131int ircomm_tty_attach_cable(struct ircomm_tty_cb *self)
@@ -135,7 +135,7 @@ int ircomm_tty_attach_cable(struct ircomm_tty_cb *self)
135 IRDA_ASSERT(self != NULL, return -1;); 135 IRDA_ASSERT(self != NULL, return -1;);
136 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); 136 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
137 137
138 /* Check if somebody has already connected to us */ 138 /* Check if somebody has already connected to us */
139 if (ircomm_is_connected(self->ircomm)) { 139 if (ircomm_is_connected(self->ircomm)) {
140 IRDA_DEBUG(0, "%s(), already connected!\n", __FUNCTION__ ); 140 IRDA_DEBUG(0, "%s(), already connected!\n", __FUNCTION__ );
141 return 0; 141 return 0;
@@ -177,7 +177,7 @@ void ircomm_tty_detach_cable(struct ircomm_tty_cb *self)
177 self->skey = NULL; 177 self->skey = NULL;
178 } 178 }
179 179
180 if (self->iriap) { 180 if (self->iriap) {
181 iriap_close(self->iriap); 181 iriap_close(self->iriap);
182 self->iriap = NULL; 182 self->iriap = NULL;
183 } 183 }
@@ -212,7 +212,7 @@ static void ircomm_tty_ias_register(struct ircomm_tty_cb *self)
212 212
213 IRDA_ASSERT(self != NULL, return;); 213 IRDA_ASSERT(self != NULL, return;);
214 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); 214 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
215 215
216 /* Compute hint bits based on service */ 216 /* Compute hint bits based on service */
217 hints = irlmp_service_to_hint(S_COMM); 217 hints = irlmp_service_to_hint(S_COMM);
218 if (self->service_type & IRCOMM_3_WIRE_RAW) 218 if (self->service_type & IRCOMM_3_WIRE_RAW)
@@ -234,19 +234,19 @@ static void ircomm_tty_ias_register(struct ircomm_tty_cb *self)
234 if (self->service_type & IRCOMM_3_WIRE_RAW) { 234 if (self->service_type & IRCOMM_3_WIRE_RAW) {
235 /* Register IrLPT with LM-IAS */ 235 /* Register IrLPT with LM-IAS */
236 self->obj = irias_new_object("IrLPT", IAS_IRLPT_ID); 236 self->obj = irias_new_object("IrLPT", IAS_IRLPT_ID);
237 irias_add_integer_attrib(self->obj, "IrDA:IrLMP:LsapSel", 237 irias_add_integer_attrib(self->obj, "IrDA:IrLMP:LsapSel",
238 self->slsap_sel, IAS_KERNEL_ATTR); 238 self->slsap_sel, IAS_KERNEL_ATTR);
239 } else { 239 } else {
240 /* Register IrCOMM with LM-IAS */ 240 /* Register IrCOMM with LM-IAS */
241 self->obj = irias_new_object("IrDA:IrCOMM", IAS_IRCOMM_ID); 241 self->obj = irias_new_object("IrDA:IrCOMM", IAS_IRCOMM_ID);
242 irias_add_integer_attrib(self->obj, "IrDA:TinyTP:LsapSel", 242 irias_add_integer_attrib(self->obj, "IrDA:TinyTP:LsapSel",
243 self->slsap_sel, IAS_KERNEL_ATTR); 243 self->slsap_sel, IAS_KERNEL_ATTR);
244 244
245 /* Code the parameters into the buffer */ 245 /* Code the parameters into the buffer */
246 irda_param_pack(oct_seq, "bbbbbb", 246 irda_param_pack(oct_seq, "bbbbbb",
247 IRCOMM_SERVICE_TYPE, 1, self->service_type, 247 IRCOMM_SERVICE_TYPE, 1, self->service_type,
248 IRCOMM_PORT_TYPE, 1, IRCOMM_SERIAL); 248 IRCOMM_PORT_TYPE, 1, IRCOMM_SERIAL);
249 249
250 /* Register parameters with LM-IAS */ 250 /* Register parameters with LM-IAS */
251 irias_add_octseq_attrib(self->obj, "Parameters", oct_seq, 6, 251 irias_add_octseq_attrib(self->obj, "Parameters", oct_seq, 6,
252 IAS_KERNEL_ATTR); 252 IAS_KERNEL_ATTR);
@@ -302,23 +302,23 @@ int ircomm_tty_send_initial_parameters(struct ircomm_tty_cb *self)
302 IRDA_ASSERT(self != NULL, return -1;); 302 IRDA_ASSERT(self != NULL, return -1;);
303 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); 303 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
304 304
305 if (self->service_type & IRCOMM_3_WIRE_RAW) 305 if (self->service_type & IRCOMM_3_WIRE_RAW)
306 return 0; 306 return 0;
307 307
308 /* 308 /*
309 * Set default values, but only if the application for some reason 309 * Set default values, but only if the application for some reason
310 * haven't set them already 310 * haven't set them already
311 */ 311 */
312 IRDA_DEBUG(2, "%s(), data-rate = %d\n", __FUNCTION__ , 312 IRDA_DEBUG(2, "%s(), data-rate = %d\n", __FUNCTION__ ,
313 self->settings.data_rate); 313 self->settings.data_rate);
314 if (!self->settings.data_rate) 314 if (!self->settings.data_rate)
315 self->settings.data_rate = 9600; 315 self->settings.data_rate = 9600;
316 IRDA_DEBUG(2, "%s(), data-format = %d\n", __FUNCTION__ , 316 IRDA_DEBUG(2, "%s(), data-format = %d\n", __FUNCTION__ ,
317 self->settings.data_format); 317 self->settings.data_format);
318 if (!self->settings.data_format) 318 if (!self->settings.data_format)
319 self->settings.data_format = IRCOMM_WSIZE_8; /* 8N1 */ 319 self->settings.data_format = IRCOMM_WSIZE_8; /* 8N1 */
320 320
321 IRDA_DEBUG(2, "%s(), flow-control = %d\n", __FUNCTION__ , 321 IRDA_DEBUG(2, "%s(), flow-control = %d\n", __FUNCTION__ ,
322 self->settings.flow_control); 322 self->settings.flow_control);
323 /*self->settings.flow_control = IRCOMM_RTS_CTS_IN|IRCOMM_RTS_CTS_OUT;*/ 323 /*self->settings.flow_control = IRCOMM_RTS_CTS_IN|IRCOMM_RTS_CTS_OUT;*/
324 324
@@ -330,7 +330,7 @@ int ircomm_tty_send_initial_parameters(struct ircomm_tty_cb *self)
330 ircomm_param_request(self, IRCOMM_SERVICE_TYPE, FALSE); 330 ircomm_param_request(self, IRCOMM_SERVICE_TYPE, FALSE);
331 ircomm_param_request(self, IRCOMM_DATA_RATE, FALSE); 331 ircomm_param_request(self, IRCOMM_DATA_RATE, FALSE);
332 ircomm_param_request(self, IRCOMM_DATA_FORMAT, FALSE); 332 ircomm_param_request(self, IRCOMM_DATA_FORMAT, FALSE);
333 333
334 /* For a 3 wire service, we just flush the last parameter and return */ 334 /* For a 3 wire service, we just flush the last parameter and return */
335 if (self->settings.service_type == IRCOMM_3_WIRE) { 335 if (self->settings.service_type == IRCOMM_3_WIRE) {
336 ircomm_param_request(self, IRCOMM_FLOW_CONTROL, TRUE); 336 ircomm_param_request(self, IRCOMM_FLOW_CONTROL, TRUE);
@@ -342,10 +342,10 @@ int ircomm_tty_send_initial_parameters(struct ircomm_tty_cb *self)
342#if 0 342#if 0
343 ircomm_param_request(self, IRCOMM_XON_XOFF, FALSE); 343 ircomm_param_request(self, IRCOMM_XON_XOFF, FALSE);
344 ircomm_param_request(self, IRCOMM_ENQ_ACK, FALSE); 344 ircomm_param_request(self, IRCOMM_ENQ_ACK, FALSE);
345#endif 345#endif
346 /* Notify peer that we are ready to receive data */ 346 /* Notify peer that we are ready to receive data */
347 ircomm_param_request(self, IRCOMM_DTE, TRUE); 347 ircomm_param_request(self, IRCOMM_DTE, TRUE);
348 348
349 return 0; 349 return 0;
350} 350}
351 351
@@ -388,8 +388,8 @@ static void ircomm_tty_discovery_indication(discinfo_t *discovery,
388 self = (struct ircomm_tty_cb *) hashbin_get_first(ircomm_tty); 388 self = (struct ircomm_tty_cb *) hashbin_get_first(ircomm_tty);
389 while (self != NULL) { 389 while (self != NULL) {
390 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); 390 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
391 391
392 ircomm_tty_do_event(self, IRCOMM_TTY_DISCOVERY_INDICATION, 392 ircomm_tty_do_event(self, IRCOMM_TTY_DISCOVERY_INDICATION,
393 NULL, &info); 393 NULL, &info);
394 394
395 self = (struct ircomm_tty_cb *) hashbin_get_next(ircomm_tty); 395 self = (struct ircomm_tty_cb *) hashbin_get_next(ircomm_tty);
@@ -402,7 +402,7 @@ static void ircomm_tty_discovery_indication(discinfo_t *discovery,
402 * Link disconnected 402 * Link disconnected
403 * 403 *
404 */ 404 */
405void ircomm_tty_disconnect_indication(void *instance, void *sap, 405void ircomm_tty_disconnect_indication(void *instance, void *sap,
406 LM_REASON reason, 406 LM_REASON reason,
407 struct sk_buff *skb) 407 struct sk_buff *skb)
408{ 408{
@@ -422,7 +422,7 @@ void ircomm_tty_disconnect_indication(void *instance, void *sap,
422 /* Stop data transfers */ 422 /* Stop data transfers */
423 self->tty->hw_stopped = 1; 423 self->tty->hw_stopped = 1;
424 424
425 ircomm_tty_do_event(self, IRCOMM_TTY_DISCONNECT_INDICATION, NULL, 425 ircomm_tty_do_event(self, IRCOMM_TTY_DISCONNECT_INDICATION, NULL,
426 NULL); 426 NULL);
427} 427}
428 428
@@ -432,8 +432,8 @@ void ircomm_tty_disconnect_indication(void *instance, void *sap,
432 * Got result from the IAS query we make 432 * Got result from the IAS query we make
433 * 433 *
434 */ 434 */
435static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id, 435static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id,
436 struct ias_value *value, 436 struct ias_value *value,
437 void *priv) 437 void *priv)
438{ 438{
439 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) priv; 439 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) priv;
@@ -454,18 +454,18 @@ static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id,
454 } 454 }
455 455
456 switch (value->type) { 456 switch (value->type) {
457 case IAS_OCT_SEQ: 457 case IAS_OCT_SEQ:
458 IRDA_DEBUG(2, "%s(), got octet sequence\n", __FUNCTION__ ); 458 IRDA_DEBUG(2, "%s(), got octet sequence\n", __FUNCTION__ );
459 459
460 irda_param_extract_all(self, value->t.oct_seq, value->len, 460 irda_param_extract_all(self, value->t.oct_seq, value->len,
461 &ircomm_param_info); 461 &ircomm_param_info);
462 462
463 ircomm_tty_do_event(self, IRCOMM_TTY_GOT_PARAMETERS, NULL, 463 ircomm_tty_do_event(self, IRCOMM_TTY_GOT_PARAMETERS, NULL,
464 NULL); 464 NULL);
465 break; 465 break;
466 case IAS_INTEGER: 466 case IAS_INTEGER:
467 /* Got LSAP selector */ 467 /* Got LSAP selector */
468 IRDA_DEBUG(2, "%s(), got lsapsel = %d\n", __FUNCTION__ , 468 IRDA_DEBUG(2, "%s(), got lsapsel = %d\n", __FUNCTION__ ,
469 value->t.integer); 469 value->t.integer);
470 470
471 if (value->t.integer == -1) { 471 if (value->t.integer == -1) {
@@ -491,10 +491,10 @@ static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id,
491 * Connection confirmed 491 * Connection confirmed
492 * 492 *
493 */ 493 */
494void ircomm_tty_connect_confirm(void *instance, void *sap, 494void ircomm_tty_connect_confirm(void *instance, void *sap,
495 struct qos_info *qos, 495 struct qos_info *qos,
496 __u32 max_data_size, 496 __u32 max_data_size,
497 __u8 max_header_size, 497 __u8 max_header_size,
498 struct sk_buff *skb) 498 struct sk_buff *skb)
499{ 499{
500 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; 500 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
@@ -515,16 +515,16 @@ void ircomm_tty_connect_confirm(void *instance, void *sap,
515} 515}
516 516
517/* 517/*
518 * Function ircomm_tty_connect_indication (instance, sap, qos, max_sdu_size, 518 * Function ircomm_tty_connect_indication (instance, sap, qos, max_sdu_size,
519 * skb) 519 * skb)
520 * 520 *
521 * we are discovered and being requested to connect by remote device ! 521 * we are discovered and being requested to connect by remote device !
522 * 522 *
523 */ 523 */
524void ircomm_tty_connect_indication(void *instance, void *sap, 524void ircomm_tty_connect_indication(void *instance, void *sap,
525 struct qos_info *qos, 525 struct qos_info *qos,
526 __u32 max_data_size, 526 __u32 max_data_size,
527 __u8 max_header_size, 527 __u8 max_header_size,
528 struct sk_buff *skb) 528 struct sk_buff *skb)
529{ 529{
530 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; 530 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
@@ -542,8 +542,8 @@ void ircomm_tty_connect_indication(void *instance, void *sap,
542 542
543 clen = skb->data[0]; 543 clen = skb->data[0];
544 if (clen) 544 if (clen)
545 irda_param_extract_all(self, skb->data+1, 545 irda_param_extract_all(self, skb->data+1,
546 IRDA_MIN(skb->len, clen), 546 IRDA_MIN(skb->len, clen),
547 &ircomm_param_info); 547 &ircomm_param_info);
548 548
549 ircomm_tty_do_event(self, IRCOMM_TTY_CONNECT_INDICATION, NULL, NULL); 549 ircomm_tty_do_event(self, IRCOMM_TTY_CONNECT_INDICATION, NULL, NULL);
@@ -566,14 +566,14 @@ void ircomm_tty_link_established(struct ircomm_tty_cb *self)
566 566
567 if (!self->tty) 567 if (!self->tty)
568 return; 568 return;
569 569
570 del_timer(&self->watchdog_timer); 570 del_timer(&self->watchdog_timer);
571 571
572 /* 572 /*
573 * IrCOMM link is now up, and if we are not using hardware 573 * IrCOMM link is now up, and if we are not using hardware
574 * flow-control, then declare the hardware as running. Otherwise we 574 * flow-control, then declare the hardware as running. Otherwise we
575 * will have to wait for the peer device (DCE) to raise the CTS 575 * will have to wait for the peer device (DCE) to raise the CTS
576 * line. 576 * line.
577 */ 577 */
578 if ((self->flags & ASYNC_CTS_FLOW) && ((self->settings.dce & IRCOMM_CTS) == 0)) { 578 if ((self->flags & ASYNC_CTS_FLOW) && ((self->settings.dce & IRCOMM_CTS) == 0)) {
579 IRDA_DEBUG(0, "%s(), waiting for CTS ...\n", __FUNCTION__ ); 579 IRDA_DEBUG(0, "%s(), waiting for CTS ...\n", __FUNCTION__ );
@@ -582,7 +582,7 @@ void ircomm_tty_link_established(struct ircomm_tty_cb *self)
582 IRDA_DEBUG(1, "%s(), starting hardware!\n", __FUNCTION__ ); 582 IRDA_DEBUG(1, "%s(), starting hardware!\n", __FUNCTION__ );
583 583
584 self->tty->hw_stopped = 0; 584 self->tty->hw_stopped = 0;
585 585
586 /* Wake up processes blocked on open */ 586 /* Wake up processes blocked on open */
587 wake_up_interruptible(&self->open_wait); 587 wake_up_interruptible(&self->open_wait);
588 } 588 }
@@ -593,8 +593,8 @@ void ircomm_tty_link_established(struct ircomm_tty_cb *self)
593/* 593/*
594 * Function ircomm_tty_start_watchdog_timer (self, timeout) 594 * Function ircomm_tty_start_watchdog_timer (self, timeout)
595 * 595 *
596 * Start the watchdog timer. This timer is used to make sure that any 596 * Start the watchdog timer. This timer is used to make sure that any
597 * connection attempt is successful, and if not, we will retry after 597 * connection attempt is successful, and if not, we will retry after
598 * the timeout 598 * the timeout
599 */ 599 */
600static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self, 600static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self,
@@ -616,7 +616,7 @@ static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self,
616static void ircomm_tty_watchdog_timer_expired(void *data) 616static void ircomm_tty_watchdog_timer_expired(void *data)
617{ 617{
618 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) data; 618 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) data;
619 619
620 IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); 620 IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
621 621
622 IRDA_ASSERT(self != NULL, return;); 622 IRDA_ASSERT(self != NULL, return;);
@@ -633,14 +633,14 @@ static void ircomm_tty_watchdog_timer_expired(void *data)
633 * 633 *
634 */ 634 */
635int ircomm_tty_do_event(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event, 635int ircomm_tty_do_event(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event,
636 struct sk_buff *skb, struct ircomm_tty_info *info) 636 struct sk_buff *skb, struct ircomm_tty_info *info)
637{ 637{
638 IRDA_ASSERT(self != NULL, return -1;); 638 IRDA_ASSERT(self != NULL, return -1;);
639 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); 639 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
640 640
641 IRDA_DEBUG(2, "%s: state=%s, event=%s\n", __FUNCTION__ , 641 IRDA_DEBUG(2, "%s: state=%s, event=%s\n", __FUNCTION__ ,
642 ircomm_tty_state[self->state], ircomm_tty_event[event]); 642 ircomm_tty_state[self->state], ircomm_tty_event[event]);
643 643
644 return (*state[self->state])(self, event, skb, info); 644 return (*state[self->state])(self, event, skb, info);
645} 645}
646 646
@@ -656,7 +656,7 @@ static inline void ircomm_tty_next_state(struct ircomm_tty_cb *self, IRCOMM_TTY_
656 IRDA_ASSERT(self != NULL, return;); 656 IRDA_ASSERT(self != NULL, return;);
657 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); 657 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
658 658
659 IRDA_DEBUG(2, "%s: next state=%s, service type=%d\n", __FUNCTION__ , 659 IRDA_DEBUG(2, "%s: next state=%s, service type=%d\n", __FUNCTION__ ,
660 ircomm_tty_state[self->state], self->service_type); 660 ircomm_tty_state[self->state], self->service_type);
661 */ 661 */
662 self->state = state; 662 self->state = state;
@@ -668,9 +668,9 @@ static inline void ircomm_tty_next_state(struct ircomm_tty_cb *self, IRCOMM_TTY_
668 * Just hanging around 668 * Just hanging around
669 * 669 *
670 */ 670 */
671static int ircomm_tty_state_idle(struct ircomm_tty_cb *self, 671static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
672 IRCOMM_TTY_EVENT event, 672 IRCOMM_TTY_EVENT event,
673 struct sk_buff *skb, 673 struct sk_buff *skb,
674 struct ircomm_tty_info *info) 674 struct ircomm_tty_info *info)
675{ 675{
676 int ret = 0; 676 int ret = 0;
@@ -679,10 +679,10 @@ static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
679 ircomm_tty_state[self->state], ircomm_tty_event[event]); 679 ircomm_tty_state[self->state], ircomm_tty_event[event]);
680 switch (event) { 680 switch (event) {
681 case IRCOMM_TTY_ATTACH_CABLE: 681 case IRCOMM_TTY_ATTACH_CABLE:
682 /* Try to discover any remote devices */ 682 /* Try to discover any remote devices */
683 ircomm_tty_start_watchdog_timer(self, 3*HZ); 683 ircomm_tty_start_watchdog_timer(self, 3*HZ);
684 ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH); 684 ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH);
685 685
686 irlmp_discovery_request(DISCOVERY_DEFAULT_SLOTS); 686 irlmp_discovery_request(DISCOVERY_DEFAULT_SLOTS);
687 break; 687 break;
688 case IRCOMM_TTY_DISCOVERY_INDICATION: 688 case IRCOMM_TTY_DISCOVERY_INDICATION:
@@ -701,7 +701,7 @@ static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
701 iriap_getvaluebyclass_request(self->iriap, 701 iriap_getvaluebyclass_request(self->iriap,
702 self->saddr, self->daddr, 702 self->saddr, self->daddr,
703 "IrDA:IrCOMM", "Parameters"); 703 "IrDA:IrCOMM", "Parameters");
704 704
705 ircomm_tty_start_watchdog_timer(self, 3*HZ); 705 ircomm_tty_start_watchdog_timer(self, 3*HZ);
706 ircomm_tty_next_state(self, IRCOMM_TTY_QUERY_PARAMETERS); 706 ircomm_tty_next_state(self, IRCOMM_TTY_QUERY_PARAMETERS);
707 break; 707 break;
@@ -732,9 +732,9 @@ static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
732 * Trying to discover an IrCOMM device 732 * Trying to discover an IrCOMM device
733 * 733 *
734 */ 734 */
735static int ircomm_tty_state_search(struct ircomm_tty_cb *self, 735static int ircomm_tty_state_search(struct ircomm_tty_cb *self,
736 IRCOMM_TTY_EVENT event, 736 IRCOMM_TTY_EVENT event,
737 struct sk_buff *skb, 737 struct sk_buff *skb,
738 struct ircomm_tty_info *info) 738 struct ircomm_tty_info *info)
739{ 739{
740 int ret = 0; 740 int ret = 0;
@@ -752,19 +752,19 @@ static int ircomm_tty_state_search(struct ircomm_tty_cb *self,
752 __FUNCTION__); 752 __FUNCTION__);
753 return -EBUSY; 753 return -EBUSY;
754 } 754 }
755 755
756 self->iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self, 756 self->iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self,
757 ircomm_tty_getvalue_confirm); 757 ircomm_tty_getvalue_confirm);
758 758
759 if (self->service_type == IRCOMM_3_WIRE_RAW) { 759 if (self->service_type == IRCOMM_3_WIRE_RAW) {
760 iriap_getvaluebyclass_request(self->iriap, self->saddr, 760 iriap_getvaluebyclass_request(self->iriap, self->saddr,
761 self->daddr, "IrLPT", 761 self->daddr, "IrLPT",
762 "IrDA:IrLMP:LsapSel"); 762 "IrDA:IrLMP:LsapSel");
763 ircomm_tty_next_state(self, IRCOMM_TTY_QUERY_LSAP_SEL); 763 ircomm_tty_next_state(self, IRCOMM_TTY_QUERY_LSAP_SEL);
764 } else { 764 } else {
765 iriap_getvaluebyclass_request(self->iriap, self->saddr, 765 iriap_getvaluebyclass_request(self->iriap, self->saddr,
766 self->daddr, 766 self->daddr,
767 "IrDA:IrCOMM", 767 "IrDA:IrCOMM",
768 "Parameters"); 768 "Parameters");
769 769
770 ircomm_tty_next_state(self, IRCOMM_TTY_QUERY_PARAMETERS); 770 ircomm_tty_next_state(self, IRCOMM_TTY_QUERY_PARAMETERS);
@@ -783,7 +783,7 @@ static int ircomm_tty_state_search(struct ircomm_tty_cb *self,
783#if 1 783#if 1
784 /* Give up */ 784 /* Give up */
785#else 785#else
786 /* Try to discover any remote devices */ 786 /* Try to discover any remote devices */
787 ircomm_tty_start_watchdog_timer(self, 3*HZ); 787 ircomm_tty_start_watchdog_timer(self, 3*HZ);
788 irlmp_discovery_request(DISCOVERY_DEFAULT_SLOTS); 788 irlmp_discovery_request(DISCOVERY_DEFAULT_SLOTS);
789#endif 789#endif
@@ -805,9 +805,9 @@ static int ircomm_tty_state_search(struct ircomm_tty_cb *self,
805 * Querying the remote LM-IAS for IrCOMM parameters 805 * Querying the remote LM-IAS for IrCOMM parameters
806 * 806 *
807 */ 807 */
808static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self, 808static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self,
809 IRCOMM_TTY_EVENT event, 809 IRCOMM_TTY_EVENT event,
810 struct sk_buff *skb, 810 struct sk_buff *skb,
811 struct ircomm_tty_info *info) 811 struct ircomm_tty_info *info)
812{ 812{
813 int ret = 0; 813 int ret = 0;
@@ -822,12 +822,12 @@ static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self,
822 __FUNCTION__); 822 __FUNCTION__);
823 return -EBUSY; 823 return -EBUSY;
824 } 824 }
825 825
826 self->iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self, 826 self->iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self,
827 ircomm_tty_getvalue_confirm); 827 ircomm_tty_getvalue_confirm);
828 828
829 iriap_getvaluebyclass_request(self->iriap, self->saddr, 829 iriap_getvaluebyclass_request(self->iriap, self->saddr,
830 self->daddr, "IrDA:IrCOMM", 830 self->daddr, "IrDA:IrCOMM",
831 "IrDA:TinyTP:LsapSel"); 831 "IrDA:TinyTP:LsapSel");
832 832
833 ircomm_tty_start_watchdog_timer(self, 3*HZ); 833 ircomm_tty_start_watchdog_timer(self, 3*HZ);
@@ -836,7 +836,7 @@ static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self,
836 case IRCOMM_TTY_WD_TIMER_EXPIRED: 836 case IRCOMM_TTY_WD_TIMER_EXPIRED:
837 /* Go back to search mode */ 837 /* Go back to search mode */
838 ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH); 838 ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH);
839 ircomm_tty_start_watchdog_timer(self, 3*HZ); 839 ircomm_tty_start_watchdog_timer(self, 3*HZ);
840 break; 840 break;
841 case IRCOMM_TTY_CONNECT_INDICATION: 841 case IRCOMM_TTY_CONNECT_INDICATION:
842 del_timer(&self->watchdog_timer); 842 del_timer(&self->watchdog_timer);
@@ -863,9 +863,9 @@ static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self,
863 * Query remote LM-IAS for the LSAP selector which we can connect to 863 * Query remote LM-IAS for the LSAP selector which we can connect to
864 * 864 *
865 */ 865 */
866static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self, 866static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self,
867 IRCOMM_TTY_EVENT event, 867 IRCOMM_TTY_EVENT event,
868 struct sk_buff *skb, 868 struct sk_buff *skb,
869 struct ircomm_tty_info *info) 869 struct ircomm_tty_info *info)
870{ 870{
871 int ret = 0; 871 int ret = 0;
@@ -877,7 +877,7 @@ static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self,
877 case IRCOMM_TTY_GOT_LSAPSEL: 877 case IRCOMM_TTY_GOT_LSAPSEL:
878 /* Connect to remote device */ 878 /* Connect to remote device */
879 ret = ircomm_connect_request(self->ircomm, self->dlsap_sel, 879 ret = ircomm_connect_request(self->ircomm, self->dlsap_sel,
880 self->saddr, self->daddr, 880 self->saddr, self->daddr,
881 NULL, self->service_type); 881 NULL, self->service_type);
882 ircomm_tty_start_watchdog_timer(self, 3*HZ); 882 ircomm_tty_start_watchdog_timer(self, 3*HZ);
883 ircomm_tty_next_state(self, IRCOMM_TTY_SETUP); 883 ircomm_tty_next_state(self, IRCOMM_TTY_SETUP);
@@ -912,9 +912,9 @@ static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self,
912 * Trying to connect 912 * Trying to connect
913 * 913 *
914 */ 914 */
915static int ircomm_tty_state_setup(struct ircomm_tty_cb *self, 915static int ircomm_tty_state_setup(struct ircomm_tty_cb *self,
916 IRCOMM_TTY_EVENT event, 916 IRCOMM_TTY_EVENT event,
917 struct sk_buff *skb, 917 struct sk_buff *skb,
918 struct ircomm_tty_info *info) 918 struct ircomm_tty_info *info)
919{ 919{
920 int ret = 0; 920 int ret = 0;
@@ -926,10 +926,10 @@ static int ircomm_tty_state_setup(struct ircomm_tty_cb *self,
926 case IRCOMM_TTY_CONNECT_CONFIRM: 926 case IRCOMM_TTY_CONNECT_CONFIRM:
927 del_timer(&self->watchdog_timer); 927 del_timer(&self->watchdog_timer);
928 ircomm_tty_ias_unregister(self); 928 ircomm_tty_ias_unregister(self);
929 929
930 /* 930 /*
931 * Send initial parameters. This will also send out queued 931 * Send initial parameters. This will also send out queued
932 * parameters waiting for the connection to come up 932 * parameters waiting for the connection to come up
933 */ 933 */
934 ircomm_tty_send_initial_parameters(self); 934 ircomm_tty_send_initial_parameters(self);
935 ircomm_tty_link_established(self); 935 ircomm_tty_link_established(self);
@@ -938,7 +938,7 @@ static int ircomm_tty_state_setup(struct ircomm_tty_cb *self,
938 case IRCOMM_TTY_CONNECT_INDICATION: 938 case IRCOMM_TTY_CONNECT_INDICATION:
939 del_timer(&self->watchdog_timer); 939 del_timer(&self->watchdog_timer);
940 ircomm_tty_ias_unregister(self); 940 ircomm_tty_ias_unregister(self);
941 941
942 /* Accept connection */ 942 /* Accept connection */
943 ircomm_connect_response(self->ircomm, NULL); 943 ircomm_connect_response(self->ircomm, NULL);
944 ircomm_tty_next_state(self, IRCOMM_TTY_READY); 944 ircomm_tty_next_state(self, IRCOMM_TTY_READY);
@@ -966,9 +966,9 @@ static int ircomm_tty_state_setup(struct ircomm_tty_cb *self,
966 * IrCOMM is now connected 966 * IrCOMM is now connected
967 * 967 *
968 */ 968 */
969static int ircomm_tty_state_ready(struct ircomm_tty_cb *self, 969static int ircomm_tty_state_ready(struct ircomm_tty_cb *self,
970 IRCOMM_TTY_EVENT event, 970 IRCOMM_TTY_EVENT event,
971 struct sk_buff *skb, 971 struct sk_buff *skb,
972 struct ircomm_tty_info *info) 972 struct ircomm_tty_info *info)
973{ 973{
974 int ret = 0; 974 int ret = 0;
@@ -976,7 +976,7 @@ static int ircomm_tty_state_ready(struct ircomm_tty_cb *self,
976 switch (event) { 976 switch (event) {
977 case IRCOMM_TTY_DATA_REQUEST: 977 case IRCOMM_TTY_DATA_REQUEST:
978 ret = ircomm_data_request(self->ircomm, skb); 978 ret = ircomm_data_request(self->ircomm, skb);
979 break; 979 break;
980 case IRCOMM_TTY_DETACH_CABLE: 980 case IRCOMM_TTY_DETACH_CABLE:
981 ircomm_disconnect_request(self->ircomm, NULL); 981 ircomm_disconnect_request(self->ircomm, NULL);
982 ircomm_tty_next_state(self, IRCOMM_TTY_IDLE); 982 ircomm_tty_next_state(self, IRCOMM_TTY_IDLE);