diff options
author | Alan Cox <alan@redhat.com> | 2009-01-02 08:46:50 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-02 13:19:40 -0500 |
commit | a6614999e800cf3a134ce93ea46ef837e3c0e76e (patch) | |
tree | 56b0a29ed004a284561a4c3ff3ee52075acabb65 /drivers/char/riscom8.c | |
parent | 7834909f1eb96ba7c49ca2b9e3a69b500a2cff76 (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/riscom8.c')
-rw-r--r-- | drivers/char/riscom8.c | 49 |
1 files changed, 5 insertions, 44 deletions
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c index af34c2054a09..9ac5febd8abd 100644 --- a/drivers/char/riscom8.c +++ b/drivers/char/riscom8.c | |||
@@ -929,35 +929,11 @@ static void rc_close(struct tty_struct *tty, struct file *filp) | |||
929 | if (!port || rc_paranoia_check(port, tty->name, "close")) | 929 | if (!port || rc_paranoia_check(port, tty->name, "close")) |
930 | return; | 930 | return; |
931 | 931 | ||
932 | spin_lock_irqsave(&port->port.lock, flags); | ||
933 | |||
934 | if (tty_hung_up_p(filp)) | ||
935 | goto out; | ||
936 | |||
937 | bp = port_Board(port); | 932 | bp = port_Board(port); |
938 | if ((tty->count == 1) && (port->port.count != 1)) { | 933 | |
939 | printk(KERN_INFO "rc%d: rc_close: bad port count;" | 934 | if (tty_port_close_start(&port->port, tty, filp) == 0) |
940 | " tty->count is 1, port count is %d\n", | 935 | return; |
941 | board_No(bp), port->port.count); | 936 | |
942 | port->port.count = 1; | ||
943 | } | ||
944 | if (--port->port.count < 0) { | ||
945 | printk(KERN_INFO "rc%d: rc_close: bad port count " | ||
946 | "for tty%d: %d\n", | ||
947 | board_No(bp), port_No(port), port->port.count); | ||
948 | port->port.count = 0; | ||
949 | } | ||
950 | if (port->port.count) | ||
951 | goto out; | ||
952 | port->port.flags |= ASYNC_CLOSING; | ||
953 | /* | ||
954 | * Now we wait for the transmit buffer to clear; and we notify | ||
955 | * the line discipline to only process XON/XOFF characters. | ||
956 | */ | ||
957 | tty->closing = 1; | ||
958 | spin_unlock_irqrestore(&port->port.lock, flags); | ||
959 | if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) | ||
960 | tty_wait_until_sent(tty, port->port.closing_wait); | ||
961 | /* | 937 | /* |
962 | * At this point we stop accepting input. To do this, we | 938 | * At this point we stop accepting input. To do this, we |
963 | * disable the receive line status interrupts, and tell the | 939 | * disable the receive line status interrupts, and tell the |
@@ -989,23 +965,8 @@ static void rc_close(struct tty_struct *tty, struct file *filp) | |||
989 | rc_shutdown_port(tty, bp, port); | 965 | rc_shutdown_port(tty, bp, port); |
990 | rc_flush_buffer(tty); | 966 | rc_flush_buffer(tty); |
991 | spin_unlock_irqrestore(&riscom_lock, flags); | 967 | spin_unlock_irqrestore(&riscom_lock, flags); |
992 | tty_ldisc_flush(tty); | ||
993 | 968 | ||
994 | spin_lock_irqsave(&port->port.lock, flags); | 969 | tty_port_close_end(&port->port, tty); |
995 | tty->closing = 0; | ||
996 | port->port.tty = NULL; | ||
997 | if (port->port.blocked_open) { | ||
998 | spin_unlock_irqrestore(&port->port.lock, flags); | ||
999 | if (port->port.close_delay) | ||
1000 | msleep_interruptible(jiffies_to_msecs(port->port.close_delay)); | ||
1001 | wake_up_interruptible(&port->port.open_wait); | ||
1002 | spin_lock_irqsave(&port->port.lock, flags); | ||
1003 | } | ||
1004 | port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); | ||
1005 | wake_up_interruptible(&port->port.close_wait); | ||
1006 | |||
1007 | out: | ||
1008 | spin_unlock_irqrestore(&riscom_lock, flags); | ||
1009 | } | 970 | } |
1010 | 971 | ||
1011 | static int rc_write(struct tty_struct *tty, | 972 | static int rc_write(struct tty_struct *tty, |