aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/mxser.c
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2008-04-30 03:53:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-30 11:29:45 -0400
commit978e595f88a1fba5869aa42a4af4fba36f33ecac (patch)
tree60848f49949c5b7b518621ee36cdc6d500244539 /drivers/char/mxser.c
parentac0e4b7d319bf284bb64bc7e1c051417386b34a4 (diff)
tty/serial: lay the foundations for the next set of reworks
- Stop drivers calling their own flush method indirectly, it obfuscates code and it will change soon anyway - A few more lock_kernel paths temporarily needed in some driver internal waiting code - Remove private put_char method that does a write call for one char - we have that anyway - Most but not yet all of the termios copy under lock fixing (some has other dependencies to follow) - Note a few locking bugs in drivers found in the process - Kill remaining [ab]users of TIOCG/SSOFTCAR in the driver, these must go to fix the termios locking Signed-off-by: Alan Cox <alan@redhat.com> Cc: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/mxser.c')
-rw-r--r--drivers/char/mxser.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 00cf09aa11fc..28f63566ab8a 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -927,6 +927,27 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
927 return 0; 927 return 0;
928} 928}
929 929
930static void mxser_flush_buffer(struct tty_struct *tty)
931{
932 struct mxser_port *info = tty->driver_data;
933 char fcr;
934 unsigned long flags;
935
936
937 spin_lock_irqsave(&info->slock, flags);
938 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
939
940 fcr = inb(info->ioaddr + UART_FCR);
941 outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
942 info->ioaddr + UART_FCR);
943 outb(fcr, info->ioaddr + UART_FCR);
944
945 spin_unlock_irqrestore(&info->slock, flags);
946
947 tty_wakeup(tty);
948}
949
950
930/* 951/*
931 * This routine is called when the serial port gets closed. First, we 952 * This routine is called when the serial port gets closed. First, we
932 * wait for the last remaining data to be sent. Then, we unlink its 953 * wait for the last remaining data to be sent. Then, we unlink its
@@ -1013,9 +1034,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
1013 } 1034 }
1014 mxser_shutdown(info); 1035 mxser_shutdown(info);
1015 1036
1016 if (tty->driver->flush_buffer) 1037 mxser_flush_buffer(tty);
1017 tty->driver->flush_buffer(tty);
1018
1019 tty_ldisc_flush(tty); 1038 tty_ldisc_flush(tty);
1020 1039
1021 tty->closing = 0; 1040 tty->closing = 0;
@@ -1142,26 +1161,6 @@ static int mxser_chars_in_buffer(struct tty_struct *tty)
1142 return info->xmit_cnt; 1161 return info->xmit_cnt;
1143} 1162}
1144 1163
1145static void mxser_flush_buffer(struct tty_struct *tty)
1146{
1147 struct mxser_port *info = tty->driver_data;
1148 char fcr;
1149 unsigned long flags;
1150
1151
1152 spin_lock_irqsave(&info->slock, flags);
1153 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
1154
1155 fcr = inb(info->ioaddr + UART_FCR);
1156 outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
1157 info->ioaddr + UART_FCR);
1158 outb(fcr, info->ioaddr + UART_FCR);
1159
1160 spin_unlock_irqrestore(&info->slock, flags);
1161
1162 tty_wakeup(tty);
1163}
1164
1165/* 1164/*
1166 * ------------------------------------------------------------ 1165 * ------------------------------------------------------------
1167 * friends of mxser_ioctl() 1166 * friends of mxser_ioctl()
@@ -1992,6 +1991,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
1992 timeout, char_time); 1991 timeout, char_time);
1993 printk("jiff=%lu...", jiffies); 1992 printk("jiff=%lu...", jiffies);
1994#endif 1993#endif
1994 lock_kernel();
1995 while (!((lsr = inb(info->ioaddr + UART_LSR)) & UART_LSR_TEMT)) { 1995 while (!((lsr = inb(info->ioaddr + UART_LSR)) & UART_LSR_TEMT)) {
1996#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT 1996#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
1997 printk("lsr = %d (jiff=%lu)...", lsr, jiffies); 1997 printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
@@ -2003,6 +2003,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
2003 break; 2003 break;
2004 } 2004 }
2005 set_current_state(TASK_RUNNING); 2005 set_current_state(TASK_RUNNING);
2006 unlock_kernel();
2006 2007
2007#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT 2008#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
2008 printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies); 2009 printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);