diff options
author | Alan Cox <alan@redhat.com> | 2009-01-02 13:45:26 +0000 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-02 10:19:38 -0800 |
commit | 3e61696bdc2103107674b06d0daf30b76193e922 (patch) | |
tree | cc4f2b7b7b0ce2162613bb9d3cf819f6bbfd3628 /drivers/char/tty_port.c | |
parent | 5d951fb458f847e5485b5251597fbf326000bb3b (diff) | |
download | lwn-3e61696bdc2103107674b06d0daf30b76193e922.tar.gz lwn-3e61696bdc2103107674b06d0daf30b76193e922.zip |
isicom: redo locking to use tty port locks
This helps set the basis for moving block_til_ready into common code. We also
introduce a tty_port_hangup helper as this will also be generally needed.
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/tty_port.c')
-rw-r--r-- | drivers/char/tty_port.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/char/tty_port.c b/drivers/char/tty_port.c index 0557b6384747..9f418bca4a22 100644 --- a/drivers/char/tty_port.c +++ b/drivers/char/tty_port.c @@ -7,6 +7,7 @@ #include <linux/tty.h> #include <linux/tty_driver.h> #include <linux/tty_flip.h> +#include <linux/serial.h> #include <linux/timer.h> #include <linux/string.h> #include <linux/slab.h> @@ -96,6 +97,29 @@ void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty) EXPORT_SYMBOL(tty_port_tty_set); /** + * tty_port_hangup - hangup helper + * @port: tty port + * + * Perform port level tty hangup flag and count changes. Drop the tty + * reference. + */ + +void tty_port_hangup(struct tty_port *port) +{ + unsigned long flags; + + spin_lock_irqsave(&port->lock, flags); + port->count = 0; + port->flags &= ~ASYNC_NORMAL_ACTIVE; + if (port->tty) + tty_kref_put(port->tty); + port->tty = NULL; + spin_unlock_irqrestore(&port->lock, flags); + wake_up_interruptible(&port->open_wait); +} +EXPORT_SYMBOL(tty_port_hangup); + +/** * tty_port_carrier_raised - carrier raised check * @port: tty port * |