Skip to contentSkip to conversation

tty: Incorrect use tty_ldisc_flush() in TTY drivers.

PATCH New Ilya Zykov 1 participant 1 message Nov 27, 2012 TTY layer and serial drivers

lore
Share & tools
lore

Ilya Zykov

author
#0 lore raw

PATCH 1/1 tty: Incorrect use tty_ldisc_flush() in TTY drivers.

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?

---

drivers/tty/serial/serial_core.c +1 -1
index 0fcfd98..d87f353 100644
@@ -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);
drivers/tty/tty_port.c +2 -2
index d7bdd8d..8a02996 100644
@@ -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 */