aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/serial/8250.c11
-rw-r--r--drivers/serial/crisv10.c11
-rw-r--r--drivers/serial/pmac_zilog.c23
-rw-r--r--drivers/serial/serial_core.c15
-rw-r--r--drivers/serial/serial_txx9.c11
5 files changed, 36 insertions, 35 deletions
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 54e5cc0dd5f8..fb610c3634a4 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -41,6 +41,7 @@
41#include <linux/serial.h> 41#include <linux/serial.h>
42#include <linux/serial_8250.h> 42#include <linux/serial_8250.h>
43#include <linux/nmi.h> 43#include <linux/nmi.h>
44#include <linux/mutex.h>
44 45
45#include <asm/io.h> 46#include <asm/io.h>
46#include <asm/irq.h> 47#include <asm/irq.h>
@@ -2467,7 +2468,7 @@ static struct platform_device *serial8250_isa_devs;
2467 * 16x50 serial ports to be configured at run-time, to support PCMCIA 2468 * 16x50 serial ports to be configured at run-time, to support PCMCIA
2468 * modems and PCI multiport cards. 2469 * modems and PCI multiport cards.
2469 */ 2470 */
2470static DECLARE_MUTEX(serial_sem); 2471static DEFINE_MUTEX(serial_mutex);
2471 2472
2472static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *port) 2473static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *port)
2473{ 2474{
@@ -2522,7 +2523,7 @@ int serial8250_register_port(struct uart_port *port)
2522 if (port->uartclk == 0) 2523 if (port->uartclk == 0)
2523 return -EINVAL; 2524 return -EINVAL;
2524 2525
2525 down(&serial_sem); 2526 mutex_lock(&serial_mutex);
2526 2527
2527 uart = serial8250_find_match_or_unused(port); 2528 uart = serial8250_find_match_or_unused(port);
2528 if (uart) { 2529 if (uart) {
@@ -2544,7 +2545,7 @@ int serial8250_register_port(struct uart_port *port)
2544 if (ret == 0) 2545 if (ret == 0)
2545 ret = uart->port.line; 2546 ret = uart->port.line;
2546 } 2547 }
2547 up(&serial_sem); 2548 mutex_unlock(&serial_mutex);
2548 2549
2549 return ret; 2550 return ret;
2550} 2551}
@@ -2561,7 +2562,7 @@ void serial8250_unregister_port(int line)
2561{ 2562{
2562 struct uart_8250_port *uart = &serial8250_ports[line]; 2563 struct uart_8250_port *uart = &serial8250_ports[line];
2563 2564
2564 down(&serial_sem); 2565 mutex_lock(&serial_mutex);
2565 uart_remove_one_port(&serial8250_reg, &uart->port); 2566 uart_remove_one_port(&serial8250_reg, &uart->port);
2566 if (serial8250_isa_devs) { 2567 if (serial8250_isa_devs) {
2567 uart->port.flags &= ~UPF_BOOT_AUTOCONF; 2568 uart->port.flags &= ~UPF_BOOT_AUTOCONF;
@@ -2571,7 +2572,7 @@ void serial8250_unregister_port(int line)
2571 } else { 2572 } else {
2572 uart->port.dev = NULL; 2573 uart->port.dev = NULL;
2573 } 2574 }
2574 up(&serial_sem); 2575 mutex_unlock(&serial_mutex);
2575} 2576}
2576EXPORT_SYMBOL(serial8250_unregister_port); 2577EXPORT_SYMBOL(serial8250_unregister_port);
2577 2578
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index 08c42c000188..be12623d8544 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -442,6 +442,7 @@ static char *serial_version = "$Revision: 1.25 $";
442#include <linux/init.h> 442#include <linux/init.h>
443#include <asm/uaccess.h> 443#include <asm/uaccess.h>
444#include <linux/kernel.h> 444#include <linux/kernel.h>
445#include <linux/mutex.h>
445 446
446#include <asm/io.h> 447#include <asm/io.h>
447#include <asm/irq.h> 448#include <asm/irq.h>
@@ -1315,11 +1316,7 @@ static const struct control_pins e100_modem_pins[NR_PORTS] =
1315 * memory if large numbers of serial ports are open. 1316 * memory if large numbers of serial ports are open.
1316 */ 1317 */
1317static unsigned char *tmp_buf; 1318static unsigned char *tmp_buf;
1318#ifdef DECLARE_MUTEX 1319static DEFINE_MUTEX(tmp_buf_mutex);
1319static DECLARE_MUTEX(tmp_buf_sem);
1320#else
1321static struct semaphore tmp_buf_sem = MUTEX;
1322#endif
1323 1320
1324/* Calculate the chartime depending on baudrate, numbor of bits etc. */ 1321/* Calculate the chartime depending on baudrate, numbor of bits etc. */
1325static void update_char_time(struct e100_serial * info) 1322static void update_char_time(struct e100_serial * info)
@@ -3661,7 +3658,7 @@ rs_raw_write(struct tty_struct * tty, int from_user,
3661 * design. 3658 * design.
3662 */ 3659 */
3663 if (from_user) { 3660 if (from_user) {
3664 down(&tmp_buf_sem); 3661 mutex_lock(&tmp_buf_mutex);
3665 while (1) { 3662 while (1) {
3666 int c1; 3663 int c1;
3667 c = CIRC_SPACE_TO_END(info->xmit.head, 3664 c = CIRC_SPACE_TO_END(info->xmit.head,
@@ -3692,7 +3689,7 @@ rs_raw_write(struct tty_struct * tty, int from_user,
3692 count -= c; 3689 count -= c;
3693 ret += c; 3690 ret += c;
3694 } 3691 }
3695 up(&tmp_buf_sem); 3692 mutex_unlock(&tmp_buf_mutex);
3696 } else { 3693 } else {
3697 cli(); 3694 cli();
3698 while (count) { 3695 while (count) {
diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c
index f330d6c0e0df..5f52883e64d2 100644
--- a/drivers/serial/pmac_zilog.c
+++ b/drivers/serial/pmac_zilog.c
@@ -60,6 +60,7 @@
60#include <linux/pmu.h> 60#include <linux/pmu.h>
61#include <linux/bitops.h> 61#include <linux/bitops.h>
62#include <linux/sysrq.h> 62#include <linux/sysrq.h>
63#include <linux/mutex.h>
63#include <asm/sections.h> 64#include <asm/sections.h>
64#include <asm/io.h> 65#include <asm/io.h>
65#include <asm/irq.h> 66#include <asm/irq.h>
@@ -96,7 +97,7 @@ MODULE_LICENSE("GPL");
96 */ 97 */
97static struct uart_pmac_port pmz_ports[MAX_ZS_PORTS]; 98static struct uart_pmac_port pmz_ports[MAX_ZS_PORTS];
98static int pmz_ports_count; 99static int pmz_ports_count;
99static DECLARE_MUTEX(pmz_irq_sem); 100static DEFINE_MUTEX(pmz_irq_mutex);
100 101
101static struct uart_driver pmz_uart_reg = { 102static struct uart_driver pmz_uart_reg = {
102 .owner = THIS_MODULE, 103 .owner = THIS_MODULE,
@@ -922,7 +923,7 @@ static int pmz_startup(struct uart_port *port)
922 if (uap->node == NULL) 923 if (uap->node == NULL)
923 return -ENODEV; 924 return -ENODEV;
924 925
925 down(&pmz_irq_sem); 926 mutex_lock(&pmz_irq_mutex);
926 927
927 uap->flags |= PMACZILOG_FLAG_IS_OPEN; 928 uap->flags |= PMACZILOG_FLAG_IS_OPEN;
928 929
@@ -940,11 +941,11 @@ static int pmz_startup(struct uart_port *port)
940 dev_err(&uap->dev->ofdev.dev, 941 dev_err(&uap->dev->ofdev.dev,
941 "Unable to register zs interrupt handler.\n"); 942 "Unable to register zs interrupt handler.\n");
942 pmz_set_scc_power(uap, 0); 943 pmz_set_scc_power(uap, 0);
943 up(&pmz_irq_sem); 944 mutex_unlock(&pmz_irq_mutex);
944 return -ENXIO; 945 return -ENXIO;
945 } 946 }
946 947
947 up(&pmz_irq_sem); 948 mutex_unlock(&pmz_irq_mutex);
948 949
949 /* Right now, we deal with delay by blocking here, I'll be 950 /* Right now, we deal with delay by blocking here, I'll be
950 * smarter later on 951 * smarter later on
@@ -981,7 +982,7 @@ static void pmz_shutdown(struct uart_port *port)
981 if (uap->node == NULL) 982 if (uap->node == NULL)
982 return; 983 return;
983 984
984 down(&pmz_irq_sem); 985 mutex_lock(&pmz_irq_mutex);
985 986
986 /* Release interrupt handler */ 987 /* Release interrupt handler */
987 free_irq(uap->port.irq, uap); 988 free_irq(uap->port.irq, uap);
@@ -1002,7 +1003,7 @@ static void pmz_shutdown(struct uart_port *port)
1002 1003
1003 if (ZS_IS_CONS(uap) || ZS_IS_ASLEEP(uap)) { 1004 if (ZS_IS_CONS(uap) || ZS_IS_ASLEEP(uap)) {
1004 spin_unlock_irqrestore(&port->lock, flags); 1005 spin_unlock_irqrestore(&port->lock, flags);
1005 up(&pmz_irq_sem); 1006 mutex_unlock(&pmz_irq_mutex);
1006 return; 1007 return;
1007 } 1008 }
1008 1009
@@ -1019,7 +1020,7 @@ static void pmz_shutdown(struct uart_port *port)
1019 1020
1020 spin_unlock_irqrestore(&port->lock, flags); 1021 spin_unlock_irqrestore(&port->lock, flags);
1021 1022
1022 up(&pmz_irq_sem); 1023 mutex_unlock(&pmz_irq_mutex);
1023 1024
1024 pmz_debug("pmz: shutdown() done.\n"); 1025 pmz_debug("pmz: shutdown() done.\n");
1025} 1026}
@@ -1591,7 +1592,7 @@ static int pmz_suspend(struct macio_dev *mdev, pm_message_t pm_state)
1591 1592
1592 state = pmz_uart_reg.state + uap->port.line; 1593 state = pmz_uart_reg.state + uap->port.line;
1593 1594
1594 down(&pmz_irq_sem); 1595 mutex_lock(&pmz_irq_mutex);
1595 down(&state->sem); 1596 down(&state->sem);
1596 1597
1597 spin_lock_irqsave(&uap->port.lock, flags); 1598 spin_lock_irqsave(&uap->port.lock, flags);
@@ -1624,7 +1625,7 @@ static int pmz_suspend(struct macio_dev *mdev, pm_message_t pm_state)
1624 pmz_set_scc_power(uap, 0); 1625 pmz_set_scc_power(uap, 0);
1625 1626
1626 up(&state->sem); 1627 up(&state->sem);
1627 up(&pmz_irq_sem); 1628 mutex_unlock(&pmz_irq_mutex);
1628 1629
1629 pmz_debug("suspend, switching complete\n"); 1630 pmz_debug("suspend, switching complete\n");
1630 1631
@@ -1651,7 +1652,7 @@ static int pmz_resume(struct macio_dev *mdev)
1651 1652
1652 state = pmz_uart_reg.state + uap->port.line; 1653 state = pmz_uart_reg.state + uap->port.line;
1653 1654
1654 down(&pmz_irq_sem); 1655 mutex_lock(&pmz_irq_mutex);
1655 down(&state->sem); 1656 down(&state->sem);
1656 1657
1657 spin_lock_irqsave(&uap->port.lock, flags); 1658 spin_lock_irqsave(&uap->port.lock, flags);
@@ -1685,7 +1686,7 @@ static int pmz_resume(struct macio_dev *mdev)
1685 1686
1686 bail: 1687 bail:
1687 up(&state->sem); 1688 up(&state->sem);
1688 up(&pmz_irq_sem); 1689 mutex_unlock(&pmz_irq_mutex);
1689 1690
1690 /* Right now, we deal with delay by blocking here, I'll be 1691 /* Right now, we deal with delay by blocking here, I'll be
1691 * smarter later on 1692 * smarter later on
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 9589509fc5bd..2ca620900bcc 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -33,6 +33,7 @@
33#include <linux/device.h> 33#include <linux/device.h>
34#include <linux/serial.h> /* for serial_state and serial_icounter_struct */ 34#include <linux/serial.h> /* for serial_state and serial_icounter_struct */
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/mutex.h>
36 37
37#include <asm/irq.h> 38#include <asm/irq.h>
38#include <asm/uaccess.h> 39#include <asm/uaccess.h>
@@ -47,7 +48,7 @@
47/* 48/*
48 * This is used to lock changes in serial line configuration. 49 * This is used to lock changes in serial line configuration.
49 */ 50 */
50static DECLARE_MUTEX(port_sem); 51static DEFINE_MUTEX(port_mutex);
51 52
52#define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8) 53#define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
53 54
@@ -1472,7 +1473,7 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line)
1472{ 1473{
1473 struct uart_state *state; 1474 struct uart_state *state;
1474 1475
1475 down(&port_sem); 1476 mutex_lock(&port_mutex);
1476 state = drv->state + line; 1477 state = drv->state + line;
1477 if (down_interruptible(&state->sem)) { 1478 if (down_interruptible(&state->sem)) {
1478 state = ERR_PTR(-ERESTARTSYS); 1479 state = ERR_PTR(-ERESTARTSYS);
@@ -1509,7 +1510,7 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line)
1509 } 1510 }
1510 1511
1511 out: 1512 out:
1512 up(&port_sem); 1513 mutex_unlock(&port_mutex);
1513 return state; 1514 return state;
1514} 1515}
1515 1516
@@ -2219,7 +2220,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *port)
2219 2220
2220 state = drv->state + port->line; 2221 state = drv->state + port->line;
2221 2222
2222 down(&port_sem); 2223 mutex_lock(&port_mutex);
2223 if (state->port) { 2224 if (state->port) {
2224 ret = -EINVAL; 2225 ret = -EINVAL;
2225 goto out; 2226 goto out;
@@ -2255,7 +2256,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *port)
2255 register_console(port->cons); 2256 register_console(port->cons);
2256 2257
2257 out: 2258 out:
2258 up(&port_sem); 2259 mutex_unlock(&port_mutex);
2259 2260
2260 return ret; 2261 return ret;
2261} 2262}
@@ -2279,7 +2280,7 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *port)
2279 printk(KERN_ALERT "Removing wrong port: %p != %p\n", 2280 printk(KERN_ALERT "Removing wrong port: %p != %p\n",
2280 state->port, port); 2281 state->port, port);
2281 2282
2282 down(&port_sem); 2283 mutex_lock(&port_mutex);
2283 2284
2284 /* 2285 /*
2285 * Remove the devices from devfs 2286 * Remove the devices from devfs
@@ -2288,7 +2289,7 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *port)
2288 2289
2289 uart_unconfigure_port(drv, state); 2290 uart_unconfigure_port(drv, state);
2290 state->port = NULL; 2291 state->port = NULL;
2291 up(&port_sem); 2292 mutex_unlock(&port_mutex);
2292 2293
2293 return 0; 2294 return 0;
2294} 2295}
diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c
index fdd1f1915a42..ee98a867bc6d 100644
--- a/drivers/serial/serial_txx9.c
+++ b/drivers/serial/serial_txx9.c
@@ -52,6 +52,7 @@
52#include <linux/tty_flip.h> 52#include <linux/tty_flip.h>
53#include <linux/serial_core.h> 53#include <linux/serial_core.h>
54#include <linux/serial.h> 54#include <linux/serial.h>
55#include <linux/mutex.h>
55 56
56#include <asm/io.h> 57#include <asm/io.h>
57#include <asm/irq.h> 58#include <asm/irq.h>
@@ -1018,7 +1019,7 @@ static void serial_txx9_resume_port(int line)
1018 uart_resume_port(&serial_txx9_reg, &serial_txx9_ports[line].port); 1019 uart_resume_port(&serial_txx9_reg, &serial_txx9_ports[line].port);
1019} 1020}
1020 1021
1021static DECLARE_MUTEX(serial_txx9_sem); 1022static DEFINE_MUTEX(serial_txx9_mutex);
1022 1023
1023/** 1024/**
1024 * serial_txx9_register_port - register a serial port 1025 * serial_txx9_register_port - register a serial port
@@ -1037,7 +1038,7 @@ static int __devinit serial_txx9_register_port(struct uart_port *port)
1037 struct uart_txx9_port *uart; 1038 struct uart_txx9_port *uart;
1038 int ret = -ENOSPC; 1039 int ret = -ENOSPC;
1039 1040
1040 down(&serial_txx9_sem); 1041 mutex_lock(&serial_txx9_mutex);
1041 for (i = 0; i < UART_NR; i++) { 1042 for (i = 0; i < UART_NR; i++) {
1042 uart = &serial_txx9_ports[i]; 1043 uart = &serial_txx9_ports[i];
1043 if (uart->port.type == PORT_UNKNOWN) 1044 if (uart->port.type == PORT_UNKNOWN)
@@ -1058,7 +1059,7 @@ static int __devinit serial_txx9_register_port(struct uart_port *port)
1058 if (ret == 0) 1059 if (ret == 0)
1059 ret = uart->port.line; 1060 ret = uart->port.line;
1060 } 1061 }
1061 up(&serial_txx9_sem); 1062 mutex_unlock(&serial_txx9_mutex);
1062 return ret; 1063 return ret;
1063} 1064}
1064 1065
@@ -1073,7 +1074,7 @@ static void __devexit serial_txx9_unregister_port(int line)
1073{ 1074{
1074 struct uart_txx9_port *uart = &serial_txx9_ports[line]; 1075 struct uart_txx9_port *uart = &serial_txx9_ports[line];
1075 1076
1076 down(&serial_txx9_sem); 1077 mutex_lock(&serial_txx9_mutex);
1077 uart_remove_one_port(&serial_txx9_reg, &uart->port); 1078 uart_remove_one_port(&serial_txx9_reg, &uart->port);
1078 uart->port.flags = 0; 1079 uart->port.flags = 0;
1079 uart->port.type = PORT_UNKNOWN; 1080 uart->port.type = PORT_UNKNOWN;
@@ -1082,7 +1083,7 @@ static void __devexit serial_txx9_unregister_port(int line)
1082 uart->port.membase = 0; 1083 uart->port.membase = 0;
1083 uart->port.dev = NULL; 1084 uart->port.dev = NULL;
1084 uart_add_one_port(&serial_txx9_reg, &uart->port); 1085 uart_add_one_port(&serial_txx9_reg, &uart->port);
1085 up(&serial_txx9_sem); 1086 mutex_unlock(&serial_txx9_mutex);
1086} 1087}
1087 1088
1088/* 1089/*