aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/riscom8.c
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2009-09-19 16:13:21 -0400
committerLive-CD User <linux@linux.site>2009-09-19 16:13:21 -0400
commitc146942573c84b16ccb480a9cfa885a7581585a8 (patch)
tree3d5b4e1d49ab0197c5223c249897fba1844eb592 /drivers/char/riscom8.c
parent7ca0ff9ab3218ec443a7a9ad247e4650373ed41e (diff)
riscom8: split open and close methods up
Moving towards a tty_port method for open/close Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/char/riscom8.c')
-rw-r--r--drivers/char/riscom8.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index 171711acf5cd..949999120258 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -921,20 +921,12 @@ static void rc_flush_buffer(struct tty_struct *tty)
921 tty_wakeup(tty); 921 tty_wakeup(tty);
922} 922}
923 923
924static void rc_close(struct tty_struct *tty, struct file *filp) 924static void rc_close_port(struct tty_struct *tty, struct tty_port *port)
925{ 925{
926 struct riscom_port *port = tty->driver_data;
927 struct riscom_board *bp;
928 unsigned long flags; 926 unsigned long flags;
927 struct riscom_port *rp = container_of(port, struct riscom_port, port);
928 struct riscom_board *bp = port_Board(rp);
929 unsigned long timeout; 929 unsigned long timeout;
930
931 if (!port || rc_paranoia_check(port, tty->name, "close"))
932 return;
933
934 bp = port_Board(port);
935
936 if (tty_port_close_start(&port->port, tty, filp) == 0)
937 return;
938 930
939 /* 931 /*
940 * At this point we stop accepting input. To do this, we 932 * At this point we stop accepting input. To do this, we
@@ -944,29 +936,42 @@ static void rc_close(struct tty_struct *tty, struct file *filp)
944 */ 936 */
945 937
946 spin_lock_irqsave(&riscom_lock, flags); 938 spin_lock_irqsave(&riscom_lock, flags);
947 port->IER &= ~IER_RXD; 939 rp->IER &= ~IER_RXD;
948 if (port->port.flags & ASYNC_INITIALIZED) { 940 if (port->flags & ASYNC_INITIALIZED) {
949 port->IER &= ~IER_TXRDY; 941 rp->IER &= ~IER_TXRDY;
950 port->IER |= IER_TXEMPTY; 942 rp->IER |= IER_TXEMPTY;
951 rc_out(bp, CD180_CAR, port_No(port)); 943 rc_out(bp, CD180_CAR, port_No(rp));
952 rc_out(bp, CD180_IER, port->IER); 944 rc_out(bp, CD180_IER, rp->IER);
953 /* 945 /*
954 * Before we drop DTR, make sure the UART transmitter 946 * Before we drop DTR, make sure the UART transmitter
955 * has completely drained; this is especially 947 * has completely drained; this is especially
956 * important if there is a transmit FIFO! 948 * important if there is a transmit FIFO!
957 */ 949 */
958 timeout = jiffies + HZ; 950 timeout = jiffies + HZ;
959 while (port->IER & IER_TXEMPTY) { 951 while (rp->IER & IER_TXEMPTY) {
960 spin_unlock_irqrestore(&riscom_lock, flags); 952 spin_unlock_irqrestore(&riscom_lock, flags);
961 msleep_interruptible(jiffies_to_msecs(port->timeout)); 953 msleep_interruptible(jiffies_to_msecs(rp->timeout));
962 spin_lock_irqsave(&riscom_lock, flags); 954 spin_lock_irqsave(&riscom_lock, flags);
963 if (time_after(jiffies, timeout)) 955 if (time_after(jiffies, timeout))
964 break; 956 break;
965 } 957 }
966 } 958 }
967 rc_shutdown_port(tty, bp, port); 959 rc_shutdown_port(tty, bp, rp);
968 rc_flush_buffer(tty);
969 spin_unlock_irqrestore(&riscom_lock, flags); 960 spin_unlock_irqrestore(&riscom_lock, flags);
961}
962
963static void rc_close(struct tty_struct *tty, struct file *filp)
964{
965 struct riscom_port *port = tty->driver_data;
966
967 if (!port || rc_paranoia_check(port, tty->name, "close"))
968 return;
969
970 if (tty_port_close_start(&port->port, tty, filp) == 0)
971 return;
972
973 rc_close_port(tty, &port->port);
974 rc_flush_buffer(tty);
970 975
971 tty_port_close_end(&port->port, tty); 976 tty_port_close_end(&port->port, tty);
972} 977}