diff options
Diffstat (limited to 'drivers/tty/tty_ldsem.c')
| -rw-r--r-- | drivers/tty/tty_ldsem.c | 31 | 
1 files changed, 17 insertions, 14 deletions
diff --git a/drivers/tty/tty_ldsem.c b/drivers/tty/tty_ldsem.c index 22fad8ad5ac..0ffb0cbe282 100644 --- a/drivers/tty/tty_ldsem.c +++ b/drivers/tty/tty_ldsem.c @@ -39,17 +39,10 @@  				lock_acquire(&(l)->dep_map, s, t, r, c, n, i)  # define __rel(l, n, i)				\  				lock_release(&(l)->dep_map, n, i) -# ifdef CONFIG_PROVE_LOCKING -#  define lockdep_acquire(l, s, t, i)		__acq(l, s, t, 0, 2, NULL, i) -#  define lockdep_acquire_nest(l, s, t, n, i)	__acq(l, s, t, 0, 2, n, i) -#  define lockdep_acquire_read(l, s, t, i)	__acq(l, s, t, 1, 2, NULL, i) -#  define lockdep_release(l, n, i)		__rel(l, n, i) -# else -#  define lockdep_acquire(l, s, t, i)		__acq(l, s, t, 0, 1, NULL, i) -#  define lockdep_acquire_nest(l, s, t, n, i)	__acq(l, s, t, 0, 1, n, i) -#  define lockdep_acquire_read(l, s, t, i)	__acq(l, s, t, 1, 1, NULL, i) -#  define lockdep_release(l, n, i)		__rel(l, n, i) -# endif +#define lockdep_acquire(l, s, t, i)		__acq(l, s, t, 0, 1, NULL, i) +#define lockdep_acquire_nest(l, s, t, n, i)	__acq(l, s, t, 0, 1, n, i) +#define lockdep_acquire_read(l, s, t, i)	__acq(l, s, t, 1, 1, NULL, i) +#define lockdep_release(l, n, i)		__rel(l, n, i)  #else  # define lockdep_acquire(l, s, t, i)		do { } while (0)  # define lockdep_acquire_nest(l, s, t, n, i)	do { } while (0) @@ -86,11 +79,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; +	}  }  /*  | 
