aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/serial')
-rw-r--r--drivers/serial/68328serial.c21
-rw-r--r--drivers/serial/68360serial.c28
-rw-r--r--drivers/serial/8250_early.c2
-rw-r--r--drivers/serial/Kconfig43
-rw-r--r--drivers/serial/Makefile1
-rw-r--r--drivers/serial/bfin_5xx.c4
-rw-r--r--drivers/serial/bfin_sport_uart.c614
-rw-r--r--drivers/serial/bfin_sport_uart.h63
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_core.c2
-rw-r--r--drivers/serial/crisv10.c31
-rw-r--r--drivers/serial/ioc3_serial.c36
-rw-r--r--drivers/serial/ioc4_serial.c32
-rw-r--r--drivers/serial/kgdboc.c6
-rw-r--r--drivers/serial/mcfserial.c22
-rw-r--r--drivers/serial/netx-serial.c1
-rw-r--r--drivers/serial/s3c2410.c13
-rw-r--r--drivers/serial/sa1100.c4
-rw-r--r--drivers/serial/serial_core.c54
-rw-r--r--drivers/serial/sh-sci.c2
-rw-r--r--drivers/serial/sn_console.c2
-rw-r--r--drivers/serial/uartlite.c2
-rw-r--r--drivers/serial/ucc_uart.c4
22 files changed, 849 insertions, 138 deletions
diff --git a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c
index 2b8a410e0959..bbf5bc5892c7 100644
--- a/drivers/serial/68328serial.c
+++ b/drivers/serial/68328serial.c
@@ -200,7 +200,7 @@ static void rs_stop(struct tty_struct *tty)
200 local_irq_restore(flags); 200 local_irq_restore(flags);
201} 201}
202 202
203static void rs_put_char(char ch) 203static int rs_put_char(char ch)
204{ 204{
205 int flags, loops = 0; 205 int flags, loops = 0;
206 206
@@ -214,6 +214,7 @@ static void rs_put_char(char ch)
214 UTX_TXDATA = ch; 214 UTX_TXDATA = ch;
215 udelay(5); 215 udelay(5);
216 local_irq_restore(flags); 216 local_irq_restore(flags);
217 return 1;
217} 218}
218 219
219static void rs_start(struct tty_struct *tty) 220static void rs_start(struct tty_struct *tty)
@@ -1017,18 +1018,6 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
1017 tty_wait_until_sent(tty, 0); 1018 tty_wait_until_sent(tty, 0);
1018 send_break(info, arg ? arg*(100) : 250); 1019 send_break(info, arg ? arg*(100) : 250);
1019 return 0; 1020 return 0;
1020 case TIOCGSOFTCAR:
1021 error = put_user(C_CLOCAL(tty) ? 1 : 0,
1022 (unsigned long *) arg);
1023 if (error)
1024 return error;
1025 return 0;
1026 case TIOCSSOFTCAR:
1027 get_user(arg, (unsigned long *) arg);
1028 tty->termios->c_cflag =
1029 ((tty->termios->c_cflag & ~CLOCAL) |
1030 (arg ? CLOCAL : 0));
1031 return 0;
1032 case TIOCGSERIAL: 1021 case TIOCGSERIAL:
1033 if (access_ok(VERIFY_WRITE, (void *) arg, 1022 if (access_ok(VERIFY_WRITE, (void *) arg,
1034 sizeof(struct serial_struct))) 1023 sizeof(struct serial_struct)))
@@ -1061,9 +1050,6 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
1061{ 1050{
1062 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; 1051 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
1063 1052
1064 if (tty->termios->c_cflag == old_termios->c_cflag)
1065 return;
1066
1067 change_speed(info); 1053 change_speed(info);
1068 1054
1069 if ((old_termios->c_cflag & CRTSCTS) && 1055 if ((old_termios->c_cflag & CRTSCTS) &&
@@ -1140,8 +1126,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1140 uart->ustcnt &= ~(USTCNT_RXEN | USTCNT_RX_INTR_MASK); 1126 uart->ustcnt &= ~(USTCNT_RXEN | USTCNT_RX_INTR_MASK);
1141 1127
1142 shutdown(info); 1128 shutdown(info);
1143 if (tty->driver->flush_buffer) 1129 rs_flush_buffer(tty);
1144 tty->driver->flush_buffer(tty);
1145 1130
1146 tty_ldisc_flush(tty); 1131 tty_ldisc_flush(tty);
1147 tty->closing = 0; 1132 tty->closing = 0;
diff --git a/drivers/serial/68360serial.c b/drivers/serial/68360serial.c
index f59463601874..d9d4e9552a4d 100644
--- a/drivers/serial/68360serial.c
+++ b/drivers/serial/68360serial.c
@@ -995,10 +995,10 @@ static void rs_360_put_char(struct tty_struct *tty, unsigned char ch)
995 volatile QUICC_BD *bdp; 995 volatile QUICC_BD *bdp;
996 996
997 if (serial_paranoia_check(info, tty->name, "rs_put_char")) 997 if (serial_paranoia_check(info, tty->name, "rs_put_char"))
998 return; 998 return 0;
999 999
1000 if (!tty) 1000 if (!tty)
1001 return; 1001 return 0;
1002 1002
1003 bdp = info->tx_cur; 1003 bdp = info->tx_cur;
1004 while (bdp->status & BD_SC_READY); 1004 while (bdp->status & BD_SC_READY);
@@ -1016,6 +1016,7 @@ static void rs_360_put_char(struct tty_struct *tty, unsigned char ch)
1016 bdp++; 1016 bdp++;
1017 1017
1018 info->tx_cur = (QUICC_BD *)bdp; 1018 info->tx_cur = (QUICC_BD *)bdp;
1019 return 1;
1019 1020
1020} 1021}
1021 1022
@@ -1246,7 +1247,7 @@ static int rs_360_tiocmget(struct tty_struct *tty, struct file *file)
1246#ifdef modem_control 1247#ifdef modem_control
1247 unsigned char control, status; 1248 unsigned char control, status;
1248 1249
1249 if (serial_paranoia_check(info, tty->name, __FUNCTION__)) 1250 if (serial_paranoia_check(info, tty->name, __func__))
1250 return -ENODEV; 1251 return -ENODEV;
1251 1252
1252 if (tty->flags & (1 << TTY_IO_ERROR)) 1253 if (tty->flags & (1 << TTY_IO_ERROR))
@@ -1277,12 +1278,12 @@ static int rs_360_tiocmset(struct tty_struct *tty, struct file *file,
1277 ser_info_t *info = (ser_info_t *)tty->driver_data; 1278 ser_info_t *info = (ser_info_t *)tty->driver_data;
1278 unsigned int arg; 1279 unsigned int arg;
1279 1280
1280 if (serial_paranoia_check(info, tty->name, __FUNCTION__)) 1281 if (serial_paranoia_check(info, tty->name, __func__))
1281 return -ENODEV; 1282 return -ENODEV;
1282 1283
1283 if (tty->flags & (1 << TTY_IO_ERROR)) 1284 if (tty->flags & (1 << TTY_IO_ERROR))
1284 return -EIO; 1285 return -EIO;
1285 1286 /* FIXME: locking on info->mcr */
1286 if (set & TIOCM_RTS) 1287 if (set & TIOCM_RTS)
1287 info->mcr |= UART_MCR_RTS; 1288 info->mcr |= UART_MCR_RTS;
1288 if (set & TIOCM_DTR) 1289 if (set & TIOCM_DTR)
@@ -1436,18 +1437,6 @@ static int rs_360_ioctl(struct tty_struct *tty, struct file * file,
1436 return retval; 1437 return retval;
1437 end_break(info); 1438 end_break(info);
1438 return 0; 1439 return 0;
1439 case TIOCGSOFTCAR:
1440 /* return put_user(C_CLOCAL(tty) ? 1 : 0, (int *) arg); */
1441 put_user(C_CLOCAL(tty) ? 1 : 0, (int *) arg);
1442 return 0;
1443 case TIOCSSOFTCAR:
1444 error = get_user(arg, (unsigned int *) arg);
1445 if (error)
1446 return error;
1447 tty->termios->c_cflag =
1448 ((tty->termios->c_cflag & ~CLOCAL) |
1449 (arg ? CLOCAL : 0));
1450 return 0;
1451#ifdef maybe 1440#ifdef maybe
1452 case TIOCSERGETLSR: /* Get line status register */ 1441 case TIOCSERGETLSR: /* Get line status register */
1453 return get_lsr_info(info, (unsigned int *) arg); 1442 return get_lsr_info(info, (unsigned int *) arg);
@@ -1665,8 +1654,7 @@ static void rs_360_close(struct tty_struct *tty, struct file * filp)
1665 rs_360_wait_until_sent(tty, info->timeout); 1654 rs_360_wait_until_sent(tty, info->timeout);
1666 } 1655 }
1667 shutdown(info); 1656 shutdown(info);
1668 if (tty->driver->flush_buffer) 1657 rs_360_flush_buffer(tty);
1669 tty->driver->flush_buffer(tty);
1670 tty_ldisc_flush(tty); 1658 tty_ldisc_flush(tty);
1671 tty->closing = 0; 1659 tty->closing = 0;
1672 info->event = 0; 1660 info->event = 0;
@@ -1717,6 +1705,7 @@ static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout)
1717 printk("jiff=%lu...", jiffies); 1705 printk("jiff=%lu...", jiffies);
1718#endif 1706#endif
1719 1707
1708 lock_kernel();
1720 /* We go through the loop at least once because we can't tell 1709 /* We go through the loop at least once because we can't tell
1721 * exactly when the last character exits the shifter. There can 1710 * exactly when the last character exits the shifter. There can
1722 * be at least two characters waiting to be sent after the buffers 1711 * be at least two characters waiting to be sent after the buffers
@@ -1745,6 +1734,7 @@ static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout)
1745 bdp--; 1734 bdp--;
1746 } while (bdp->status & BD_SC_READY); 1735 } while (bdp->status & BD_SC_READY);
1747 current->state = TASK_RUNNING; 1736 current->state = TASK_RUNNING;
1737 unlock_kernel();
1748#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT 1738#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
1749 printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies); 1739 printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
1750#endif 1740#endif
diff --git a/drivers/serial/8250_early.c b/drivers/serial/8250_early.c
index 38776e8b064b..cd898704ba4f 100644
--- a/drivers/serial/8250_early.c
+++ b/drivers/serial/8250_early.c
@@ -156,7 +156,7 @@ static int __init parse_options(struct early_serial8250_device *device,
156 port->membase = ioremap(port->mapbase, 64); 156 port->membase = ioremap(port->mapbase, 64);
157 if (!port->membase) { 157 if (!port->membase) {
158 printk(KERN_ERR "%s: Couldn't ioremap 0x%llx\n", 158 printk(KERN_ERR "%s: Couldn't ioremap 0x%llx\n",
159 __FUNCTION__, 159 __func__,
160 (unsigned long long)port->mapbase); 160 (unsigned long long)port->mapbase);
161 return -ENOMEM; 161 return -ENOMEM;
162 } 162 }
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 34b809e3b596..36acbcca2d48 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -1355,4 +1355,47 @@ config SERIAL_SC26XX_CONSOLE
1355 help 1355 help
1356 Support for Console on SC2681/SC2692 serial ports. 1356 Support for Console on SC2681/SC2692 serial ports.
1357 1357
1358config SERIAL_BFIN_SPORT
1359 tristate "Blackfin SPORT emulate UART (EXPERIMENTAL)"
1360 depends on BFIN && EXPERIMENTAL
1361 select SERIAL_CORE
1362 help
1363 Enble support SPORT emulate UART on Blackfin series.
1364
1365 To compile this driver as a module, choose M here: the
1366 module will be called bfin_sport_uart.
1367
1368choice
1369 prompt "Baud rate for Blackfin SPORT UART"
1370 depends on SERIAL_BFIN_SPORT
1371 default SERIAL_SPORT_BAUD_RATE_57600
1372 help
1373 Choose a baud rate for the SPORT UART, other uart settings are
1374 8 bit, 1 stop bit, no parity, no flow control.
1375
1376config SERIAL_SPORT_BAUD_RATE_115200
1377 bool "115200"
1378
1379config SERIAL_SPORT_BAUD_RATE_57600
1380 bool "57600"
1381
1382config SERIAL_SPORT_BAUD_RATE_38400
1383 bool "38400"
1384
1385config SERIAL_SPORT_BAUD_RATE_19200
1386 bool "19200"
1387
1388config SERIAL_SPORT_BAUD_RATE_9600
1389 bool "9600"
1390endchoice
1391
1392config SPORT_BAUD_RATE
1393 int
1394 depends on SERIAL_BFIN_SPORT
1395 default 115200 if (SERIAL_SPORT_BAUD_RATE_115200)
1396 default 57600 if (SERIAL_SPORT_BAUD_RATE_57600)
1397 default 38400 if (SERIAL_SPORT_BAUD_RATE_38400)
1398 default 19200 if (SERIAL_SPORT_BAUD_RATE_19200)
1399 default 9600 if (SERIAL_SPORT_BAUD_RATE_9600)
1400
1358endmenu 1401endmenu
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index f02ff9fad017..0d9c09b1e836 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_SERIAL_PXA) += pxa.o
27obj-$(CONFIG_SERIAL_PNX8XXX) += pnx8xxx_uart.o 27obj-$(CONFIG_SERIAL_PNX8XXX) += pnx8xxx_uart.o
28obj-$(CONFIG_SERIAL_SA1100) += sa1100.o 28obj-$(CONFIG_SERIAL_SA1100) += sa1100.o
29obj-$(CONFIG_SERIAL_BFIN) += bfin_5xx.o 29obj-$(CONFIG_SERIAL_BFIN) += bfin_5xx.o
30obj-$(CONFIG_SERIAL_BFIN_SPORT) += bfin_sport_uart.o
30obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o 31obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o
31obj-$(CONFIG_SERIAL_SUNCORE) += suncore.o 32obj-$(CONFIG_SERIAL_SUNCORE) += suncore.o
32obj-$(CONFIG_SERIAL_SUNHV) += sunhv.o 33obj-$(CONFIG_SERIAL_SUNHV) += sunhv.o
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index 5f55534a290b..8a2f6a1baa74 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -762,7 +762,7 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
762 break; 762 break;
763 default: 763 default:
764 printk(KERN_ERR "%s: word lengh not supported\n", 764 printk(KERN_ERR "%s: word lengh not supported\n",
765 __FUNCTION__); 765 __func__);
766 } 766 }
767 767
768 if (termios->c_cflag & CSTOPB) 768 if (termios->c_cflag & CSTOPB)
@@ -1029,7 +1029,7 @@ bfin_serial_console_get_options(struct bfin_serial_port *uart, int *baud,
1029 1029
1030 *baud = get_sclk() / (16*(dll | dlh << 8)); 1030 *baud = get_sclk() / (16*(dll | dlh << 8));
1031 } 1031 }
1032 pr_debug("%s:baud = %d, parity = %c, bits= %d\n", __FUNCTION__, *baud, *parity, *bits); 1032 pr_debug("%s:baud = %d, parity = %c, bits= %d\n", __func__, *baud, *parity, *bits);
1033} 1033}
1034#endif 1034#endif
1035 1035
diff --git a/drivers/serial/bfin_sport_uart.c b/drivers/serial/bfin_sport_uart.c
new file mode 100644
index 000000000000..aca1240ad808
--- /dev/null
+++ b/drivers/serial/bfin_sport_uart.c
@@ -0,0 +1,614 @@
1/*
2 * File: linux/drivers/serial/bfin_sport_uart.c
3 *
4 * Based on: drivers/serial/bfin_5xx.c by Aubrey Li.
5 * Author: Roy Huang <roy.huang@analog.com>
6 *
7 * Created: Nov 22, 2006
8 * Copyright: (c) 2006-2007 Analog Devices Inc.
9 * Description: this driver enable SPORTs on Blackfin emulate UART.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see the file COPYING, or write
23 * to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26
27/*
28 * This driver and the hardware supported are in term of EE-191 of ADI.
29 * http://www.analog.com/UploadedFiles/Application_Notes/399447663EE191.pdf
30 * This application note describe how to implement a UART on a Sharc DSP,
31 * but this driver is implemented on Blackfin Processor.
32 */
33
34/* After reset, there is a prelude of low level pulse when transmit data first
35 * time. No addtional pulse in following transmit.
36 * According to document:
37 * The SPORTs are ready to start transmitting or receiving data no later than
38 * three serial clock cycles after they are enabled in the SPORTx_TCR1 or
39 * SPORTx_RCR1 register. No serial clock cycles are lost from this point on.
40 * The first internal frame sync will occur one frame sync delay after the
41 * SPORTs are ready. External frame syncs can occur as soon as the SPORT is
42 * ready.
43 */
44
45/* Thanks to Axel Alatalo <axel@rubico.se> for fixing sport rx bug. Sometimes
46 * sport receives data incorrectly. The following is Axel's words.
47 * As EE-191, sport rx samples 3 times of the UART baudrate and takes the
48 * middle smaple of every 3 samples as the data bit. For a 8-N-1 UART setting,
49 * 30 samples will be required for a byte. If transmitter sends a 1/3 bit short
50 * byte due to buadrate drift, then the 30th sample of a byte, this sample is
51 * also the third sample of the stop bit, will happens on the immediately
52 * following start bit which will be thrown away and missed. Thus since parts
53 * of the startbit will be missed and the receiver will begin to drift, the
54 * effect accumulates over time until synchronization is lost.
55 * If only require 2 samples of the stopbit (by sampling in total 29 samples),
56 * then a to short byte as in the case above will be tolerated. Then the 1/3
57 * early startbit will trigger a framesync since the last read is complete
58 * after only 2/3 stopbit and framesync is active during the last 1/3 looking
59 * for a possible early startbit. */
60
61//#define DEBUG
62
63#include <linux/module.h>
64#include <linux/ioport.h>
65#include <linux/init.h>
66#include <linux/console.h>
67#include <linux/sysrq.h>
68#include <linux/platform_device.h>
69#include <linux/tty.h>
70#include <linux/tty_flip.h>
71#include <linux/serial_core.h>
72
73#include <asm/delay.h>
74#include <asm/portmux.h>
75
76#include "bfin_sport_uart.h"
77
78unsigned short bfin_uart_pin_req_sport0[] =
79 {P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS, \
80 P_SPORT0_DRPRI, P_SPORT0_RSCLK, P_SPORT0_DRSEC, P_SPORT0_DTSEC, 0};
81
82unsigned short bfin_uart_pin_req_sport1[] =
83 {P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS, \
84 P_SPORT1_DRPRI, P_SPORT1_RSCLK, P_SPORT1_DRSEC, P_SPORT1_DTSEC, 0};
85
86#define DRV_NAME "bfin-sport-uart"
87
88struct sport_uart_port {
89 struct uart_port port;
90 char *name;
91
92 int tx_irq;
93 int rx_irq;
94 int err_irq;
95};
96
97static void sport_uart_tx_chars(struct sport_uart_port *up);
98static void sport_stop_tx(struct uart_port *port);
99
100static inline void tx_one_byte(struct sport_uart_port *up, unsigned int value)
101{
102 pr_debug("%s value:%x\n", __FUNCTION__, value);
103 /* Place a Start and Stop bit */
104 __asm__ volatile (
105 "R2 = b#01111111100;\n\t"
106 "R3 = b#10000000001;\n\t"
107 "%0 <<= 2;\n\t"
108 "%0 = %0 & R2;\n\t"
109 "%0 = %0 | R3;\n\t"
110 :"=r"(value)
111 :"0"(value)
112 :"R2", "R3");
113 pr_debug("%s value:%x\n", __FUNCTION__, value);
114
115 SPORT_PUT_TX(up, value);
116}
117
118static inline unsigned int rx_one_byte(struct sport_uart_port *up)
119{
120 unsigned int value, extract;
121
122 value = SPORT_GET_RX32(up);
123 pr_debug("%s value:%x\n", __FUNCTION__, value);
124
125 /* Extract 8 bits data */
126 __asm__ volatile (
127 "R5 = 0;\n\t"
128 "P0 = 8;\n\t"
129 "R1 = 0x1801(Z);\n\t"
130 "R3 = 0x0300(Z);\n\t"
131 "R4 = 0;\n\t"
132 "LSETUP(loop_s, loop_e) LC0 = P0;\nloop_s:\t"
133 "R2 = extract(%1, R1.L)(Z);\n\t"
134 "R2 <<= R4;\n\t"
135 "R5 = R5 | R2;\n\t"
136 "R1 = R1 - R3;\nloop_e:\t"
137 "R4 += 1;\n\t"
138 "%0 = R5;\n\t"
139 :"=r"(extract)
140 :"r"(value)
141 :"P0", "R1", "R2","R3","R4", "R5");
142
143 pr_debug(" extract:%x\n", extract);
144 return extract;
145}
146
147static int sport_uart_setup(struct sport_uart_port *up, int sclk, int baud_rate)
148{
149 int tclkdiv, tfsdiv, rclkdiv;
150
151 /* Set TCR1 and TCR2 */
152 SPORT_PUT_TCR1(up, (LTFS | ITFS | TFSR | TLSBIT | ITCLK));
153 SPORT_PUT_TCR2(up, 10);
154 pr_debug("%s TCR1:%x, TCR2:%x\n", __FUNCTION__, SPORT_GET_TCR1(up), SPORT_GET_TCR2(up));
155
156 /* Set RCR1 and RCR2 */
157 SPORT_PUT_RCR1(up, (RCKFE | LARFS | LRFS | RFSR | IRCLK));
158 SPORT_PUT_RCR2(up, 28);
159 pr_debug("%s RCR1:%x, RCR2:%x\n", __FUNCTION__, SPORT_GET_RCR1(up), SPORT_GET_RCR2(up));
160
161 tclkdiv = sclk/(2 * baud_rate) - 1;
162 tfsdiv = 12;
163 rclkdiv = sclk/(2 * baud_rate * 3) - 1;
164 SPORT_PUT_TCLKDIV(up, tclkdiv);
165 SPORT_PUT_TFSDIV(up, tfsdiv);
166 SPORT_PUT_RCLKDIV(up, rclkdiv);
167 SSYNC();
168 pr_debug("%s sclk:%d, baud_rate:%d, tclkdiv:%d, tfsdiv:%d, rclkdiv:%d\n",
169 __FUNCTION__, sclk, baud_rate, tclkdiv, tfsdiv, rclkdiv);
170
171 return 0;
172}
173
174static irqreturn_t sport_uart_rx_irq(int irq, void *dev_id)
175{
176 struct sport_uart_port *up = dev_id;
177 struct tty_struct *tty = up->port.info->tty;
178 unsigned int ch;
179
180 do {
181 ch = rx_one_byte(up);
182 up->port.icount.rx++;
183
184 if (uart_handle_sysrq_char(&up->port, ch))
185 ;
186 else
187 tty_insert_flip_char(tty, ch, TTY_NORMAL);
188 } while (SPORT_GET_STAT(up) & RXNE);
189 tty_flip_buffer_push(tty);
190
191 return IRQ_HANDLED;
192}
193
194static irqreturn_t sport_uart_tx_irq(int irq, void *dev_id)
195{
196 sport_uart_tx_chars(dev_id);
197
198 return IRQ_HANDLED;
199}
200
201static irqreturn_t sport_uart_err_irq(int irq, void *dev_id)
202{
203 struct sport_uart_port *up = dev_id;
204 struct tty_struct *tty = up->port.info->tty;
205 unsigned int stat = SPORT_GET_STAT(up);
206
207 /* Overflow in RX FIFO */
208 if (stat & ROVF) {
209 up->port.icount.overrun++;
210 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
211 SPORT_PUT_STAT(up, ROVF); /* Clear ROVF bit */
212 }
213 /* These should not happen */
214 if (stat & (TOVF | TUVF | RUVF)) {
215 printk(KERN_ERR "SPORT Error:%s %s %s\n",
216 (stat & TOVF)?"TX overflow":"",
217 (stat & TUVF)?"TX underflow":"",
218 (stat & RUVF)?"RX underflow":"");
219 SPORT_PUT_TCR1(up, SPORT_GET_TCR1(up) & ~TSPEN);
220 SPORT_PUT_RCR1(up, SPORT_GET_RCR1(up) & ~RSPEN);
221 }
222 SSYNC();
223
224 return IRQ_HANDLED;
225}
226
227/* Reqeust IRQ, Setup clock */
228static int sport_startup(struct uart_port *port)
229{
230 struct sport_uart_port *up = (struct sport_uart_port *)port;
231 char buffer[20];
232 int retval;
233
234 pr_debug("%s enter\n", __FUNCTION__);
235 memset(buffer, 20, '\0');
236 snprintf(buffer, 20, "%s rx", up->name);
237 retval = request_irq(up->rx_irq, sport_uart_rx_irq, IRQF_SAMPLE_RANDOM, buffer, up);
238 if (retval) {
239 printk(KERN_ERR "Unable to request interrupt %s\n", buffer);
240 return retval;
241 }
242
243 snprintf(buffer, 20, "%s tx", up->name);
244 retval = request_irq(up->tx_irq, sport_uart_tx_irq, IRQF_SAMPLE_RANDOM, buffer, up);
245 if (retval) {
246 printk(KERN_ERR "Unable to request interrupt %s\n", buffer);
247 goto fail1;
248 }
249
250 snprintf(buffer, 20, "%s err", up->name);
251 retval = request_irq(up->err_irq, sport_uart_err_irq, IRQF_SAMPLE_RANDOM, buffer, up);
252 if (retval) {
253 printk(KERN_ERR "Unable to request interrupt %s\n", buffer);
254 goto fail2;
255 }
256
257 if (port->line) {
258 if (peripheral_request_list(bfin_uart_pin_req_sport1, DRV_NAME))
259 goto fail3;
260 } else {
261 if (peripheral_request_list(bfin_uart_pin_req_sport0, DRV_NAME))
262 goto fail3;
263 }
264
265 sport_uart_setup(up, get_sclk(), port->uartclk);
266
267 /* Enable receive interrupt */
268 SPORT_PUT_RCR1(up, (SPORT_GET_RCR1(up) | RSPEN));
269 SSYNC();
270
271 return 0;
272
273
274fail3:
275 printk(KERN_ERR DRV_NAME
276 ": Requesting Peripherals failed\n");
277
278 free_irq(up->err_irq, up);
279fail2:
280 free_irq(up->tx_irq, up);
281fail1:
282 free_irq(up->rx_irq, up);
283
284 return retval;
285
286}
287
288static void sport_uart_tx_chars(struct sport_uart_port *up)
289{
290 struct circ_buf *xmit = &up->port.info->xmit;
291
292 if (SPORT_GET_STAT(up) & TXF)
293 return;
294
295 if (up->port.x_char) {
296 tx_one_byte(up, up->port.x_char);
297 up->port.icount.tx++;
298 up->port.x_char = 0;
299 return;
300 }
301
302 if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
303 sport_stop_tx(&up->port);
304 return;
305 }
306
307 while(!(SPORT_GET_STAT(up) & TXF) && !uart_circ_empty(xmit)) {
308 tx_one_byte(up, xmit->buf[xmit->tail]);
309 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE -1);
310 up->port.icount.tx++;
311 }
312
313 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
314 uart_write_wakeup(&up->port);
315}
316
317static unsigned int sport_tx_empty(struct uart_port *port)
318{
319 struct sport_uart_port *up = (struct sport_uart_port *)port;
320 unsigned int stat;
321
322 stat = SPORT_GET_STAT(up);
323 pr_debug("%s stat:%04x\n", __FUNCTION__, stat);
324 if (stat & TXHRE) {
325 return TIOCSER_TEMT;
326 } else
327 return 0;
328}
329
330static unsigned int sport_get_mctrl(struct uart_port *port)
331{
332 pr_debug("%s enter\n", __FUNCTION__);
333 return (TIOCM_CTS | TIOCM_CD | TIOCM_DSR);
334}
335
336static void sport_set_mctrl(struct uart_port *port, unsigned int mctrl)
337{
338 pr_debug("%s enter\n", __FUNCTION__);
339}
340
341static void sport_stop_tx(struct uart_port *port)
342{
343 struct sport_uart_port *up = (struct sport_uart_port *)port;
344 unsigned int stat;
345
346 pr_debug("%s enter\n", __FUNCTION__);
347
348 stat = SPORT_GET_STAT(up);
349 while(!(stat & TXHRE)) {
350 udelay(1);
351 stat = SPORT_GET_STAT(up);
352 }
353 /* Although the hold register is empty, last byte is still in shift
354 * register and not sent out yet. If baud rate is lower than default,
355 * delay should be longer. For example, if the baud rate is 9600,
356 * the delay must be at least 2ms by experience */
357 udelay(500);
358
359 SPORT_PUT_TCR1(up, (SPORT_GET_TCR1(up) & ~TSPEN));
360 SSYNC();
361
362 return;
363}
364
365static void sport_start_tx(struct uart_port *port)
366{
367 struct sport_uart_port *up = (struct sport_uart_port *)port;
368
369 pr_debug("%s enter\n", __FUNCTION__);
370 /* Write data into SPORT FIFO before enable SPROT to transmit */
371 sport_uart_tx_chars(up);
372
373 /* Enable transmit, then an interrupt will generated */
374 SPORT_PUT_TCR1(up, (SPORT_GET_TCR1(up) | TSPEN));
375 SSYNC();
376 pr_debug("%s exit\n", __FUNCTION__);
377}
378
379static void sport_stop_rx(struct uart_port *port)
380{
381 struct sport_uart_port *up = (struct sport_uart_port *)port;
382
383 pr_debug("%s enter\n", __FUNCTION__);
384 /* Disable sport to stop rx */
385 SPORT_PUT_RCR1(up, (SPORT_GET_RCR1(up) & ~RSPEN));
386 SSYNC();
387}
388
389static void sport_enable_ms(struct uart_port *port)
390{
391 pr_debug("%s enter\n", __FUNCTION__);
392}
393
394static void sport_break_ctl(struct uart_port *port, int break_state)
395{
396 pr_debug("%s enter\n", __FUNCTION__);
397}
398
399static void sport_shutdown(struct uart_port *port)
400{
401 struct sport_uart_port *up = (struct sport_uart_port *)port;
402
403 pr_debug("%s enter\n", __FUNCTION__);
404
405 /* Disable sport */
406 SPORT_PUT_TCR1(up, (SPORT_GET_TCR1(up) & ~TSPEN));
407 SPORT_PUT_RCR1(up, (SPORT_GET_RCR1(up) & ~RSPEN));
408 SSYNC();
409
410 if (port->line) {
411 peripheral_free_list(bfin_uart_pin_req_sport1);
412 } else {
413 peripheral_free_list(bfin_uart_pin_req_sport0);
414 }
415
416 free_irq(up->rx_irq, up);
417 free_irq(up->tx_irq, up);
418 free_irq(up->err_irq, up);
419}
420
421static void sport_set_termios(struct uart_port *port,
422 struct termios *termios, struct termios *old)
423{
424 pr_debug("%s enter, c_cflag:%08x\n", __FUNCTION__, termios->c_cflag);
425 uart_update_timeout(port, CS8 ,port->uartclk);
426}
427
428static const char *sport_type(struct uart_port *port)
429{
430 struct sport_uart_port *up = (struct sport_uart_port *)port;
431
432 pr_debug("%s enter\n", __FUNCTION__);
433 return up->name;
434}
435
436static void sport_release_port(struct uart_port *port)
437{
438 pr_debug("%s enter\n", __FUNCTION__);
439}
440
441static int sport_request_port(struct uart_port *port)
442{
443 pr_debug("%s enter\n", __FUNCTION__);
444 return 0;
445}
446
447static void sport_config_port(struct uart_port *port, int flags)
448{
449 struct sport_uart_port *up = (struct sport_uart_port *)port;
450
451 pr_debug("%s enter\n", __FUNCTION__);
452 up->port.type = PORT_BFIN_SPORT;
453}
454
455static int sport_verify_port(struct uart_port *port, struct serial_struct *ser)
456{
457 pr_debug("%s enter\n", __FUNCTION__);
458 return 0;
459}
460
461struct uart_ops sport_uart_ops = {
462 .tx_empty = sport_tx_empty,
463 .set_mctrl = sport_set_mctrl,
464 .get_mctrl = sport_get_mctrl,
465 .stop_tx = sport_stop_tx,
466 .start_tx = sport_start_tx,
467 .stop_rx = sport_stop_rx,
468 .enable_ms = sport_enable_ms,
469 .break_ctl = sport_break_ctl,
470 .startup = sport_startup,
471 .shutdown = sport_shutdown,
472 .set_termios = sport_set_termios,
473 .type = sport_type,
474 .release_port = sport_release_port,
475 .request_port = sport_request_port,
476 .config_port = sport_config_port,
477 .verify_port = sport_verify_port,
478};
479
480static struct sport_uart_port sport_uart_ports[] = {
481 { /* SPORT 0 */
482 .name = "SPORT0",
483 .tx_irq = IRQ_SPORT0_TX,
484 .rx_irq = IRQ_SPORT0_RX,
485 .err_irq= IRQ_SPORT0_ERROR,
486 .port = {
487 .type = PORT_BFIN_SPORT,
488 .iotype = UPIO_MEM,
489 .membase = (void __iomem *)SPORT0_TCR1,
490 .mapbase = SPORT0_TCR1,
491 .irq = IRQ_SPORT0_RX,
492 .uartclk = CONFIG_SPORT_BAUD_RATE,
493 .fifosize = 8,
494 .ops = &sport_uart_ops,
495 .line = 0,
496 },
497 }, { /* SPORT 1 */
498 .name = "SPORT1",
499 .tx_irq = IRQ_SPORT1_TX,
500 .rx_irq = IRQ_SPORT1_RX,
501 .err_irq= IRQ_SPORT1_ERROR,
502 .port = {
503 .type = PORT_BFIN_SPORT,
504 .iotype = UPIO_MEM,
505 .membase = (void __iomem *)SPORT1_TCR1,
506 .mapbase = SPORT1_TCR1,
507 .irq = IRQ_SPORT1_RX,
508 .uartclk = CONFIG_SPORT_BAUD_RATE,
509 .fifosize = 8,
510 .ops = &sport_uart_ops,
511 .line = 1,
512 },
513 }
514};
515
516static struct uart_driver sport_uart_reg = {
517 .owner = THIS_MODULE,
518 .driver_name = "SPORT-UART",
519 .dev_name = "ttySS",
520 .major = 204,
521 .minor = 84,
522 .nr = ARRAY_SIZE(sport_uart_ports),
523 .cons = NULL,
524};
525
526static int sport_uart_suspend(struct platform_device *dev, pm_message_t state)
527{
528 struct sport_uart_port *sport = platform_get_drvdata(dev);
529
530 pr_debug("%s enter\n", __FUNCTION__);
531 if (sport)
532 uart_suspend_port(&sport_uart_reg, &sport->port);
533
534 return 0;
535}
536
537static int sport_uart_resume(struct platform_device *dev)
538{
539 struct sport_uart_port *sport = platform_get_drvdata(dev);
540
541 pr_debug("%s enter\n", __FUNCTION__);
542 if (sport)
543 uart_resume_port(&sport_uart_reg, &sport->port);
544
545 return 0;
546}
547
548static int sport_uart_probe(struct platform_device *dev)
549{
550 pr_debug("%s enter\n", __FUNCTION__);
551 sport_uart_ports[dev->id].port.dev = &dev->dev;
552 uart_add_one_port(&sport_uart_reg, &sport_uart_ports[dev->id].port);
553 platform_set_drvdata(dev, &sport_uart_ports[dev->id]);
554
555 return 0;
556}
557
558static int sport_uart_remove(struct platform_device *dev)
559{
560 struct sport_uart_port *sport = platform_get_drvdata(dev);
561
562 pr_debug("%s enter\n", __FUNCTION__);
563 platform_set_drvdata(dev, NULL);
564
565 if (sport)
566 uart_remove_one_port(&sport_uart_reg, &sport->port);
567
568 return 0;
569}
570
571static struct platform_driver sport_uart_driver = {
572 .probe = sport_uart_probe,
573 .remove = sport_uart_remove,
574 .suspend = sport_uart_suspend,
575 .resume = sport_uart_resume,
576 .driver = {
577 .name = DRV_NAME,
578 },
579};
580
581static int __init sport_uart_init(void)
582{
583 int ret;
584
585 pr_debug("%s enter\n", __FUNCTION__);
586 ret = uart_register_driver(&sport_uart_reg);
587 if (ret != 0) {
588 printk(KERN_ERR "Failed to register %s:%d\n",
589 sport_uart_reg.driver_name, ret);
590 return ret;
591 }
592
593 ret = platform_driver_register(&sport_uart_driver);
594 if (ret != 0) {
595 printk(KERN_ERR "Failed to register sport uart driver:%d\n", ret);
596 uart_unregister_driver(&sport_uart_reg);
597 }
598
599
600 pr_debug("%s exit\n", __FUNCTION__);
601 return ret;
602}
603
604static void __exit sport_uart_exit(void)
605{
606 pr_debug("%s enter\n", __FUNCTION__);
607 platform_driver_unregister(&sport_uart_driver);
608 uart_unregister_driver(&sport_uart_reg);
609}
610
611module_init(sport_uart_init);
612module_exit(sport_uart_exit);
613
614MODULE_LICENSE("GPL");
diff --git a/drivers/serial/bfin_sport_uart.h b/drivers/serial/bfin_sport_uart.h
new file mode 100644
index 000000000000..671d41cc1a3f
--- /dev/null
+++ b/drivers/serial/bfin_sport_uart.h
@@ -0,0 +1,63 @@
1/*
2 * File: linux/drivers/serial/bfin_sport_uart.h
3 *
4 * Based on: include/asm-blackfin/mach-533/bfin_serial_5xx.h
5 * Author: Roy Huang <roy.huang>analog.com>
6 *
7 * Created: Nov 22, 2006
8 * Copyright: (C) Analog Device Inc.
9 * Description: this driver enable SPORTs on Blackfin emulate UART.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see the file COPYING, or write
23 * to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26
27
28#define OFFSET_TCR1 0x00 /* Transmit Configuration 1 Register */
29#define OFFSET_TCR2 0x04 /* Transmit Configuration 2 Register */
30#define OFFSET_TCLKDIV 0x08 /* Transmit Serial Clock Divider Register */
31#define OFFSET_TFSDIV 0x0C /* Transmit Frame Sync Divider Register */
32#define OFFSET_TX 0x10 /* Transmit Data Register */
33#define OFFSET_RX 0x18 /* Receive Data Register */
34#define OFFSET_RCR1 0x20 /* Receive Configuration 1 Register */
35#define OFFSET_RCR2 0x24 /* Receive Configuration 2 Register */
36#define OFFSET_RCLKDIV 0x28 /* Receive Serial Clock Divider Register */
37#define OFFSET_RFSDIV 0x2c /* Receive Frame Sync Divider Register */
38#define OFFSET_STAT 0x30 /* Status Register */
39
40#define SPORT_GET_TCR1(sport) bfin_read16(((sport)->port.membase + OFFSET_TCR1))
41#define SPORT_GET_TCR2(sport) bfin_read16(((sport)->port.membase + OFFSET_TCR2))
42#define SPORT_GET_TCLKDIV(sport) bfin_read16(((sport)->port.membase + OFFSET_TCLKDIV))
43#define SPORT_GET_TFSDIV(sport) bfin_read16(((sport)->port.membase + OFFSET_TFSDIV))
44#define SPORT_GET_TX(sport) bfin_read16(((sport)->port.membase + OFFSET_TX))
45#define SPORT_GET_RX(sport) bfin_read16(((sport)->port.membase + OFFSET_RX))
46#define SPORT_GET_RX32(sport) bfin_read32(((sport)->port.membase + OFFSET_RX))
47#define SPORT_GET_RCR1(sport) bfin_read16(((sport)->port.membase + OFFSET_RCR1))
48#define SPORT_GET_RCR2(sport) bfin_read16(((sport)->port.membase + OFFSET_RCR2))
49#define SPORT_GET_RCLKDIV(sport) bfin_read16(((sport)->port.membase + OFFSET_RCLKDIV))
50#define SPORT_GET_RFSDIV(sport) bfin_read16(((sport)->port.membase + OFFSET_RFSDIV))
51#define SPORT_GET_STAT(sport) bfin_read16(((sport)->port.membase + OFFSET_STAT))
52
53#define SPORT_PUT_TCR1(sport, v) bfin_write16(((sport)->port.membase + OFFSET_TCR1), v)
54#define SPORT_PUT_TCR2(sport, v) bfin_write16(((sport)->port.membase + OFFSET_TCR2), v)
55#define SPORT_PUT_TCLKDIV(sport, v) bfin_write16(((sport)->port.membase + OFFSET_TCLKDIV), v)
56#define SPORT_PUT_TFSDIV(sport, v) bfin_write16(((sport)->port.membase + OFFSET_TFSDIV), v)
57#define SPORT_PUT_TX(sport, v) bfin_write16(((sport)->port.membase + OFFSET_TX), v)
58#define SPORT_PUT_RX(sport, v) bfin_write16(((sport)->port.membase + OFFSET_RX), v)
59#define SPORT_PUT_RCR1(sport, v) bfin_write16(((sport)->port.membase + OFFSET_RCR1), v)
60#define SPORT_PUT_RCR2(sport, v) bfin_write16(((sport)->port.membase + OFFSET_RCR2), v)
61#define SPORT_PUT_RCLKDIV(sport, v) bfin_write16(((sport)->port.membase + OFFSET_RCLKDIV), v)
62#define SPORT_PUT_RFSDIV(sport, v) bfin_write16(((sport)->port.membase + OFFSET_RFSDIV), v)
63#define SPORT_PUT_STAT(sport, v) bfin_write16(((sport)->port.membase + OFFSET_STAT), v)
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index a638ba0679ac..a19dc7ef8861 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -1117,7 +1117,7 @@ int cpm_uart_drv_get_platform_data(struct platform_device *pdev, int is_con)
1117 1117
1118 line = cpm_uart_id2nr(idx); 1118 line = cpm_uart_id2nr(idx);
1119 if(line < 0) { 1119 if(line < 0) {
1120 printk(KERN_ERR"%s(): port %d is not registered", __FUNCTION__, idx); 1120 printk(KERN_ERR"%s(): port %d is not registered", __func__, idx);
1121 return -EINVAL; 1121 return -EINVAL;
1122 } 1122 }
1123 1123
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index 88e7c1d5b919..f9fa237aa949 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -1788,7 +1788,7 @@ static unsigned int handle_descr_data(struct e100_serial *info,
1788 1788
1789 if (info->recv_cnt + recvl > 65536) { 1789 if (info->recv_cnt + recvl > 65536) {
1790 printk(KERN_CRIT 1790 printk(KERN_CRIT
1791 "%s: Too much pending incoming serial data! Dropping %u bytes.\n", __FUNCTION__, recvl); 1791 "%s: Too much pending incoming serial data! Dropping %u bytes.\n", __func__, recvl);
1792 return 0; 1792 return 0;
1793 } 1793 }
1794 1794
@@ -1801,7 +1801,7 @@ static unsigned int handle_descr_data(struct e100_serial *info,
1801 append_recv_buffer(info, buffer); 1801 append_recv_buffer(info, buffer);
1802 1802
1803 if (!(buffer = alloc_recv_buffer(SERIAL_DESCR_BUF_SIZE))) 1803 if (!(buffer = alloc_recv_buffer(SERIAL_DESCR_BUF_SIZE)))
1804 panic("%s: Failed to allocate memory for receive buffer!\n", __FUNCTION__); 1804 panic("%s: Failed to allocate memory for receive buffer!\n", __func__);
1805 1805
1806 descr->buf = virt_to_phys(buffer->buffer); 1806 descr->buf = virt_to_phys(buffer->buffer);
1807 1807
@@ -1925,7 +1925,7 @@ static int start_recv_dma(struct e100_serial *info)
1925 /* Set up the receiving descriptors */ 1925 /* Set up the receiving descriptors */
1926 for (i = 0; i < SERIAL_RECV_DESCRIPTORS; i++) { 1926 for (i = 0; i < SERIAL_RECV_DESCRIPTORS; i++) {
1927 if (!(buffer = alloc_recv_buffer(SERIAL_DESCR_BUF_SIZE))) 1927 if (!(buffer = alloc_recv_buffer(SERIAL_DESCR_BUF_SIZE)))
1928 panic("%s: Failed to allocate memory for receive buffer!\n", __FUNCTION__); 1928 panic("%s: Failed to allocate memory for receive buffer!\n", __func__);
1929 1929
1930 descr[i].ctrl = d_int; 1930 descr[i].ctrl = d_int;
1931 descr[i].buf = virt_to_phys(buffer->buffer); 1931 descr[i].buf = virt_to_phys(buffer->buffer);
@@ -3581,8 +3581,9 @@ rs_tiocmset(struct tty_struct *tty, struct file *file,
3581 unsigned int set, unsigned int clear) 3581 unsigned int set, unsigned int clear)
3582{ 3582{
3583 struct e100_serial *info = (struct e100_serial *)tty->driver_data; 3583 struct e100_serial *info = (struct e100_serial *)tty->driver_data;
3584 unsigned long flags;
3584 3585
3585 lock_kernel(); 3586 local_irq_save(flags);
3586 3587
3587 if (clear & TIOCM_RTS) 3588 if (clear & TIOCM_RTS)
3588 e100_rts(info, 0); 3589 e100_rts(info, 0);
@@ -3604,7 +3605,7 @@ rs_tiocmset(struct tty_struct *tty, struct file *file,
3604 if (set & TIOCM_CD) 3605 if (set & TIOCM_CD)
3605 e100_cd_out(info, 1); 3606 e100_cd_out(info, 1);
3606 3607
3607 unlock_kernel(); 3608 local_irq_restore(flags);
3608 return 0; 3609 return 0;
3609} 3610}
3610 3611
@@ -3613,8 +3614,10 @@ rs_tiocmget(struct tty_struct *tty, struct file *file)
3613{ 3614{
3614 struct e100_serial *info = (struct e100_serial *)tty->driver_data; 3615 struct e100_serial *info = (struct e100_serial *)tty->driver_data;
3615 unsigned int result; 3616 unsigned int result;
3617 unsigned long flags;
3618
3619 local_irq_save(flags);
3616 3620
3617 lock_kernel();
3618 result = 3621 result =
3619 (!E100_RTS_GET(info) ? TIOCM_RTS : 0) 3622 (!E100_RTS_GET(info) ? TIOCM_RTS : 0)
3620 | (!E100_DTR_GET(info) ? TIOCM_DTR : 0) 3623 | (!E100_DTR_GET(info) ? TIOCM_DTR : 0)
@@ -3623,7 +3626,7 @@ rs_tiocmget(struct tty_struct *tty, struct file *file)
3623 | (!E100_CD_GET(info) ? TIOCM_CAR : 0) 3626 | (!E100_CD_GET(info) ? TIOCM_CAR : 0)
3624 | (!E100_CTS_GET(info) ? TIOCM_CTS : 0); 3627 | (!E100_CTS_GET(info) ? TIOCM_CTS : 0);
3625 3628
3626 unlock_kernel(); 3629 local_irq_restore(flags);
3627 3630
3628#ifdef SERIAL_DEBUG_IO 3631#ifdef SERIAL_DEBUG_IO
3629 printk(KERN_DEBUG "ser%i: modem state: %i 0x%08X\n", 3632 printk(KERN_DEBUG "ser%i: modem state: %i 0x%08X\n",
@@ -3702,10 +3705,6 @@ rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
3702{ 3705{
3703 struct e100_serial *info = (struct e100_serial *)tty->driver_data; 3706 struct e100_serial *info = (struct e100_serial *)tty->driver_data;
3704 3707
3705 if (tty->termios->c_cflag == old_termios->c_cflag &&
3706 tty->termios->c_iflag == old_termios->c_iflag)
3707 return;
3708
3709 change_speed(info); 3708 change_speed(info);
3710 3709
3711 /* Handle turning off CRTSCTS */ 3710 /* Handle turning off CRTSCTS */
@@ -3808,10 +3807,8 @@ rs_close(struct tty_struct *tty, struct file * filp)
3808#endif 3807#endif
3809 3808
3810 shutdown(info); 3809 shutdown(info);
3811 if (tty->driver->flush_buffer) 3810 rs_flush_buffer(tty);
3812 tty->driver->flush_buffer(tty); 3811 tty_ldisc_flush_buffer(tty);
3813 if (tty->ldisc.flush_buffer)
3814 tty->ldisc.flush_buffer(tty);
3815 tty->closing = 0; 3812 tty->closing = 0;
3816 info->event = 0; 3813 info->event = 0;
3817 info->tty = 0; 3814 info->tty = 0;
@@ -3885,6 +3882,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
3885 * Check R_DMA_CHx_STATUS bit 0-6=number of available bytes in FIFO 3882 * Check R_DMA_CHx_STATUS bit 0-6=number of available bytes in FIFO
3886 * R_DMA_CHx_HWSW bit 31-16=nbr of bytes left in DMA buffer (0=64k) 3883 * R_DMA_CHx_HWSW bit 31-16=nbr of bytes left in DMA buffer (0=64k)
3887 */ 3884 */
3885 lock_kernel();
3888 orig_jiffies = jiffies; 3886 orig_jiffies = jiffies;
3889 while (info->xmit.head != info->xmit.tail || /* More in send queue */ 3887 while (info->xmit.head != info->xmit.tail || /* More in send queue */
3890 (*info->ostatusadr & 0x007f) || /* more in FIFO */ 3888 (*info->ostatusadr & 0x007f) || /* more in FIFO */
@@ -3901,6 +3899,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
3901 curr_time_usec - info->last_tx_active_usec; 3899 curr_time_usec - info->last_tx_active_usec;
3902 } 3900 }
3903 set_current_state(TASK_RUNNING); 3901 set_current_state(TASK_RUNNING);
3902 unlock_kernel();
3904} 3903}
3905 3904
3906/* 3905/*
@@ -4520,7 +4519,7 @@ rs_init(void)
4520 4519
4521 if (request_irq(SERIAL_IRQ_NBR, ser_interrupt, 4520 if (request_irq(SERIAL_IRQ_NBR, ser_interrupt,
4522 IRQF_SHARED | IRQF_DISABLED, "serial ", driver)) 4521 IRQF_SHARED | IRQF_DISABLED, "serial ", driver))
4523 panic("%s: Failed to request irq8", __FUNCTION__); 4522 panic("%s: Failed to request irq8", __func__);
4524 4523
4525#endif 4524#endif
4526#endif /* CONFIG_SVINTO_SIM */ 4525#endif /* CONFIG_SVINTO_SIM */
diff --git a/drivers/serial/ioc3_serial.c b/drivers/serial/ioc3_serial.c
index 168073f12cec..4f1af71e9a1b 100644
--- a/drivers/serial/ioc3_serial.c
+++ b/drivers/serial/ioc3_serial.c
@@ -52,7 +52,7 @@ static unsigned int Submodule_slot;
52#define DPRINT_CONFIG(_x...) ; 52#define DPRINT_CONFIG(_x...) ;
53//#define DPRINT_CONFIG(_x...) printk _x 53//#define DPRINT_CONFIG(_x...) printk _x
54#define NOT_PROGRESS() ; 54#define NOT_PROGRESS() ;
55//#define NOT_PROGRESS() printk("%s : fails %d\n", __FUNCTION__, __LINE__) 55//#define NOT_PROGRESS() printk("%s : fails %d\n", __func__, __LINE__)
56 56
57/* number of characters we want to transmit to the lower level at a time */ 57/* number of characters we want to transmit to the lower level at a time */
58#define MAX_CHARS 256 58#define MAX_CHARS 256
@@ -445,7 +445,7 @@ static int inline port_init(struct ioc3_port *port)
445 sbbr_h = &idd->vma->sbbr_h; 445 sbbr_h = &idd->vma->sbbr_h;
446 ring_pci_addr = (unsigned long __iomem)port->ip_dma_ringbuf; 446 ring_pci_addr = (unsigned long __iomem)port->ip_dma_ringbuf;
447 DPRINT_CONFIG(("%s: ring_pci_addr 0x%p\n", 447 DPRINT_CONFIG(("%s: ring_pci_addr 0x%p\n",
448 __FUNCTION__, (void *)ring_pci_addr)); 448 __func__, (void *)ring_pci_addr));
449 449
450 writel((unsigned int)((uint64_t) ring_pci_addr >> 32), sbbr_h); 450 writel((unsigned int)((uint64_t) ring_pci_addr >> 32), sbbr_h);
451 writel((unsigned int)ring_pci_addr | BUF_SIZE_BIT, sbbr_l); 451 writel((unsigned int)ring_pci_addr | BUF_SIZE_BIT, sbbr_l);
@@ -593,7 +593,7 @@ config_port(struct ioc3_port *port,
593 593
594 DPRINT_CONFIG(("%s: line %d baud %d byte_size %d stop %d parenb %d " 594 DPRINT_CONFIG(("%s: line %d baud %d byte_size %d stop %d parenb %d "
595 "parodd %d\n", 595 "parodd %d\n",
596 __FUNCTION__, ((struct uart_port *)port->ip_port)->line, 596 __func__, ((struct uart_port *)port->ip_port)->line,
597 baud, byte_size, stop_bits, parenb, parodd)); 597 baud, byte_size, stop_bits, parenb, parodd));
598 598
599 if (set_baud(port, baud)) 599 if (set_baud(port, baud))
@@ -871,14 +871,14 @@ static int ioc3_set_proto(struct ioc3_port *port, int proto)
871 default: 871 default:
872 case PROTO_RS232: 872 case PROTO_RS232:
873 /* Clear the appropriate GIO pin */ 873 /* Clear the appropriate GIO pin */
874 DPRINT_CONFIG(("%s: rs232\n", __FUNCTION__)); 874 DPRINT_CONFIG(("%s: rs232\n", __func__));
875 writel(0, (&port->ip_idd->vma->gppr[0] 875 writel(0, (&port->ip_idd->vma->gppr[0]
876 + hooks->rs422_select_pin)); 876 + hooks->rs422_select_pin));
877 break; 877 break;
878 878
879 case PROTO_RS422: 879 case PROTO_RS422:
880 /* Set the appropriate GIO pin */ 880 /* Set the appropriate GIO pin */
881 DPRINT_CONFIG(("%s: rs422\n", __FUNCTION__)); 881 DPRINT_CONFIG(("%s: rs422\n", __func__));
882 writel(1, (&port->ip_idd->vma->gppr[0] 882 writel(1, (&port->ip_idd->vma->gppr[0]
883 + hooks->rs422_select_pin)); 883 + hooks->rs422_select_pin));
884 break; 884 break;
@@ -988,7 +988,7 @@ ioc3_change_speed(struct uart_port *the_port,
988 } 988 }
989 baud = uart_get_baud_rate(the_port, new_termios, old_termios, 989 baud = uart_get_baud_rate(the_port, new_termios, old_termios,
990 MIN_BAUD_SUPPORTED, MAX_BAUD_SUPPORTED); 990 MIN_BAUD_SUPPORTED, MAX_BAUD_SUPPORTED);
991 DPRINT_CONFIG(("%s: returned baud %d for line %d\n", __FUNCTION__, baud, 991 DPRINT_CONFIG(("%s: returned baud %d for line %d\n", __func__, baud,
992 the_port->line)); 992 the_port->line));
993 993
994 if (!the_port->fifosize) 994 if (!the_port->fifosize)
@@ -1026,7 +1026,7 @@ ioc3_change_speed(struct uart_port *the_port,
1026 DPRINT_CONFIG(("%s : port 0x%p line %d cflag 0%o " 1026 DPRINT_CONFIG(("%s : port 0x%p line %d cflag 0%o "
1027 "config_port(baud %d data %d stop %d penable %d " 1027 "config_port(baud %d data %d stop %d penable %d "
1028 " parity %d), notification 0x%x\n", 1028 " parity %d), notification 0x%x\n",
1029 __FUNCTION__, (void *)port, the_port->line, cflag, baud, 1029 __func__, (void *)port, the_port->line, cflag, baud,
1030 new_data, new_stop, new_parity_enable, new_parity, 1030 new_data, new_stop, new_parity_enable, new_parity,
1031 the_port->ignore_status_mask)); 1031 the_port->ignore_status_mask));
1032 1032
@@ -1919,7 +1919,7 @@ static inline int ioc3_serial_core_attach( struct ioc3_submodule *is,
1919 struct pci_dev *pdev = idd->pdev; 1919 struct pci_dev *pdev = idd->pdev;
1920 1920
1921 DPRINT_CONFIG(("%s: attach pdev 0x%p - card_ptr 0x%p\n", 1921 DPRINT_CONFIG(("%s: attach pdev 0x%p - card_ptr 0x%p\n",
1922 __FUNCTION__, pdev, (void *)card_ptr)); 1922 __func__, pdev, (void *)card_ptr));
1923 1923
1924 if (!card_ptr) 1924 if (!card_ptr)
1925 return -ENODEV; 1925 return -ENODEV;
@@ -1933,7 +1933,7 @@ static inline int ioc3_serial_core_attach( struct ioc3_submodule *is,
1933 port->ip_port = the_port; 1933 port->ip_port = the_port;
1934 1934
1935 DPRINT_CONFIG(("%s: attach the_port 0x%p / port 0x%p [%d/%d]\n", 1935 DPRINT_CONFIG(("%s: attach the_port 0x%p / port 0x%p [%d/%d]\n",
1936 __FUNCTION__, (void *)the_port, (void *)port, 1936 __func__, (void *)the_port, (void *)port,
1937 phys_port, ii)); 1937 phys_port, ii));
1938 1938
1939 /* membase, iobase and mapbase just need to be non-0 */ 1939 /* membase, iobase and mapbase just need to be non-0 */
@@ -1950,7 +1950,7 @@ static inline int ioc3_serial_core_attach( struct ioc3_submodule *is,
1950 if (uart_add_one_port(&ioc3_uart, the_port) < 0) { 1950 if (uart_add_one_port(&ioc3_uart, the_port) < 0) {
1951 printk(KERN_WARNING 1951 printk(KERN_WARNING
1952 "%s: unable to add port %d bus %d\n", 1952 "%s: unable to add port %d bus %d\n",
1953 __FUNCTION__, the_port->line, pdev->bus->number); 1953 __func__, the_port->line, pdev->bus->number);
1954 } else { 1954 } else {
1955 DPRINT_CONFIG(("IOC3 serial port %d irq %d bus %d\n", 1955 DPRINT_CONFIG(("IOC3 serial port %d irq %d bus %d\n",
1956 the_port->line, the_port->irq, pdev->bus->number)); 1956 the_port->line, the_port->irq, pdev->bus->number));
@@ -2017,7 +2017,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2017 struct ioc3_port *ports[PORTS_PER_CARD]; 2017 struct ioc3_port *ports[PORTS_PER_CARD];
2018 int phys_port; 2018 int phys_port;
2019 2019
2020 DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, is, idd)); 2020 DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __func__, is, idd));
2021 2021
2022 card_ptr = kzalloc(sizeof(struct ioc3_card), GFP_KERNEL); 2022 card_ptr = kzalloc(sizeof(struct ioc3_card), GFP_KERNEL);
2023 if (!card_ptr) { 2023 if (!card_ptr) {
@@ -2067,7 +2067,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2067 2067
2068 DPRINT_CONFIG(("%s : Port A ip_serial_regs 0x%p " 2068 DPRINT_CONFIG(("%s : Port A ip_serial_regs 0x%p "
2069 "ip_uart_regs 0x%p\n", 2069 "ip_uart_regs 0x%p\n",
2070 __FUNCTION__, 2070 __func__,
2071 (void *)port->ip_serial_regs, 2071 (void *)port->ip_serial_regs,
2072 (void *)port->ip_uart_regs)); 2072 (void *)port->ip_uart_regs));
2073 2073
@@ -2082,7 +2082,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2082 DPRINT_CONFIG(("%s : Port A ip_cpu_ringbuf 0x%p " 2082 DPRINT_CONFIG(("%s : Port A ip_cpu_ringbuf 0x%p "
2083 "ip_dma_ringbuf 0x%p, ip_inring 0x%p " 2083 "ip_dma_ringbuf 0x%p, ip_inring 0x%p "
2084 "ip_outring 0x%p\n", 2084 "ip_outring 0x%p\n",
2085 __FUNCTION__, 2085 __func__,
2086 (void *)port->ip_cpu_ringbuf, 2086 (void *)port->ip_cpu_ringbuf,
2087 (void *)port->ip_dma_ringbuf, 2087 (void *)port->ip_dma_ringbuf,
2088 (void *)port->ip_inring, 2088 (void *)port->ip_inring,
@@ -2094,7 +2094,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2094 2094
2095 DPRINT_CONFIG(("%s : Port B ip_serial_regs 0x%p " 2095 DPRINT_CONFIG(("%s : Port B ip_serial_regs 0x%p "
2096 "ip_uart_regs 0x%p\n", 2096 "ip_uart_regs 0x%p\n",
2097 __FUNCTION__, 2097 __func__,
2098 (void *)port->ip_serial_regs, 2098 (void *)port->ip_serial_regs,
2099 (void *)port->ip_uart_regs)); 2099 (void *)port->ip_uart_regs));
2100 2100
@@ -2108,7 +2108,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2108 DPRINT_CONFIG(("%s : Port B ip_cpu_ringbuf 0x%p " 2108 DPRINT_CONFIG(("%s : Port B ip_cpu_ringbuf 0x%p "
2109 "ip_dma_ringbuf 0x%p, ip_inring 0x%p " 2109 "ip_dma_ringbuf 0x%p, ip_inring 0x%p "
2110 "ip_outring 0x%p\n", 2110 "ip_outring 0x%p\n",
2111 __FUNCTION__, 2111 __func__,
2112 (void *)port->ip_cpu_ringbuf, 2112 (void *)port->ip_cpu_ringbuf,
2113 (void *)port->ip_dma_ringbuf, 2113 (void *)port->ip_dma_ringbuf,
2114 (void *)port->ip_inring, 2114 (void *)port->ip_inring,
@@ -2116,7 +2116,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2116 } 2116 }
2117 2117
2118 DPRINT_CONFIG(("%s : port %d [addr 0x%p] card_ptr 0x%p", 2118 DPRINT_CONFIG(("%s : port %d [addr 0x%p] card_ptr 0x%p",
2119 __FUNCTION__, 2119 __func__,
2120 phys_port, (void *)port, (void *)card_ptr)); 2120 phys_port, (void *)port, (void *)card_ptr));
2121 DPRINT_CONFIG((" ip_serial_regs 0x%p ip_uart_regs 0x%p\n", 2121 DPRINT_CONFIG((" ip_serial_regs 0x%p ip_uart_regs 0x%p\n",
2122 (void *)port->ip_serial_regs, 2122 (void *)port->ip_serial_regs,
@@ -2127,7 +2127,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2127 2127
2128 DPRINT_CONFIG(("%s: phys_port %d port 0x%p inring 0x%p " 2128 DPRINT_CONFIG(("%s: phys_port %d port 0x%p inring 0x%p "
2129 "outring 0x%p\n", 2129 "outring 0x%p\n",
2130 __FUNCTION__, 2130 __func__,
2131 phys_port, (void *)port, 2131 phys_port, (void *)port,
2132 (void *)port->ip_inring, 2132 (void *)port->ip_inring,
2133 (void *)port->ip_outring)); 2133 (void *)port->ip_outring));
@@ -2170,7 +2170,7 @@ static int __devinit ioc3uart_init(void)
2170 if ((ret = uart_register_driver(&ioc3_uart)) < 0) { 2170 if ((ret = uart_register_driver(&ioc3_uart)) < 0) {
2171 printk(KERN_WARNING 2171 printk(KERN_WARNING
2172 "%s: Couldn't register IOC3 uart serial driver\n", 2172 "%s: Couldn't register IOC3 uart serial driver\n",
2173 __FUNCTION__); 2173 __func__);
2174 return ret; 2174 return ret;
2175 } 2175 }
2176 ret = ioc3_register_submodule(&ioc3uart_submodule); 2176 ret = ioc3_register_submodule(&ioc3uart_submodule);
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index 0c179384fb0c..49b8a82b7b9f 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -889,7 +889,7 @@ static int inline port_init(struct ioc4_port *port)
889 889
890 ring_pci_addr = (unsigned long __iomem)port->ip_dma_ringbuf; 890 ring_pci_addr = (unsigned long __iomem)port->ip_dma_ringbuf;
891 DPRINT_CONFIG(("%s: ring_pci_addr 0x%lx\n", 891 DPRINT_CONFIG(("%s: ring_pci_addr 0x%lx\n",
892 __FUNCTION__, ring_pci_addr)); 892 __func__, ring_pci_addr));
893 893
894 writel((unsigned int)((uint64_t)ring_pci_addr >> 32), sbbr_h); 894 writel((unsigned int)((uint64_t)ring_pci_addr >> 32), sbbr_h);
895 writel((unsigned int)ring_pci_addr | IOC4_BUF_SIZE_BIT, sbbr_l); 895 writel((unsigned int)ring_pci_addr | IOC4_BUF_SIZE_BIT, sbbr_l);
@@ -1028,7 +1028,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
1028 spin_lock_irqsave(&soft->is_ir_lock, flag); 1028 spin_lock_irqsave(&soft->is_ir_lock, flag);
1029 printk ("%s : %d : mem 0x%p sio_ir 0x%x sio_ies 0x%x " 1029 printk ("%s : %d : mem 0x%p sio_ir 0x%x sio_ies 0x%x "
1030 "other_ir 0x%x other_ies 0x%x mask 0x%x\n", 1030 "other_ir 0x%x other_ies 0x%x mask 0x%x\n",
1031 __FUNCTION__, __LINE__, 1031 __func__, __LINE__,
1032 (void *)mem, readl(&mem->sio_ir.raw), 1032 (void *)mem, readl(&mem->sio_ir.raw),
1033 readl(&mem->sio_ies.raw), 1033 readl(&mem->sio_ies.raw),
1034 readl(&mem->other_ir.raw), 1034 readl(&mem->other_ir.raw),
@@ -1155,14 +1155,14 @@ static int inline ioc4_attach_local(struct ioc4_driver_data *idd)
1155 (TOTAL_RING_BUF_SIZE - 1)) == 0)); 1155 (TOTAL_RING_BUF_SIZE - 1)) == 0));
1156 DPRINT_CONFIG(("%s : ip_cpu_ringbuf 0x%p " 1156 DPRINT_CONFIG(("%s : ip_cpu_ringbuf 0x%p "
1157 "ip_dma_ringbuf 0x%p\n", 1157 "ip_dma_ringbuf 0x%p\n",
1158 __FUNCTION__, 1158 __func__,
1159 (void *)port->ip_cpu_ringbuf, 1159 (void *)port->ip_cpu_ringbuf,
1160 (void *)port->ip_dma_ringbuf)); 1160 (void *)port->ip_dma_ringbuf));
1161 port->ip_inring = RING(port, RX_0_OR_2); 1161 port->ip_inring = RING(port, RX_0_OR_2);
1162 port->ip_outring = RING(port, TX_0_OR_2); 1162 port->ip_outring = RING(port, TX_0_OR_2);
1163 } 1163 }
1164 DPRINT_CONFIG(("%s : port %d [addr 0x%p] control 0x%p", 1164 DPRINT_CONFIG(("%s : port %d [addr 0x%p] control 0x%p",
1165 __FUNCTION__, 1165 __func__,
1166 port_number, (void *)port, (void *)control)); 1166 port_number, (void *)port, (void *)control));
1167 DPRINT_CONFIG((" ip_serial_regs 0x%p ip_uart_regs 0x%p\n", 1167 DPRINT_CONFIG((" ip_serial_regs 0x%p ip_uart_regs 0x%p\n",
1168 (void *)port->ip_serial_regs, 1168 (void *)port->ip_serial_regs,
@@ -1173,7 +1173,7 @@ static int inline ioc4_attach_local(struct ioc4_driver_data *idd)
1173 1173
1174 DPRINT_CONFIG(("%s: port_number %d port 0x%p inring 0x%p " 1174 DPRINT_CONFIG(("%s: port_number %d port 0x%p inring 0x%p "
1175 "outring 0x%p\n", 1175 "outring 0x%p\n",
1176 __FUNCTION__, 1176 __func__,
1177 port_number, (void *)port, 1177 port_number, (void *)port,
1178 (void *)port->ip_inring, 1178 (void *)port->ip_inring,
1179 (void *)port->ip_outring)); 1179 (void *)port->ip_outring));
@@ -1317,7 +1317,7 @@ config_port(struct ioc4_port *port,
1317 int spiniter = 0; 1317 int spiniter = 0;
1318 1318
1319 DPRINT_CONFIG(("%s: baud %d byte_size %d stop %d parenb %d parodd %d\n", 1319 DPRINT_CONFIG(("%s: baud %d byte_size %d stop %d parenb %d parodd %d\n",
1320 __FUNCTION__, baud, byte_size, stop_bits, parenb, parodd)); 1320 __func__, baud, byte_size, stop_bits, parenb, parodd));
1321 1321
1322 if (set_baud(port, baud)) 1322 if (set_baud(port, baud))
1323 return 1; 1323 return 1;
@@ -1725,7 +1725,7 @@ ioc4_change_speed(struct uart_port *the_port,
1725 } 1725 }
1726 baud = uart_get_baud_rate(the_port, new_termios, old_termios, 1726 baud = uart_get_baud_rate(the_port, new_termios, old_termios,
1727 MIN_BAUD_SUPPORTED, MAX_BAUD_SUPPORTED); 1727 MIN_BAUD_SUPPORTED, MAX_BAUD_SUPPORTED);
1728 DPRINT_CONFIG(("%s: returned baud %d\n", __FUNCTION__, baud)); 1728 DPRINT_CONFIG(("%s: returned baud %d\n", __func__, baud));
1729 1729
1730 /* default is 9600 */ 1730 /* default is 9600 */
1731 if (!baud) 1731 if (!baud)
@@ -1765,7 +1765,7 @@ ioc4_change_speed(struct uart_port *the_port,
1765 DPRINT_CONFIG(("%s : port 0x%p cflag 0%o " 1765 DPRINT_CONFIG(("%s : port 0x%p cflag 0%o "
1766 "config_port(baud %d data %d stop %d p enable %d parity %d)," 1766 "config_port(baud %d data %d stop %d p enable %d parity %d),"
1767 " notification 0x%x\n", 1767 " notification 0x%x\n",
1768 __FUNCTION__, (void *)port, cflag, baud, new_data, new_stop, 1768 __func__, (void *)port, cflag, baud, new_data, new_stop,
1769 new_parity_enable, new_parity, the_port->ignore_status_mask)); 1769 new_parity_enable, new_parity, the_port->ignore_status_mask));
1770 1770
1771 if ((config_port(port, baud, /* baud */ 1771 if ((config_port(port, baud, /* baud */
@@ -2715,7 +2715,7 @@ ioc4_serial_core_attach(struct pci_dev *pdev, int port_type)
2715 2715
2716 2716
2717 DPRINT_CONFIG(("%s: attach pdev 0x%p - control 0x%p\n", 2717 DPRINT_CONFIG(("%s: attach pdev 0x%p - control 0x%p\n",
2718 __FUNCTION__, pdev, (void *)control)); 2718 __func__, pdev, (void *)control));
2719 2719
2720 if (!control) 2720 if (!control)
2721 return -ENODEV; 2721 return -ENODEV;
@@ -2734,7 +2734,7 @@ ioc4_serial_core_attach(struct pci_dev *pdev, int port_type)
2734 port->ip_all_ports[port_type_idx] = the_port; 2734 port->ip_all_ports[port_type_idx] = the_port;
2735 2735
2736 DPRINT_CONFIG(("%s: attach the_port 0x%p / port 0x%p : type %s\n", 2736 DPRINT_CONFIG(("%s: attach the_port 0x%p / port 0x%p : type %s\n",
2737 __FUNCTION__, (void *)the_port, 2737 __func__, (void *)the_port,
2738 (void *)port, 2738 (void *)port,
2739 port_type == PROTO_RS232 ? "rs232" : "rs422")); 2739 port_type == PROTO_RS232 ? "rs232" : "rs422"));
2740 2740
@@ -2752,7 +2752,7 @@ ioc4_serial_core_attach(struct pci_dev *pdev, int port_type)
2752 if (uart_add_one_port(u_driver, the_port) < 0) { 2752 if (uart_add_one_port(u_driver, the_port) < 0) {
2753 printk(KERN_WARNING 2753 printk(KERN_WARNING
2754 "%s: unable to add port %d bus %d\n", 2754 "%s: unable to add port %d bus %d\n",
2755 __FUNCTION__, the_port->line, pdev->bus->number); 2755 __func__, the_port->line, pdev->bus->number);
2756 } else { 2756 } else {
2757 DPRINT_CONFIG( 2757 DPRINT_CONFIG(
2758 ("IOC4 serial port %d irq = %d, bus %d\n", 2758 ("IOC4 serial port %d irq = %d, bus %d\n",
@@ -2777,7 +2777,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
2777 int ret = 0; 2777 int ret = 0;
2778 2778
2779 2779
2780 DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, idd->idd_pdev, 2780 DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __func__, idd->idd_pdev,
2781 idd->idd_pci_id)); 2781 idd->idd_pci_id));
2782 2782
2783 /* PCI-RT does not bring out serial connections. 2783 /* PCI-RT does not bring out serial connections.
@@ -2806,7 +2806,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
2806 goto out2; 2806 goto out2;
2807 } 2807 }
2808 DPRINT_CONFIG(("%s : mem 0x%p, serial 0x%p\n", 2808 DPRINT_CONFIG(("%s : mem 0x%p, serial 0x%p\n",
2809 __FUNCTION__, (void *)idd->idd_misc_regs, 2809 __func__, (void *)idd->idd_misc_regs,
2810 (void *)serial)); 2810 (void *)serial));
2811 2811
2812 /* Get memory for the new card */ 2812 /* Get memory for the new card */
@@ -2858,7 +2858,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
2858 } else { 2858 } else {
2859 printk(KERN_WARNING 2859 printk(KERN_WARNING
2860 "%s : request_irq fails for IRQ 0x%x\n ", 2860 "%s : request_irq fails for IRQ 0x%x\n ",
2861 __FUNCTION__, idd->idd_pdev->irq); 2861 __func__, idd->idd_pdev->irq);
2862 } 2862 }
2863 ret = ioc4_attach_local(idd); 2863 ret = ioc4_attach_local(idd);
2864 if (ret) 2864 if (ret)
@@ -2911,13 +2911,13 @@ int ioc4_serial_init(void)
2911 if ((ret = uart_register_driver(&ioc4_uart_rs232)) < 0) { 2911 if ((ret = uart_register_driver(&ioc4_uart_rs232)) < 0) {
2912 printk(KERN_WARNING 2912 printk(KERN_WARNING
2913 "%s: Couldn't register rs232 IOC4 serial driver\n", 2913 "%s: Couldn't register rs232 IOC4 serial driver\n",
2914 __FUNCTION__); 2914 __func__);
2915 return ret; 2915 return ret;
2916 } 2916 }
2917 if ((ret = uart_register_driver(&ioc4_uart_rs422)) < 0) { 2917 if ((ret = uart_register_driver(&ioc4_uart_rs422)) < 0) {
2918 printk(KERN_WARNING 2918 printk(KERN_WARNING
2919 "%s: Couldn't register rs422 IOC4 serial driver\n", 2919 "%s: Couldn't register rs422 IOC4 serial driver\n",
2920 __FUNCTION__); 2920 __func__);
2921 return ret; 2921 return ret;
2922 } 2922 }
2923 2923
diff --git a/drivers/serial/kgdboc.c b/drivers/serial/kgdboc.c
index 9cf03327386a..eadc1ab6bbce 100644
--- a/drivers/serial/kgdboc.c
+++ b/drivers/serial/kgdboc.c
@@ -96,12 +96,14 @@ static void cleanup_kgdboc(void)
96 96
97static int kgdboc_get_char(void) 97static int kgdboc_get_char(void)
98{ 98{
99 return kgdb_tty_driver->poll_get_char(kgdb_tty_driver, kgdb_tty_line); 99 return kgdb_tty_driver->ops->poll_get_char(kgdb_tty_driver,
100 kgdb_tty_line);
100} 101}
101 102
102static void kgdboc_put_char(u8 chr) 103static void kgdboc_put_char(u8 chr)
103{ 104{
104 kgdb_tty_driver->poll_put_char(kgdb_tty_driver, kgdb_tty_line, chr); 105 kgdb_tty_driver->ops->poll_put_char(kgdb_tty_driver,
106 kgdb_tty_line, chr);
105} 107}
106 108
107static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp) 109static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
index ddd3aa50d4ad..43af40d59b8a 100644
--- a/drivers/serial/mcfserial.c
+++ b/drivers/serial/mcfserial.c
@@ -1072,18 +1072,6 @@ static int mcfrs_ioctl(struct tty_struct *tty, struct file * file,
1072 tty_wait_until_sent(tty, 0); 1072 tty_wait_until_sent(tty, 0);
1073 send_break(info, arg ? arg*(HZ/10) : HZ/4); 1073 send_break(info, arg ? arg*(HZ/10) : HZ/4);
1074 return 0; 1074 return 0;
1075 case TIOCGSOFTCAR:
1076 error = put_user(C_CLOCAL(tty) ? 1 : 0,
1077 (unsigned long *) arg);
1078 if (error)
1079 return error;
1080 return 0;
1081 case TIOCSSOFTCAR:
1082 get_user(arg, (unsigned long *) arg);
1083 tty->termios->c_cflag =
1084 ((tty->termios->c_cflag & ~CLOCAL) |
1085 (arg ? CLOCAL : 0));
1086 return 0;
1087 case TIOCGSERIAL: 1075 case TIOCGSERIAL:
1088 if (access_ok(VERIFY_WRITE, (void *) arg, 1076 if (access_ok(VERIFY_WRITE, (void *) arg,
1089 sizeof(struct serial_struct))) 1077 sizeof(struct serial_struct)))
@@ -1222,8 +1210,7 @@ static void mcfrs_close(struct tty_struct *tty, struct file * filp)
1222 } else 1210 } else
1223#endif 1211#endif
1224 shutdown(info); 1212 shutdown(info);
1225 if (tty->driver->flush_buffer) 1213 mcfrs_flush_buffer(tty);
1226 tty->driver->flush_buffer(tty);
1227 tty_ldisc_flush(tty); 1214 tty_ldisc_flush(tty);
1228 1215
1229 tty->closing = 0; 1216 tty->closing = 0;
@@ -1276,6 +1263,8 @@ mcfrs_wait_until_sent(struct tty_struct *tty, int timeout)
1276 * Note: we have to use pretty tight timings here to satisfy 1263 * Note: we have to use pretty tight timings here to satisfy
1277 * the NIST-PCTS. 1264 * the NIST-PCTS.
1278 */ 1265 */
1266 lock_kernel();
1267
1279 fifo_time = (MCF5272_FIFO_SIZE * HZ * 10) / info->baud; 1268 fifo_time = (MCF5272_FIFO_SIZE * HZ * 10) / info->baud;
1280 char_time = fifo_time / 5; 1269 char_time = fifo_time / 5;
1281 if (char_time == 0) 1270 if (char_time == 0)
@@ -1312,6 +1301,7 @@ mcfrs_wait_until_sent(struct tty_struct *tty, int timeout)
1312 if (timeout && time_after(jiffies, orig_jiffies + timeout)) 1301 if (timeout && time_after(jiffies, orig_jiffies + timeout))
1313 break; 1302 break;
1314 } 1303 }
1304 unlock_kernel();
1315#else 1305#else
1316 /* 1306 /*
1317 * For the other coldfire models, assume all data has been sent 1307 * For the other coldfire models, assume all data has been sent
@@ -1907,7 +1897,7 @@ static struct tty_driver *mcfrs_console_device(struct console *c, int *index)
1907 * This is used for console output. 1897 * This is used for console output.
1908 */ 1898 */
1909 1899
1910void mcfrs_put_char(char ch) 1900int mcfrs_put_char(char ch)
1911{ 1901{
1912 volatile unsigned char *uartp; 1902 volatile unsigned char *uartp;
1913 unsigned long flags; 1903 unsigned long flags;
@@ -1931,7 +1921,7 @@ void mcfrs_put_char(char ch)
1931 mcfrs_init_console(); /* try and get it back */ 1921 mcfrs_init_console(); /* try and get it back */
1932 local_irq_restore(flags); 1922 local_irq_restore(flags);
1933 1923
1934 return; 1924 return 1;
1935} 1925}
1936 1926
1937 1927
diff --git a/drivers/serial/netx-serial.c b/drivers/serial/netx-serial.c
index 3123ffeac8ad..81ac9bb4f39b 100644
--- a/drivers/serial/netx-serial.c
+++ b/drivers/serial/netx-serial.c
@@ -287,6 +287,7 @@ static void netx_set_mctrl(struct uart_port *port, unsigned int mctrl)
287{ 287{
288 unsigned int val; 288 unsigned int val;
289 289
290 /* FIXME: Locking needed ? */
290 if (mctrl & TIOCM_RTS) { 291 if (mctrl & TIOCM_RTS) {
291 val = readl(port->membase + UART_RTS_CR); 292 val = readl(port->membase + UART_RTS_CR);
292 writel(val | RTS_CR_RTS, port->membase + UART_RTS_CR); 293 writel(val | RTS_CR_RTS, port->membase + UART_RTS_CR);
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index 4ffa2585429a..2b6a013639e6 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -1022,6 +1022,7 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
1022 struct uart_port *port = &ourport->port; 1022 struct uart_port *port = &ourport->port;
1023 struct s3c2410_uartcfg *cfg; 1023 struct s3c2410_uartcfg *cfg;
1024 struct resource *res; 1024 struct resource *res;
1025 int ret;
1025 1026
1026 dbg("s3c24xx_serial_init_port: port=%p, platdev=%p\n", port, platdev); 1027 dbg("s3c24xx_serial_init_port: port=%p, platdev=%p\n", port, platdev);
1027 1028
@@ -1064,9 +1065,11 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
1064 1065
1065 port->mapbase = res->start; 1066 port->mapbase = res->start;
1066 port->membase = S3C24XX_VA_UART + (res->start - S3C24XX_PA_UART); 1067 port->membase = S3C24XX_VA_UART + (res->start - S3C24XX_PA_UART);
1067 port->irq = platform_get_irq(platdev, 0); 1068 ret = platform_get_irq(platdev, 0);
1068 if (port->irq < 0) 1069 if (ret < 0)
1069 port->irq = 0; 1070 port->irq = 0;
1071 else
1072 port->irq = ret;
1070 1073
1071 ourport->clk = clk_get(&platdev->dev, "uart"); 1074 ourport->clk = clk_get(&platdev->dev, "uart");
1072 1075
@@ -1093,13 +1096,13 @@ static int s3c24xx_serial_probe(struct platform_device *dev,
1093 ourport = &s3c24xx_serial_ports[probe_index]; 1096 ourport = &s3c24xx_serial_ports[probe_index];
1094 probe_index++; 1097 probe_index++;
1095 1098
1096 dbg("%s: initialising port %p...\n", __FUNCTION__, ourport); 1099 dbg("%s: initialising port %p...\n", __func__, ourport);
1097 1100
1098 ret = s3c24xx_serial_init_port(ourport, info, dev); 1101 ret = s3c24xx_serial_init_port(ourport, info, dev);
1099 if (ret < 0) 1102 if (ret < 0)
1100 goto probe_err; 1103 goto probe_err;
1101 1104
1102 dbg("%s: adding port\n", __FUNCTION__); 1105 dbg("%s: adding port\n", __func__);
1103 uart_add_one_port(&s3c24xx_uart_drv, &ourport->port); 1106 uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
1104 platform_set_drvdata(dev, &ourport->port); 1107 platform_set_drvdata(dev, &ourport->port);
1105 1108
@@ -1584,7 +1587,7 @@ static int s3c2412_serial_resetport(struct uart_port *port,
1584 unsigned long ucon = rd_regl(port, S3C2410_UCON); 1587 unsigned long ucon = rd_regl(port, S3C2410_UCON);
1585 1588
1586 dbg("%s: port=%p (%08lx), cfg=%p\n", 1589 dbg("%s: port=%p (%08lx), cfg=%p\n",
1587 __FUNCTION__, port, port->mapbase, cfg); 1590 __func__, port, port->mapbase, cfg);
1588 1591
1589 /* ensure we don't change the clock settings... */ 1592 /* ensure we don't change the clock settings... */
1590 1593
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
index 67b2338913c2..62b38582f5e9 100644
--- a/drivers/serial/sa1100.c
+++ b/drivers/serial/sa1100.c
@@ -655,7 +655,7 @@ void __init sa1100_register_uart_fns(struct sa1100_port_fns *fns)
655void __init sa1100_register_uart(int idx, int port) 655void __init sa1100_register_uart(int idx, int port)
656{ 656{
657 if (idx >= NR_PORTS) { 657 if (idx >= NR_PORTS) {
658 printk(KERN_ERR "%s: bad index number %d\n", __FUNCTION__, idx); 658 printk(KERN_ERR "%s: bad index number %d\n", __func__, idx);
659 return; 659 return;
660 } 660 }
661 661
@@ -682,7 +682,7 @@ void __init sa1100_register_uart(int idx, int port)
682 break; 682 break;
683 683
684 default: 684 default:
685 printk(KERN_ERR "%s: bad port number %d\n", __FUNCTION__, port); 685 printk(KERN_ERR "%s: bad port number %d\n", __func__, port);
686 } 686 }
687} 687}
688 688
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 977ce820ce30..1e2b9d826f69 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -422,6 +422,7 @@ uart_get_divisor(struct uart_port *port, unsigned int baud)
422 422
423EXPORT_SYMBOL(uart_get_divisor); 423EXPORT_SYMBOL(uart_get_divisor);
424 424
425/* FIXME: Consistent locking policy */
425static void 426static void
426uart_change_speed(struct uart_state *state, struct ktermios *old_termios) 427uart_change_speed(struct uart_state *state, struct ktermios *old_termios)
427{ 428{
@@ -454,27 +455,30 @@ uart_change_speed(struct uart_state *state, struct ktermios *old_termios)
454 port->ops->set_termios(port, termios, old_termios); 455 port->ops->set_termios(port, termios, old_termios);
455} 456}
456 457
457static inline void 458static inline int
458__uart_put_char(struct uart_port *port, struct circ_buf *circ, unsigned char c) 459__uart_put_char(struct uart_port *port, struct circ_buf *circ, unsigned char c)
459{ 460{
460 unsigned long flags; 461 unsigned long flags;
462 int ret = 0;
461 463
462 if (!circ->buf) 464 if (!circ->buf)
463 return; 465 return 0;
464 466
465 spin_lock_irqsave(&port->lock, flags); 467 spin_lock_irqsave(&port->lock, flags);
466 if (uart_circ_chars_free(circ) != 0) { 468 if (uart_circ_chars_free(circ) != 0) {
467 circ->buf[circ->head] = c; 469 circ->buf[circ->head] = c;
468 circ->head = (circ->head + 1) & (UART_XMIT_SIZE - 1); 470 circ->head = (circ->head + 1) & (UART_XMIT_SIZE - 1);
471 ret = 1;
469 } 472 }
470 spin_unlock_irqrestore(&port->lock, flags); 473 spin_unlock_irqrestore(&port->lock, flags);
474 return ret;
471} 475}
472 476
473static void uart_put_char(struct tty_struct *tty, unsigned char ch) 477static int uart_put_char(struct tty_struct *tty, unsigned char ch)
474{ 478{
475 struct uart_state *state = tty->driver_data; 479 struct uart_state *state = tty->driver_data;
476 480
477 __uart_put_char(state->port, &state->info->xmit, ch); 481 return __uart_put_char(state->port, &state->info->xmit, ch);
478} 482}
479 483
480static void uart_flush_chars(struct tty_struct *tty) 484static void uart_flush_chars(struct tty_struct *tty)
@@ -528,15 +532,25 @@ uart_write(struct tty_struct *tty, const unsigned char *buf, int count)
528static int uart_write_room(struct tty_struct *tty) 532static int uart_write_room(struct tty_struct *tty)
529{ 533{
530 struct uart_state *state = tty->driver_data; 534 struct uart_state *state = tty->driver_data;
535 unsigned long flags;
536 int ret;
531 537
532 return uart_circ_chars_free(&state->info->xmit); 538 spin_lock_irqsave(&state->port->lock, flags);
539 ret = uart_circ_chars_free(&state->info->xmit);
540 spin_unlock_irqrestore(&state->port->lock, flags);
541 return ret;
533} 542}
534 543
535static int uart_chars_in_buffer(struct tty_struct *tty) 544static int uart_chars_in_buffer(struct tty_struct *tty)
536{ 545{
537 struct uart_state *state = tty->driver_data; 546 struct uart_state *state = tty->driver_data;
547 unsigned long flags;
548 int ret;
538 549
539 return uart_circ_chars_pending(&state->info->xmit); 550 spin_lock_irqsave(&state->port->lock, flags);
551 ret = uart_circ_chars_pending(&state->info->xmit);
552 spin_unlock_irqrestore(&state->port->lock, flags);
553 return ret;
540} 554}
541 555
542static void uart_flush_buffer(struct tty_struct *tty) 556static void uart_flush_buffer(struct tty_struct *tty)
@@ -618,6 +632,11 @@ static int uart_get_info(struct uart_state *state,
618 struct serial_struct tmp; 632 struct serial_struct tmp;
619 633
620 memset(&tmp, 0, sizeof(tmp)); 634 memset(&tmp, 0, sizeof(tmp));
635
636 /* Ensure the state we copy is consistent and no hardware changes
637 occur as we go */
638 mutex_lock(&state->mutex);
639
621 tmp.type = port->type; 640 tmp.type = port->type;
622 tmp.line = port->line; 641 tmp.line = port->line;
623 tmp.port = port->iobase; 642 tmp.port = port->iobase;
@@ -637,6 +656,8 @@ static int uart_get_info(struct uart_state *state,
637 tmp.iomem_reg_shift = port->regshift; 656 tmp.iomem_reg_shift = port->regshift;
638 tmp.iomem_base = (void *)(unsigned long)port->mapbase; 657 tmp.iomem_base = (void *)(unsigned long)port->mapbase;
639 658
659 mutex_unlock(&state->mutex);
660
640 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 661 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
641 return -EFAULT; 662 return -EFAULT;
642 return 0; 663 return 0;
@@ -914,8 +935,6 @@ static void uart_break_ctl(struct tty_struct *tty, int break_state)
914 struct uart_state *state = tty->driver_data; 935 struct uart_state *state = tty->driver_data;
915 struct uart_port *port = state->port; 936 struct uart_port *port = state->port;
916 937
917 BUG_ON(!kernel_locked());
918
919 mutex_lock(&state->mutex); 938 mutex_lock(&state->mutex);
920 939
921 if (port->type != PORT_UNKNOWN) 940 if (port->type != PORT_UNKNOWN)
@@ -1059,7 +1078,7 @@ static int uart_get_count(struct uart_state *state,
1059} 1078}
1060 1079
1061/* 1080/*
1062 * Called via sys_ioctl under the BKL. We can use spin_lock_irq() here. 1081 * Called via sys_ioctl. We can use spin_lock_irq() here.
1063 */ 1082 */
1064static int 1083static int
1065uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, 1084uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd,
@@ -1069,7 +1088,6 @@ uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd,
1069 void __user *uarg = (void __user *)arg; 1088 void __user *uarg = (void __user *)arg;
1070 int ret = -ENOIOCTLCMD; 1089 int ret = -ENOIOCTLCMD;
1071 1090
1072 BUG_ON(!kernel_locked());
1073 1091
1074 /* 1092 /*
1075 * These ioctls don't rely on the hardware to be present. 1093 * These ioctls don't rely on the hardware to be present.
@@ -1140,9 +1158,9 @@ uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd,
1140 break; 1158 break;
1141 } 1159 }
1142 } 1160 }
1143 out_up: 1161out_up:
1144 mutex_unlock(&state->mutex); 1162 mutex_unlock(&state->mutex);
1145 out: 1163out:
1146 return ret; 1164 return ret;
1147} 1165}
1148 1166
@@ -1153,7 +1171,6 @@ static void uart_set_termios(struct tty_struct *tty,
1153 unsigned long flags; 1171 unsigned long flags;
1154 unsigned int cflag = tty->termios->c_cflag; 1172 unsigned int cflag = tty->termios->c_cflag;
1155 1173
1156 BUG_ON(!kernel_locked());
1157 1174
1158 /* 1175 /*
1159 * These are the bits that are used to setup various 1176 * These are the bits that are used to setup various
@@ -1165,8 +1182,9 @@ static void uart_set_termios(struct tty_struct *tty,
1165 if ((cflag ^ old_termios->c_cflag) == 0 && 1182 if ((cflag ^ old_termios->c_cflag) == 0 &&
1166 tty->termios->c_ospeed == old_termios->c_ospeed && 1183 tty->termios->c_ospeed == old_termios->c_ospeed &&
1167 tty->termios->c_ispeed == old_termios->c_ispeed && 1184 tty->termios->c_ispeed == old_termios->c_ispeed &&
1168 RELEVANT_IFLAG(tty->termios->c_iflag ^ old_termios->c_iflag) == 0) 1185 RELEVANT_IFLAG(tty->termios->c_iflag ^ old_termios->c_iflag) == 0) {
1169 return; 1186 return;
1187 }
1170 1188
1171 uart_change_speed(state, old_termios); 1189 uart_change_speed(state, old_termios);
1172 1190
@@ -1200,7 +1218,6 @@ static void uart_set_termios(struct tty_struct *tty,
1200 } 1218 }
1201 spin_unlock_irqrestore(&state->port->lock, flags); 1219 spin_unlock_irqrestore(&state->port->lock, flags);
1202 } 1220 }
1203
1204#if 0 1221#if 0
1205 /* 1222 /*
1206 * No need to wake up processes in open wait, since they 1223 * No need to wake up processes in open wait, since they
@@ -1316,11 +1333,11 @@ static void uart_wait_until_sent(struct tty_struct *tty, int timeout)
1316 struct uart_port *port = state->port; 1333 struct uart_port *port = state->port;
1317 unsigned long char_time, expire; 1334 unsigned long char_time, expire;
1318 1335
1319 BUG_ON(!kernel_locked());
1320
1321 if (port->type == PORT_UNKNOWN || port->fifosize == 0) 1336 if (port->type == PORT_UNKNOWN || port->fifosize == 0)
1322 return; 1337 return;
1323 1338
1339 lock_kernel();
1340
1324 /* 1341 /*
1325 * Set the check interval to be 1/5 of the estimated time to 1342 * Set the check interval to be 1/5 of the estimated time to
1326 * send a single character, and make it at least 1. The check 1343 * send a single character, and make it at least 1. The check
@@ -1366,6 +1383,7 @@ static void uart_wait_until_sent(struct tty_struct *tty, int timeout)
1366 break; 1383 break;
1367 } 1384 }
1368 set_current_state(TASK_RUNNING); /* might not be needed */ 1385 set_current_state(TASK_RUNNING); /* might not be needed */
1386 unlock_kernel();
1369} 1387}
1370 1388
1371/* 1389/*
@@ -2079,7 +2097,9 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *port)
2079 int ret; 2097 int ret;
2080 2098
2081 uart_change_pm(state, 0); 2099 uart_change_pm(state, 0);
2100 spin_lock_irq(&port->lock);
2082 ops->set_mctrl(port, 0); 2101 ops->set_mctrl(port, 0);
2102 spin_unlock_irq(&port->lock);
2083 ret = ops->startup(port); 2103 ret = ops->startup(port);
2084 if (ret == 0) { 2104 if (ret == 0) {
2085 uart_change_speed(state, NULL); 2105 uart_change_speed(state, NULL);
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index c2ea5d4df44a..969106187718 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -855,7 +855,7 @@ static int sci_notifier(struct notifier_block *self,
855 855
856 printk(KERN_INFO "%s: got a postchange notification " 856 printk(KERN_INFO "%s: got a postchange notification "
857 "for cpu %d (old %d, new %d)\n", 857 "for cpu %d (old %d, new %d)\n",
858 __FUNCTION__, freqs->cpu, freqs->old, freqs->new); 858 __func__, freqs->cpu, freqs->old, freqs->new);
859 } 859 }
860 860
861 return NOTIFY_OK; 861 return NOTIFY_OK;
diff --git a/drivers/serial/sn_console.c b/drivers/serial/sn_console.c
index 41fc61264443..019da2e05f0b 100644
--- a/drivers/serial/sn_console.c
+++ b/drivers/serial/sn_console.c
@@ -839,7 +839,7 @@ static int __init sn_sal_module_init(void)
839 839
840 if (uart_add_one_port(&sal_console_uart, &sal_console_port.sc_port) < 0) { 840 if (uart_add_one_port(&sal_console_uart, &sal_console_port.sc_port) < 0) {
841 /* error - not sure what I'd do - so I'll do nothing */ 841 /* error - not sure what I'd do - so I'll do nothing */
842 printk(KERN_ERR "%s: unable to add port\n", __FUNCTION__); 842 printk(KERN_ERR "%s: unable to add port\n", __func__);
843 } 843 }
844 844
845 /* when this driver is compiled in, the console initialization 845 /* when this driver is compiled in, the console initialization
diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c
index b565d5a37499..b51c24245be4 100644
--- a/drivers/serial/uartlite.c
+++ b/drivers/serial/uartlite.c
@@ -584,7 +584,7 @@ ulite_of_probe(struct of_device *op, const struct of_device_id *match)
584 const unsigned int *id; 584 const unsigned int *id;
585 int irq, rc; 585 int irq, rc;
586 586
587 dev_dbg(&op->dev, "%s(%p, %p)\n", __FUNCTION__, op, match); 587 dev_dbg(&op->dev, "%s(%p, %p)\n", __func__, op, match);
588 588
589 rc = of_address_to_resource(op->node, 0, &res); 589 rc = of_address_to_resource(op->node, 0, &res);
590 if (rc) { 590 if (rc) {
diff --git a/drivers/serial/ucc_uart.c b/drivers/serial/ucc_uart.c
index 5e4310ccd591..01917c433f17 100644
--- a/drivers/serial/ucc_uart.c
+++ b/drivers/serial/ucc_uart.c
@@ -215,7 +215,7 @@ static inline dma_addr_t cpu2qe_addr(void *addr, struct uart_qe_port *qe_port)
215 return qe_port->bd_dma_addr + (addr - qe_port->bd_virt); 215 return qe_port->bd_dma_addr + (addr - qe_port->bd_virt);
216 216
217 /* something nasty happened */ 217 /* something nasty happened */
218 printk(KERN_ERR "%s: addr=%p\n", __FUNCTION__, addr); 218 printk(KERN_ERR "%s: addr=%p\n", __func__, addr);
219 BUG(); 219 BUG();
220 return 0; 220 return 0;
221} 221}
@@ -234,7 +234,7 @@ static inline void *qe2cpu_addr(dma_addr_t addr, struct uart_qe_port *qe_port)
234 return qe_port->bd_virt + (addr - qe_port->bd_dma_addr); 234 return qe_port->bd_virt + (addr - qe_port->bd_dma_addr);
235 235
236 /* something nasty happened */ 236 /* something nasty happened */
237 printk(KERN_ERR "%s: addr=%x\n", __FUNCTION__, addr); 237 printk(KERN_ERR "%s: addr=%x\n", __func__, addr);
238 BUG(); 238 BUG();
239 return NULL; 239 return NULL;
240} 240}