diff options
Diffstat (limited to 'net/irda/ircomm/ircomm_tty_attach.c')
| -rw-r--r-- | net/irda/ircomm/ircomm_tty_attach.c | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/net/irda/ircomm/ircomm_tty_attach.c b/net/irda/ircomm/ircomm_tty_attach.c index b65d66e0d817..edab393e0c82 100644 --- a/net/irda/ircomm/ircomm_tty_attach.c +++ b/net/irda/ircomm/ircomm_tty_attach.c | |||
| @@ -130,6 +130,8 @@ static int (*state[])(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event, | |||
| 130 | */ | 130 | */ |
| 131 | int ircomm_tty_attach_cable(struct ircomm_tty_cb *self) | 131 | int ircomm_tty_attach_cable(struct ircomm_tty_cb *self) |
| 132 | { | 132 | { |
| 133 | struct tty_struct *tty; | ||
| 134 | |||
| 133 | IRDA_DEBUG(0, "%s()\n", __func__ ); | 135 | IRDA_DEBUG(0, "%s()\n", __func__ ); |
| 134 | 136 | ||
| 135 | IRDA_ASSERT(self != NULL, return -1;); | 137 | IRDA_ASSERT(self != NULL, return -1;); |
| @@ -142,7 +144,11 @@ int ircomm_tty_attach_cable(struct ircomm_tty_cb *self) | |||
| 142 | } | 144 | } |
| 143 | 145 | ||
| 144 | /* Make sure nobody tries to write before the link is up */ | 146 | /* Make sure nobody tries to write before the link is up */ |
| 145 | self->tty->hw_stopped = 1; | 147 | tty = tty_port_tty_get(&self->port); |
| 148 | if (tty) { | ||
| 149 | tty->hw_stopped = 1; | ||
| 150 | tty_kref_put(tty); | ||
| 151 | } | ||
| 146 | 152 | ||
| 147 | ircomm_tty_ias_register(self); | 153 | ircomm_tty_ias_register(self); |
| 148 | 154 | ||
| @@ -398,23 +404,26 @@ void ircomm_tty_disconnect_indication(void *instance, void *sap, | |||
| 398 | struct sk_buff *skb) | 404 | struct sk_buff *skb) |
| 399 | { | 405 | { |
| 400 | struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; | 406 | struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; |
| 407 | struct tty_struct *tty; | ||
| 401 | 408 | ||
| 402 | IRDA_DEBUG(2, "%s()\n", __func__ ); | 409 | IRDA_DEBUG(2, "%s()\n", __func__ ); |
| 403 | 410 | ||
| 404 | IRDA_ASSERT(self != NULL, return;); | 411 | IRDA_ASSERT(self != NULL, return;); |
| 405 | IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); | 412 | IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); |
| 406 | 413 | ||
| 407 | if (!self->tty) | 414 | tty = tty_port_tty_get(&self->port); |
| 415 | if (!tty) | ||
| 408 | return; | 416 | return; |
| 409 | 417 | ||
| 410 | /* This will stop control data transfers */ | 418 | /* This will stop control data transfers */ |
| 411 | self->flow = FLOW_STOP; | 419 | self->flow = FLOW_STOP; |
| 412 | 420 | ||
| 413 | /* Stop data transfers */ | 421 | /* Stop data transfers */ |
| 414 | self->tty->hw_stopped = 1; | 422 | tty->hw_stopped = 1; |
| 415 | 423 | ||
| 416 | ircomm_tty_do_event(self, IRCOMM_TTY_DISCONNECT_INDICATION, NULL, | 424 | ircomm_tty_do_event(self, IRCOMM_TTY_DISCONNECT_INDICATION, NULL, |
| 417 | NULL); | 425 | NULL); |
| 426 | tty_kref_put(tty); | ||
| 418 | } | 427 | } |
| 419 | 428 | ||
| 420 | /* | 429 | /* |
| @@ -550,12 +559,15 @@ void ircomm_tty_connect_indication(void *instance, void *sap, | |||
| 550 | */ | 559 | */ |
| 551 | void ircomm_tty_link_established(struct ircomm_tty_cb *self) | 560 | void ircomm_tty_link_established(struct ircomm_tty_cb *self) |
| 552 | { | 561 | { |
| 562 | struct tty_struct *tty; | ||
| 563 | |||
| 553 | IRDA_DEBUG(2, "%s()\n", __func__ ); | 564 | IRDA_DEBUG(2, "%s()\n", __func__ ); |
| 554 | 565 | ||
| 555 | IRDA_ASSERT(self != NULL, return;); | 566 | IRDA_ASSERT(self != NULL, return;); |
| 556 | IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); | 567 | IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); |
| 557 | 568 | ||
| 558 | if (!self->tty) | 569 | tty = tty_port_tty_get(&self->port); |
| 570 | if (!tty) | ||
| 559 | return; | 571 | return; |
| 560 | 572 | ||
| 561 | del_timer(&self->watchdog_timer); | 573 | del_timer(&self->watchdog_timer); |
| @@ -566,19 +578,22 @@ void ircomm_tty_link_established(struct ircomm_tty_cb *self) | |||
| 566 | * will have to wait for the peer device (DCE) to raise the CTS | 578 | * will have to wait for the peer device (DCE) to raise the CTS |
| 567 | * line. | 579 | * line. |
| 568 | */ | 580 | */ |
| 569 | if ((self->flags & ASYNC_CTS_FLOW) && ((self->settings.dce & IRCOMM_CTS) == 0)) { | 581 | if (tty_port_cts_enabled(&self->port) && |
| 582 | ((self->settings.dce & IRCOMM_CTS) == 0)) { | ||
| 570 | IRDA_DEBUG(0, "%s(), waiting for CTS ...\n", __func__ ); | 583 | IRDA_DEBUG(0, "%s(), waiting for CTS ...\n", __func__ ); |
| 571 | return; | 584 | goto put; |
| 572 | } else { | 585 | } else { |
| 573 | IRDA_DEBUG(1, "%s(), starting hardware!\n", __func__ ); | 586 | IRDA_DEBUG(1, "%s(), starting hardware!\n", __func__ ); |
| 574 | 587 | ||
| 575 | self->tty->hw_stopped = 0; | 588 | tty->hw_stopped = 0; |
| 576 | 589 | ||
| 577 | /* Wake up processes blocked on open */ | 590 | /* Wake up processes blocked on open */ |
| 578 | wake_up_interruptible(&self->open_wait); | 591 | wake_up_interruptible(&self->port.open_wait); |
| 579 | } | 592 | } |
| 580 | 593 | ||
| 581 | schedule_work(&self->tqueue); | 594 | schedule_work(&self->tqueue); |
| 595 | put: | ||
| 596 | tty_kref_put(tty); | ||
| 582 | } | 597 | } |
| 583 | 598 | ||
| 584 | /* | 599 | /* |
| @@ -977,14 +992,17 @@ static int ircomm_tty_state_ready(struct ircomm_tty_cb *self, | |||
| 977 | ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH); | 992 | ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH); |
| 978 | ircomm_tty_start_watchdog_timer(self, 3*HZ); | 993 | ircomm_tty_start_watchdog_timer(self, 3*HZ); |
| 979 | 994 | ||
| 980 | if (self->flags & ASYNC_CHECK_CD) { | 995 | if (self->port.flags & ASYNC_CHECK_CD) { |
| 981 | /* Drop carrier */ | 996 | /* Drop carrier */ |
| 982 | self->settings.dce = IRCOMM_DELTA_CD; | 997 | self->settings.dce = IRCOMM_DELTA_CD; |
| 983 | ircomm_tty_check_modem_status(self); | 998 | ircomm_tty_check_modem_status(self); |
| 984 | } else { | 999 | } else { |
| 1000 | struct tty_struct *tty = tty_port_tty_get(&self->port); | ||
| 985 | IRDA_DEBUG(0, "%s(), hanging up!\n", __func__ ); | 1001 | IRDA_DEBUG(0, "%s(), hanging up!\n", __func__ ); |
| 986 | if (self->tty) | 1002 | if (tty) { |
| 987 | tty_hangup(self->tty); | 1003 | tty_hangup(tty); |
| 1004 | tty_kref_put(tty); | ||
| 1005 | } | ||
| 988 | } | 1006 | } |
| 989 | break; | 1007 | break; |
| 990 | default: | 1008 | default: |
