aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2011-08-25 09:12:04 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-08-25 12:00:39 -0400
commit426929f8d3514d7f727b8c464d1eeeaf74b21519 (patch)
tree05f84b3f6e0182dfee2f0cb720f2acc36a4134ba /drivers/tty
parentdfc97fcebd6a9a85335adcfc0e4d0a204bbaea35 (diff)
TTY: serial, use ASYNCB_CLOSING in uart_close
We need to move port->mutex locking after wait_until_sent in uart_close (for rationale see next patches). But if we did it now, we would introduce a race between close and open. This is exactly why port->mutex is locked at the top of uart_close. To avoid the race, we add ASYNCB_CLOSING to uart_close. Like every other sane TTY driver. Thanks to tty_port_block_til_ready used in uart_open we will have this for free. Then we can move the port->mutex lock. Also note that this will make the conversion to tty_port helpers easier. They are currently handling ASYNC_CLOSING flag correctly. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/serial_core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 3844980b397f..849bd0d06b2c 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1288,6 +1288,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
1288 * the line discipline to only process XON/XOFF characters by 1288 * the line discipline to only process XON/XOFF characters by
1289 * setting tty->closing. 1289 * setting tty->closing.
1290 */ 1290 */
1291 set_bit(ASYNCB_CLOSING, &port->flags);
1291 tty->closing = 1; 1292 tty->closing = 1;
1292 spin_unlock_irqrestore(&port->lock, flags); 1293 spin_unlock_irqrestore(&port->lock, flags);
1293 1294
@@ -1335,8 +1336,10 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
1335 * Wake up anyone trying to open this port. 1336 * Wake up anyone trying to open this port.
1336 */ 1337 */
1337 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags); 1338 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
1339 clear_bit(ASYNCB_CLOSING, &port->flags);
1338 spin_unlock_irqrestore(&port->lock, flags); 1340 spin_unlock_irqrestore(&port->lock, flags);
1339 wake_up_interruptible(&port->open_wait); 1341 wake_up_interruptible(&port->open_wait);
1342 wake_up_interruptible(&port->close_wait);
1340 1343
1341done: 1344done:
1342 mutex_unlock(&port->mutex); 1345 mutex_unlock(&port->mutex);