aboutsummaryrefslogtreecommitdiffstats
path: root/net/irda/ircomm
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-06-04 07:35:25 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-06-12 18:50:24 -0400
commitc0e7865003ae9929f32bcb7277f591115fa242b7 (patch)
treea421df435f0a46a33dd89401f6a85c30c2a4c701 /net/irda/ircomm
parenta1e844036af9cb0d87e878a4f90ce64713c76e5a (diff)
TTY: ircomm, use tty_port_close_start helper
Again, the code is identical, so leverage the helper code. 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')
-rw-r--r--net/irda/ircomm/ircomm_tty.c48
1 files changed, 1 insertions, 47 deletions
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index cfe352dfb48..4e35b45c1c7 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -509,64 +509,18 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
509{ 509{
510 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; 510 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
511 struct tty_port *port = &self->port; 511 struct tty_port *port = &self->port;
512 unsigned long flags;
513 512
514 IRDA_DEBUG(0, "%s()\n", __func__ ); 513 IRDA_DEBUG(0, "%s()\n", __func__ );
515 514
516 IRDA_ASSERT(self != NULL, return;); 515 IRDA_ASSERT(self != NULL, return;);
517 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); 516 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
518 517
519 spin_lock_irqsave(&port->lock, flags); 518 if (tty_port_close_start(port, tty, filp) == 0)
520
521 if (tty_hung_up_p(filp)) {
522 spin_unlock_irqrestore(&port->lock, flags);
523
524 IRDA_DEBUG(0, "%s(), returning 1\n", __func__ );
525 return;
526 }
527
528 if ((tty->count == 1) && (port->count != 1)) {
529 /*
530 * Uh, oh. tty->count is 1, which means that the tty
531 * structure will be freed. state->count should always
532 * be one in these conditions. If it's greater than
533 * one, we've got real problems, since it means the
534 * serial port won't be shutdown.
535 */
536 IRDA_DEBUG(0, "%s(), bad serial port count; "
537 "tty->count is 1, state->count is %d\n", __func__ ,
538 port->count);
539 port->count = 1;
540 }
541
542 if (--port->count < 0) {
543 IRDA_ERROR("%s(), bad serial port count for ttys%d: %d\n",
544 __func__, self->line, port->count);
545 port->count = 0;
546 }
547 if (port->count) {
548 spin_unlock_irqrestore(&port->lock, flags);
549
550 IRDA_DEBUG(0, "%s(), open count > 0\n", __func__ );
551 return; 519 return;
552 }
553
554 set_bit(ASYNCB_CLOSING, &port->flags);
555
556 spin_unlock_irqrestore(&port->lock, flags);
557
558 /*
559 * Now we wait for the transmit buffer to clear; and we notify
560 * the line discipline to only process XON/XOFF characters.
561 */
562 tty->closing = 1;
563 if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
564 tty_wait_until_sent_from_close(tty, port->closing_wait);
565 520
566 ircomm_tty_shutdown(self); 521 ircomm_tty_shutdown(self);
567 522
568 tty_driver_flush_buffer(tty); 523 tty_driver_flush_buffer(tty);
569 tty_ldisc_flush(tty);
570 524
571 tty_port_close_end(port, tty); 525 tty_port_close_end(port, tty);
572 tty_port_tty_set(port, NULL); 526 tty_port_tty_set(port, NULL);