aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/stallion.c
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2009-01-02 08:46:50 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-02 13:19:40 -0500
commita6614999e800cf3a134ce93ea46ef837e3c0e76e (patch)
tree56b0a29ed004a284561a4c3ff3ee52075acabb65 /drivers/char/stallion.c
parent7834909f1eb96ba7c49ca2b9e3a69b500a2cff76 (diff)
tty: Introduce some close helpers for ports
Again this is a lot of common code we can unify Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/stallion.c')
-rw-r--r--drivers/char/stallion.c39
1 files changed, 4 insertions, 35 deletions
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 77eef61c46f3..e1e0dd89ac9a 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -833,40 +833,20 @@ static void stl_close(struct tty_struct *tty, struct file *filp)
833 pr_debug("stl_close(tty=%p,filp=%p)\n", tty, filp); 833 pr_debug("stl_close(tty=%p,filp=%p)\n", tty, filp);
834 834
835 portp = tty->driver_data; 835 portp = tty->driver_data;
836 if (portp == NULL) 836 BUG_ON(portp == NULL);
837 return; 837
838 port = &portp->port; 838 port = &portp->port;
839 839
840 spin_lock_irqsave(&port->lock, flags); 840 if (tty_port_close_start(port, tty, filp) == 0)
841 if (tty_hung_up_p(filp)) {
842 spin_unlock_irqrestore(&port->lock, flags);
843 return; 841 return;
844 }
845 if (tty->count == 1 && port->count != 1)
846 port->count = 1;
847 if (port->count-- > 1) {
848 spin_unlock_irqrestore(&port->lock, flags);
849 return;
850 }
851
852 port->count = 0;
853 port->flags |= ASYNC_CLOSING;
854
855/* 842/*
856 * May want to wait for any data to drain before closing. The BUSY 843 * May want to wait for any data to drain before closing. The BUSY
857 * flag keeps track of whether we are still sending or not - it is 844 * flag keeps track of whether we are still sending or not - it is
858 * very accurate for the cd1400, not quite so for the sc26198. 845 * very accurate for the cd1400, not quite so for the sc26198.
859 * (The sc26198 has no "end-of-data" interrupt only empty FIFO) 846 * (The sc26198 has no "end-of-data" interrupt only empty FIFO)
860 */ 847 */
861 tty->closing = 1;
862
863 spin_unlock_irqrestore(&port->lock, flags);
864
865 if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE)
866 tty_wait_until_sent(tty, portp->closing_wait);
867 stl_waituntilsent(tty, (HZ / 2)); 848 stl_waituntilsent(tty, (HZ / 2));
868 849
869
870 spin_lock_irqsave(&port->lock, flags); 850 spin_lock_irqsave(&port->lock, flags);
871 portp->port.flags &= ~ASYNC_INITIALIZED; 851 portp->port.flags &= ~ASYNC_INITIALIZED;
872 spin_unlock_irqrestore(&port->lock, flags); 852 spin_unlock_irqrestore(&port->lock, flags);
@@ -883,20 +863,9 @@ static void stl_close(struct tty_struct *tty, struct file *filp)
883 portp->tx.head = NULL; 863 portp->tx.head = NULL;
884 portp->tx.tail = NULL; 864 portp->tx.tail = NULL;
885 } 865 }
886 set_bit(TTY_IO_ERROR, &tty->flags);
887 tty_ldisc_flush(tty);
888 866
889 tty->closing = 0; 867 tty_port_close_end(port, tty);
890 tty_port_tty_set(port, NULL); 868 tty_port_tty_set(port, NULL);
891
892 if (port->blocked_open) {
893 if (portp->close_delay)
894 msleep_interruptible(jiffies_to_msecs(portp->close_delay));
895 wake_up_interruptible(&portp->port.open_wait);
896 }
897
898 portp->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
899 wake_up_interruptible(&port->close_wait);
900} 869}
901 870
902/*****************************************************************************/ 871/*****************************************************************************/