diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-06-04 07:35:16 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-06-12 18:50:23 -0400 |
commit | a3cc9fcff84c4c8aaecda2420acd89a1418d57e9 (patch) | |
tree | 417fefbc96cdea1649186b483bab077c839a2f21 /net/irda/ircomm/ircomm_tty.c | |
parent | 718c4ca1f721be3ae67f9ff7d43b9a910e4a1ec3 (diff) |
TTY: ircomm, add tty_port
And use close/open_wait from there.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Samuel Ortiz <samuel@sortiz.org>
Cc: netdev@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/irda/ircomm/ircomm_tty.c')
-rw-r--r-- | net/irda/ircomm/ircomm_tty.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index 6b9d5a0e42f9..8eeaa8b7f4a6 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c | |||
@@ -278,7 +278,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, | |||
278 | */ | 278 | */ |
279 | 279 | ||
280 | retval = 0; | 280 | retval = 0; |
281 | add_wait_queue(&self->open_wait, &wait); | 281 | add_wait_queue(&self->port.open_wait, &wait); |
282 | 282 | ||
283 | IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n", | 283 | IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n", |
284 | __FILE__,__LINE__, tty->driver->name, self->open_count ); | 284 | __FILE__,__LINE__, tty->driver->name, self->open_count ); |
@@ -336,7 +336,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, | |||
336 | } | 336 | } |
337 | 337 | ||
338 | __set_current_state(TASK_RUNNING); | 338 | __set_current_state(TASK_RUNNING); |
339 | remove_wait_queue(&self->open_wait, &wait); | 339 | remove_wait_queue(&self->port.open_wait, &wait); |
340 | 340 | ||
341 | if (extra_count) { | 341 | if (extra_count) { |
342 | /* ++ is not atomic, so this should be protected - Jean II */ | 342 | /* ++ is not atomic, so this should be protected - Jean II */ |
@@ -381,6 +381,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp) | |||
381 | return -ENOMEM; | 381 | return -ENOMEM; |
382 | } | 382 | } |
383 | 383 | ||
384 | tty_port_init(&self->port); | ||
384 | self->magic = IRCOMM_TTY_MAGIC; | 385 | self->magic = IRCOMM_TTY_MAGIC; |
385 | self->flow = FLOW_STOP; | 386 | self->flow = FLOW_STOP; |
386 | 387 | ||
@@ -393,8 +394,6 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp) | |||
393 | 394 | ||
394 | /* Init some important stuff */ | 395 | /* Init some important stuff */ |
395 | init_timer(&self->watchdog_timer); | 396 | init_timer(&self->watchdog_timer); |
396 | init_waitqueue_head(&self->open_wait); | ||
397 | init_waitqueue_head(&self->close_wait); | ||
398 | spin_lock_init(&self->spinlock); | 397 | spin_lock_init(&self->spinlock); |
399 | 398 | ||
400 | /* | 399 | /* |
@@ -408,6 +407,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp) | |||
408 | tty->termios->c_oflag = 0; | 407 | tty->termios->c_oflag = 0; |
409 | 408 | ||
410 | /* Insert into hash */ | 409 | /* Insert into hash */ |
410 | /* FIXME there is a window from find to here */ | ||
411 | hashbin_insert(ircomm_tty, (irda_queue_t *) self, line, NULL); | 411 | hashbin_insert(ircomm_tty, (irda_queue_t *) self, line, NULL); |
412 | } | 412 | } |
413 | /* ++ is not atomic, so this should be protected - Jean II */ | 413 | /* ++ is not atomic, so this should be protected - Jean II */ |
@@ -438,7 +438,8 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp) | |||
438 | * probably better sleep uninterruptible? | 438 | * probably better sleep uninterruptible? |
439 | */ | 439 | */ |
440 | 440 | ||
441 | if (wait_event_interruptible(self->close_wait, !test_bit(ASYNC_B_CLOSING, &self->flags))) { | 441 | if (wait_event_interruptible(self->port.close_wait, |
442 | !test_bit(ASYNC_B_CLOSING, &self->flags))) { | ||
442 | IRDA_WARNING("%s - got signal while blocking on ASYNC_CLOSING!\n", | 443 | IRDA_WARNING("%s - got signal while blocking on ASYNC_CLOSING!\n", |
443 | __func__); | 444 | __func__); |
444 | return -ERESTARTSYS; | 445 | return -ERESTARTSYS; |
@@ -559,11 +560,11 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp) | |||
559 | if (self->blocked_open) { | 560 | if (self->blocked_open) { |
560 | if (self->close_delay) | 561 | if (self->close_delay) |
561 | schedule_timeout_interruptible(self->close_delay); | 562 | schedule_timeout_interruptible(self->close_delay); |
562 | wake_up_interruptible(&self->open_wait); | 563 | wake_up_interruptible(&self->port.open_wait); |
563 | } | 564 | } |
564 | 565 | ||
565 | self->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); | 566 | self->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); |
566 | wake_up_interruptible(&self->close_wait); | 567 | wake_up_interruptible(&self->port.close_wait); |
567 | } | 568 | } |
568 | 569 | ||
569 | /* | 570 | /* |
@@ -1011,7 +1012,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty) | |||
1011 | self->open_count = 0; | 1012 | self->open_count = 0; |
1012 | spin_unlock_irqrestore(&self->spinlock, flags); | 1013 | spin_unlock_irqrestore(&self->spinlock, flags); |
1013 | 1014 | ||
1014 | wake_up_interruptible(&self->open_wait); | 1015 | wake_up_interruptible(&self->port.open_wait); |
1015 | } | 1016 | } |
1016 | 1017 | ||
1017 | /* | 1018 | /* |
@@ -1084,7 +1085,7 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self) | |||
1084 | (status & IRCOMM_CD) ? "on" : "off"); | 1085 | (status & IRCOMM_CD) ? "on" : "off"); |
1085 | 1086 | ||
1086 | if (status & IRCOMM_CD) { | 1087 | if (status & IRCOMM_CD) { |
1087 | wake_up_interruptible(&self->open_wait); | 1088 | wake_up_interruptible(&self->port.open_wait); |
1088 | } else { | 1089 | } else { |
1089 | IRDA_DEBUG(2, | 1090 | IRDA_DEBUG(2, |
1090 | "%s(), Doing serial hangup..\n", __func__ ); | 1091 | "%s(), Doing serial hangup..\n", __func__ ); |
@@ -1103,7 +1104,7 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self) | |||
1103 | tty->hw_stopped = 0; | 1104 | tty->hw_stopped = 0; |
1104 | 1105 | ||
1105 | /* Wake up processes blocked on open */ | 1106 | /* Wake up processes blocked on open */ |
1106 | wake_up_interruptible(&self->open_wait); | 1107 | wake_up_interruptible(&self->port.open_wait); |
1107 | 1108 | ||
1108 | schedule_work(&self->tqueue); | 1109 | schedule_work(&self->tqueue); |
1109 | return; | 1110 | return; |