Skip to content

Commit

Permalink
lib: Fix atomic64_add_unless return value convention
Browse files Browse the repository at this point in the history
atomic64_add_unless must return 1 if it perfomed the add and 0 otherwise.
The generic implementation did the opposite thing.

Reported-by: H. Peter Anvin <[email protected]>
Confirmed-by: Paul Mackerras <[email protected]>
Signed-off-by: Luca Barbieri <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: H. Peter Anvin <[email protected]>
  • Loading branch information
luca-barbieri authored and H. Peter Anvin committed Mar 1, 2010
1 parent 6e6104f commit 9757789
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/atomic64.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ int atomic64_add_unless(atomic64_t *v, long long a, long long u)
{
unsigned long flags;
spinlock_t *lock = lock_addr(v);
int ret = 1;
int ret = 0;

spin_lock_irqsave(lock, flags);
if (v->counter != u) {
v->counter += a;
ret = 0;
ret = 1;
}
spin_unlock_irqrestore(lock, flags);
return ret;
Expand Down

0 comments on commit 9757789

Please sign in to comment.