public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ilya Zykov <ilya@ilyx.ru>
To: Alan Cox <alan@linux.intel.com>
Cc: Andrew McGregor <andrew.mcgregor@alliedtelesis.co.nz>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	ilya@ilyx.ru
Subject: [PATCH]tty: Incorrect use tty_ldisc_flush() in TTY drivers.
Date: Tue, 27 Nov 2012 04:06:52 +0400	[thread overview]
Message-ID: <50B4041C.9030002@ilyx.ru> (raw)

Sorry. Correct patch format.

Related bug 'tty: fix "IRQ45: nobody cared"'
Related commit 7b292b4bf9a9d6098440d85616d6ca4c608b8304

  Unfortunately, some drivers indirectly call ldisc's flush_buffer() function 
in own callback function close(). In particularly, by the use of tty_ldisc_flush(),
before TTY LAYER calls ldisc's flush_buffer() in the right moment.

1. It disturb the logic of work ldisc's layer.
2. It is simple overhead because we call ldisc's flush_buffer() at least two times.

Please, tell me what do you think about this? Can I make the adjustment for other drivers?

Signed-off-by: Ilya Zykov <ilya@ilyx.ru>
---
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 0fcfd98..d87f353 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1304,7 +1304,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
 	uart_shutdown(tty, state);
 	uart_flush_buffer(tty);
 
-	tty_ldisc_flush(tty);
+	tty_buffer_flush(tty);
 
 	tty_port_tty_set(port, NULL);
 	spin_lock_irqsave(&port->lock, flags);
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index d7bdd8d..8a02996 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -428,8 +428,8 @@ int tty_port_close_start(struct tty_port *port,
 			timeout = 2 * HZ;
 		schedule_timeout_interruptible(timeout);
 	}
-	/* Flush the ldisc buffering */
-	tty_ldisc_flush(tty);
+	/* Flush the driver buffering */
+	tty_buffer_flush(tty);
 
 	/* Drop DTR/RTS if HUPCL is set. This causes any attached modem to
 	   hang up the line */

             reply	other threads:[~2012-11-27  0:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-27  0:06 Ilya Zykov [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-11-23 18:42 [PATCH]tty: Incorrect use tty_ldisc_flush() in TTY drivers Ilya Zykov

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=50B4041C.9030002@ilyx.ru \
    --to=ilya@ilyx.ru \
    --cc=alan@linux.intel.com \
    --cc=andrew.mcgregor@alliedtelesis.co.nz \
    --cc=gregkh@linuxfoundation.org \
    --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