[SERIAL] turn serial semaphores into mutexes

Turn several drivers/serial/ semaphores-used-as-mutex into mutexes

Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by Arjan van de Ven and committed by Russell King f392ecfa 593195f9

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