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