[SERIAL] convert uart_state.sem to uart_state.mutex

semaphore to mutex conversion.

the conversion was generated via scripts, and the result was validated
automatically via a script as well.

build and boot tested.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by Ingo Molnar and committed by Russell King e2862f6a 43ecb9a3

+36 -36
+4 -5
drivers/serial/pmac_zilog.c
··· 69 #include <asm/pmac_feature.h> 70 #include <asm/dbdma.h> 71 #include <asm/macio.h> 72 - #include <asm/semaphore.h> 73 74 #if defined (CONFIG_SERIAL_PMACZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 75 #define SUPPORT_SYSRQ ··· 1592 state = pmz_uart_reg.state + uap->port.line; 1593 1594 mutex_lock(&pmz_irq_mutex); 1595 - down(&state->sem); 1596 1597 spin_lock_irqsave(&uap->port.lock, flags); 1598 ··· 1623 /* Shut the chip down */ 1624 pmz_set_scc_power(uap, 0); 1625 1626 - up(&state->sem); 1627 mutex_unlock(&pmz_irq_mutex); 1628 1629 pmz_debug("suspend, switching complete\n"); ··· 1652 state = pmz_uart_reg.state + uap->port.line; 1653 1654 mutex_lock(&pmz_irq_mutex); 1655 - down(&state->sem); 1656 1657 spin_lock_irqsave(&uap->port.lock, flags); 1658 if (!ZS_IS_OPEN(uap) && !ZS_IS_CONS(uap)) { ··· 1684 } 1685 1686 bail: 1687 - up(&state->sem); 1688 mutex_unlock(&pmz_irq_mutex); 1689 1690 /* Right now, we deal with delay by blocking here, I'll be
··· 69 #include <asm/pmac_feature.h> 70 #include <asm/dbdma.h> 71 #include <asm/macio.h> 72 73 #if defined (CONFIG_SERIAL_PMACZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 74 #define SUPPORT_SYSRQ ··· 1593 state = pmz_uart_reg.state + uap->port.line; 1594 1595 mutex_lock(&pmz_irq_mutex); 1596 + mutex_lock(&state->mutex); 1597 1598 spin_lock_irqsave(&uap->port.lock, flags); 1599 ··· 1624 /* Shut the chip down */ 1625 pmz_set_scc_power(uap, 0); 1626 1627 + mutex_unlock(&state->mutex); 1628 mutex_unlock(&pmz_irq_mutex); 1629 1630 pmz_debug("suspend, switching complete\n"); ··· 1653 state = pmz_uart_reg.state + uap->port.line; 1654 1655 mutex_lock(&pmz_irq_mutex); 1656 + mutex_lock(&state->mutex); 1657 1658 spin_lock_irqsave(&uap->port.lock, flags); 1659 if (!ZS_IS_OPEN(uap) && !ZS_IS_CONS(uap)) { ··· 1685 } 1686 1687 bail: 1688 + mutex_unlock(&state->mutex); 1689 mutex_unlock(&pmz_irq_mutex); 1690 1691 /* Right now, we deal with delay by blocking here, I'll be
+30 -30
drivers/serial/serial_core.c
··· 638 * module insertion/removal doesn't change anything 639 * under us. 640 */ 641 - down(&state->sem); 642 643 change_irq = new_serial.irq != port->irq; 644 ··· 797 } else 798 retval = uart_startup(state, 1); 799 exit: 800 - up(&state->sem); 801 return retval; 802 } 803 ··· 834 struct uart_port *port = state->port; 835 int result = -EIO; 836 837 - down(&state->sem); 838 if ((!file || !tty_hung_up_p(file)) && 839 !(tty->flags & (1 << TTY_IO_ERROR))) { 840 result = port->mctrl; ··· 843 result |= port->ops->get_mctrl(port); 844 spin_unlock_irq(&port->lock); 845 } 846 - up(&state->sem); 847 848 return result; 849 } ··· 856 struct uart_port *port = state->port; 857 int ret = -EIO; 858 859 - down(&state->sem); 860 if ((!file || !tty_hung_up_p(file)) && 861 !(tty->flags & (1 << TTY_IO_ERROR))) { 862 uart_update_mctrl(port, set, clear); 863 ret = 0; 864 } 865 - up(&state->sem); 866 return ret; 867 } 868 ··· 873 874 BUG_ON(!kernel_locked()); 875 876 - down(&state->sem); 877 878 if (port->type != PORT_UNKNOWN) 879 port->ops->break_ctl(port, break_state); 880 881 - up(&state->sem); 882 } 883 884 static int uart_do_autoconfig(struct uart_state *state) ··· 894 * changing, and hence any extra opens of the port while 895 * we're auto-configuring. 896 */ 897 - if (down_interruptible(&state->sem)) 898 return -ERESTARTSYS; 899 900 ret = -EBUSY; ··· 920 921 ret = uart_startup(state, 1); 922 } 923 - up(&state->sem); 924 return ret; 925 } 926 ··· 1074 if (ret != -ENOIOCTLCMD) 1075 goto out; 1076 1077 - down(&state->sem); 1078 1079 if (tty_hung_up_p(filp)) { 1080 ret = -EIO; ··· 1098 } 1099 } 1100 out_up: 1101 - up(&state->sem); 1102 out: 1103 return ret; 1104 } ··· 1186 1187 DPRINTK("uart_close(%d) called\n", port->line); 1188 1189 - down(&state->sem); 1190 1191 if (tty_hung_up_p(filp)) 1192 goto done; ··· 1260 wake_up_interruptible(&state->info->open_wait); 1261 1262 done: 1263 - up(&state->sem); 1264 } 1265 1266 static void uart_wait_until_sent(struct tty_struct *tty, int timeout) ··· 1334 BUG_ON(!kernel_locked()); 1335 DPRINTK("uart_hangup(%d)\n", state->port->line); 1336 1337 - down(&state->sem); 1338 if (state->info && state->info->flags & UIF_NORMAL_ACTIVE) { 1339 uart_flush_buffer(tty); 1340 uart_shutdown(state); ··· 1344 wake_up_interruptible(&state->info->open_wait); 1345 wake_up_interruptible(&state->info->delta_msr_wait); 1346 } 1347 - up(&state->sem); 1348 } 1349 1350 /* ··· 1447 if (mctrl & TIOCM_CAR) 1448 break; 1449 1450 - up(&state->sem); 1451 schedule(); 1452 - down(&state->sem); 1453 1454 if (signal_pending(current)) 1455 break; ··· 1475 1476 mutex_lock(&port_mutex); 1477 state = drv->state + line; 1478 - if (down_interruptible(&state->sem)) { 1479 state = ERR_PTR(-ERESTARTSYS); 1480 goto out; 1481 } ··· 1483 state->count++; 1484 if (!state->port) { 1485 state->count--; 1486 - up(&state->sem); 1487 state = ERR_PTR(-ENXIO); 1488 goto out; 1489 } ··· 1504 (unsigned long)state); 1505 } else { 1506 state->count--; 1507 - up(&state->sem); 1508 state = ERR_PTR(-ENOMEM); 1509 } 1510 } ··· 1571 if (tty_hung_up_p(filp)) { 1572 retval = -EAGAIN; 1573 state->count--; 1574 - up(&state->sem); 1575 goto fail; 1576 } 1577 ··· 1591 */ 1592 if (retval == 0) 1593 retval = uart_block_til_ready(filp, state); 1594 - up(&state->sem); 1595 1596 /* 1597 * If this is the first open to succeed, adjust things to suit. ··· 1867 { 1868 struct uart_state *state = drv->state + port->line; 1869 1870 - down(&state->sem); 1871 1872 if (state->info && state->info->flags & UIF_INITIALIZED) { 1873 struct uart_ops *ops = port->ops; ··· 1896 1897 uart_change_pm(state, 3); 1898 1899 - up(&state->sem); 1900 1901 return 0; 1902 } ··· 1905 { 1906 struct uart_state *state = drv->state + port->line; 1907 1908 - down(&state->sem); 1909 1910 uart_change_pm(state, 0); 1911 ··· 1954 } 1955 } 1956 1957 - up(&state->sem); 1958 1959 return 0; 1960 } ··· 2049 if (info && info->tty) 2050 tty_vhangup(info->tty); 2051 2052 - down(&state->sem); 2053 2054 state->info = NULL; 2055 ··· 2072 kfree(info); 2073 } 2074 2075 - up(&state->sem); 2076 } 2077 2078 static struct tty_operations uart_ops = { ··· 2161 state->close_delay = 500; /* .5 seconds */ 2162 state->closing_wait = 30000; /* 30 seconds */ 2163 2164 - init_MUTEX(&state->sem); 2165 } 2166 2167 retval = tty_register_driver(normal);
··· 638 * module insertion/removal doesn't change anything 639 * under us. 640 */ 641 + mutex_lock(&state->mutex); 642 643 change_irq = new_serial.irq != port->irq; 644 ··· 797 } else 798 retval = uart_startup(state, 1); 799 exit: 800 + mutex_unlock(&state->mutex); 801 return retval; 802 } 803 ··· 834 struct uart_port *port = state->port; 835 int result = -EIO; 836 837 + mutex_lock(&state->mutex); 838 if ((!file || !tty_hung_up_p(file)) && 839 !(tty->flags & (1 << TTY_IO_ERROR))) { 840 result = port->mctrl; ··· 843 result |= port->ops->get_mctrl(port); 844 spin_unlock_irq(&port->lock); 845 } 846 + mutex_unlock(&state->mutex); 847 848 return result; 849 } ··· 856 struct uart_port *port = state->port; 857 int ret = -EIO; 858 859 + mutex_lock(&state->mutex); 860 if ((!file || !tty_hung_up_p(file)) && 861 !(tty->flags & (1 << TTY_IO_ERROR))) { 862 uart_update_mctrl(port, set, clear); 863 ret = 0; 864 } 865 + mutex_unlock(&state->mutex); 866 return ret; 867 } 868 ··· 873 874 BUG_ON(!kernel_locked()); 875 876 + mutex_lock(&state->mutex); 877 878 if (port->type != PORT_UNKNOWN) 879 port->ops->break_ctl(port, break_state); 880 881 + mutex_unlock(&state->mutex); 882 } 883 884 static int uart_do_autoconfig(struct uart_state *state) ··· 894 * changing, and hence any extra opens of the port while 895 * we're auto-configuring. 896 */ 897 + if (mutex_lock_interruptible(&state->mutex)) 898 return -ERESTARTSYS; 899 900 ret = -EBUSY; ··· 920 921 ret = uart_startup(state, 1); 922 } 923 + mutex_unlock(&state->mutex); 924 return ret; 925 } 926 ··· 1074 if (ret != -ENOIOCTLCMD) 1075 goto out; 1076 1077 + mutex_lock(&state->mutex); 1078 1079 if (tty_hung_up_p(filp)) { 1080 ret = -EIO; ··· 1098 } 1099 } 1100 out_up: 1101 + mutex_unlock(&state->mutex); 1102 out: 1103 return ret; 1104 } ··· 1186 1187 DPRINTK("uart_close(%d) called\n", port->line); 1188 1189 + mutex_lock(&state->mutex); 1190 1191 if (tty_hung_up_p(filp)) 1192 goto done; ··· 1260 wake_up_interruptible(&state->info->open_wait); 1261 1262 done: 1263 + mutex_unlock(&state->mutex); 1264 } 1265 1266 static void uart_wait_until_sent(struct tty_struct *tty, int timeout) ··· 1334 BUG_ON(!kernel_locked()); 1335 DPRINTK("uart_hangup(%d)\n", state->port->line); 1336 1337 + mutex_lock(&state->mutex); 1338 if (state->info && state->info->flags & UIF_NORMAL_ACTIVE) { 1339 uart_flush_buffer(tty); 1340 uart_shutdown(state); ··· 1344 wake_up_interruptible(&state->info->open_wait); 1345 wake_up_interruptible(&state->info->delta_msr_wait); 1346 } 1347 + mutex_unlock(&state->mutex); 1348 } 1349 1350 /* ··· 1447 if (mctrl & TIOCM_CAR) 1448 break; 1449 1450 + mutex_unlock(&state->mutex); 1451 schedule(); 1452 + mutex_lock(&state->mutex); 1453 1454 if (signal_pending(current)) 1455 break; ··· 1475 1476 mutex_lock(&port_mutex); 1477 state = drv->state + line; 1478 + if (mutex_lock_interruptible(&state->mutex)) { 1479 state = ERR_PTR(-ERESTARTSYS); 1480 goto out; 1481 } ··· 1483 state->count++; 1484 if (!state->port) { 1485 state->count--; 1486 + mutex_unlock(&state->mutex); 1487 state = ERR_PTR(-ENXIO); 1488 goto out; 1489 } ··· 1504 (unsigned long)state); 1505 } else { 1506 state->count--; 1507 + mutex_unlock(&state->mutex); 1508 state = ERR_PTR(-ENOMEM); 1509 } 1510 } ··· 1571 if (tty_hung_up_p(filp)) { 1572 retval = -EAGAIN; 1573 state->count--; 1574 + mutex_unlock(&state->mutex); 1575 goto fail; 1576 } 1577 ··· 1591 */ 1592 if (retval == 0) 1593 retval = uart_block_til_ready(filp, state); 1594 + mutex_unlock(&state->mutex); 1595 1596 /* 1597 * If this is the first open to succeed, adjust things to suit. ··· 1867 { 1868 struct uart_state *state = drv->state + port->line; 1869 1870 + mutex_lock(&state->mutex); 1871 1872 if (state->info && state->info->flags & UIF_INITIALIZED) { 1873 struct uart_ops *ops = port->ops; ··· 1896 1897 uart_change_pm(state, 3); 1898 1899 + mutex_unlock(&state->mutex); 1900 1901 return 0; 1902 } ··· 1905 { 1906 struct uart_state *state = drv->state + port->line; 1907 1908 + mutex_lock(&state->mutex); 1909 1910 uart_change_pm(state, 0); 1911 ··· 1954 } 1955 } 1956 1957 + mutex_unlock(&state->mutex); 1958 1959 return 0; 1960 } ··· 2049 if (info && info->tty) 2050 tty_vhangup(info->tty); 2051 2052 + mutex_lock(&state->mutex); 2053 2054 state->info = NULL; 2055 ··· 2072 kfree(info); 2073 } 2074 2075 + mutex_unlock(&state->mutex); 2076 } 2077 2078 static struct tty_operations uart_ops = { ··· 2161 state->close_delay = 500; /* .5 seconds */ 2162 state->closing_wait = 30000; /* 30 seconds */ 2163 2164 + mutex_init(&state->mutex); 2165 } 2166 2167 retval = tty_register_driver(normal);
+2 -1
include/linux/serial_core.h
··· 136 #include <linux/spinlock.h> 137 #include <linux/sched.h> 138 #include <linux/tty.h> 139 140 struct uart_port; 141 struct uart_info; ··· 285 struct uart_info *info; 286 struct uart_port *port; 287 288 - struct semaphore sem; 289 }; 290 291 #define UART_XMIT_SIZE PAGE_SIZE
··· 136 #include <linux/spinlock.h> 137 #include <linux/sched.h> 138 #include <linux/tty.h> 139 + #include <linux/mutex.h> 140 141 struct uart_port; 142 struct uart_info; ··· 284 struct uart_info *info; 285 struct uart_port *port; 286 287 + struct mutex mutex; 288 }; 289 290 #define UART_XMIT_SIZE PAGE_SIZE