mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: gregkh@suse.de
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	jirislaby@gmail.com, Alan Cox <alan@linux.intel.com>
Subject: [PATCH 04/10] TTY: serial, use tty_port_close_start helper
Date: Wed,  9 Nov 2011 21:33:46 +0100	[thread overview]
Message-ID: <1320870831-23778-4-git-send-email-jslaby@suse.cz> (raw)
In-Reply-To: <1320870831-23778-1-git-send-email-jslaby@suse.cz>

After the previous patches, the code is almost identical. There are
few differences in the helper code:
1) flush_buffer when flow_stopped
   * when a user doesn't care about the data, delete it anyways
2) ASYNCB_INITIALIZED test before wait_until_sent_from
   * obviously, there is nothing to wait for if the port is dead
3) drain_delay wait
   * we don't set drain_delay

So we can use the helper now. It indeed removes a bunch of duplicated
code.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Alan Cox <alan@linux.intel.com>
---
 drivers/tty/serial/serial_core.c |   40 +-------------------------------------
 1 files changed, 1 insertions(+), 39 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 2b1ee7c..fcb5342 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1267,46 +1267,8 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
 
 	pr_debug("uart_close(%d) called\n", uport->line);
 
-	spin_lock_irqsave(&port->lock, flags);
-
-	if (tty_hung_up_p(filp)) {
-		spin_unlock_irqrestore(&port->lock, flags);
+	if (tty_port_close_start(port, tty, filp) == 0)
 		return;
-	}
-
-	if ((tty->count == 1) && (port->count != 1)) {
-		/*
-		 * Uh, oh.  tty->count is 1, which means that the tty
-		 * structure will be freed.  port->count should always
-		 * be one in these conditions.  If it's greater than
-		 * one, we've got real problems, since it means the
-		 * serial port won't be shutdown.
-		 */
-		printk(KERN_ERR "uart_close: bad serial port count; tty->count is 1, "
-		       "port->count is %d\n", port->count);
-		port->count = 1;
-	}
-	if (--port->count < 0) {
-		printk(KERN_ERR "uart_close: bad serial port count for %s: %d\n",
-		       tty->name, port->count);
-		port->count = 0;
-	}
-	if (port->count) {
-		spin_unlock_irqrestore(&port->lock, flags);
-		return;
-	}
-
-	/*
-	 * Now we wait for the transmit buffer to clear; and we notify
-	 * the line discipline to only process XON/XOFF characters by
-	 * setting tty->closing.
-	 */
-	set_bit(ASYNCB_CLOSING, &port->flags);
-	tty->closing = 1;
-	spin_unlock_irqrestore(&port->lock, flags);
-
-	if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
-		tty_wait_until_sent_from_close(tty, port->closing_wait);
 
 	/*
 	 * At this point, we stop accepting input.  To do this, we
-- 
1.7.7



  parent reply	other threads:[~2011-11-09 20:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-09 20:33 [PATCH 01/10] TTY: serial, cleanup include file Jiri Slaby
2011-11-09 20:33 ` [PATCH 02/10] TTY: serial, cleanup atmel_set_ldisc Jiri Slaby
2011-11-15  9:01   ` Nicolas Ferre
2011-11-09 20:33 ` [PATCH 03/10] TTY: serial, switch closing_wait and close_delay to jiffies Jiri Slaby
2011-11-09 20:33 ` Jiri Slaby [this message]
2011-11-09 20:33 ` [PATCH 05/10] TTY: serial, document few functions Jiri Slaby
2011-11-09 20:33 ` [PATCH 06/10] TTY: serial, do not touch tty->alt_speed Jiri Slaby
2011-11-09 20:33 ` [PATCH 07/10] TTY: serial, inline uart_get Jiri Slaby
2011-11-09 20:33 ` [PATCH 08/10] TTY: serial, define uart_port_activate/shutdown Jiri Slaby
2011-11-09 20:33 ` [PATCH 09/10] TTY: serial, fill uart_port_shutdown Jiri Slaby
2011-11-09 20:34 ` [PATCH 10/10] TTY: serial, extract uart_port_startup Jiri Slaby
2011-11-09 21:59 ` [PATCH 01/10] TTY: serial, cleanup include file Alan Cox
2011-11-09 22:09   ` Jiri Slaby
2011-11-09 23:25     ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1320870831-23778-4-git-send-email-jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=alan@linux.intel.com \
    --cc=gregkh@suse.de \
    --cc=jirislaby@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®