diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-12-24 19:10:47 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-12-24 19:10:47 +0100 |
commit | b86b75ec57c381f32090a5bc61252f84f955c094 (patch) | |
tree | 69afa8a88979bfa8fbdbcb106ddf8fe3ee5da99f /drivers/tty/tty_ldsem.c | |
parent | tty: an overflow of multiplication in drivers/tty/cyclades.c (diff) | |
parent | Linux 3.13-rc5 (diff) | |
download | linux-b86b75ec57c381f32090a5bc61252f84f955c094.tar.xz linux-b86b75ec57c381f32090a5bc61252f84f955c094.zip |
Merge 3.13-rc5 into tty-next
We need the tty fixes in here as well.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/tty_ldsem.c')
-rw-r--r-- | drivers/tty/tty_ldsem.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/tty/tty_ldsem.c b/drivers/tty/tty_ldsem.c index 22fad8ad5ac2..d8a55e87877f 100644 --- a/drivers/tty/tty_ldsem.c +++ b/drivers/tty/tty_ldsem.c @@ -86,11 +86,21 @@ static inline long ldsem_atomic_update(long delta, struct ld_semaphore *sem) return atomic_long_add_return(delta, (atomic_long_t *)&sem->count); } +/* + * ldsem_cmpxchg() updates @*old with the last-known sem->count value. + * Returns 1 if count was successfully changed; @*old will have @new value. + * Returns 0 if count was not changed; @*old will have most recent sem->count + */ static inline int ldsem_cmpxchg(long *old, long new, struct ld_semaphore *sem) { - long tmp = *old; - *old = atomic_long_cmpxchg(&sem->count, *old, new); - return *old == tmp; + long tmp = atomic_long_cmpxchg(&sem->count, *old, new); + if (tmp == *old) { + *old = new; + return 1; + } else { + *old = tmp; + return 0; + } } /* |