]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
ARM: 6211/1: atomic ops: fix register constraints for atomic64_add_unless
authorWill Deacon <will.deacon@arm.com>
Thu, 8 Jul 2010 09:58:06 +0000 (10:58 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 9 Jul 2010 10:29:35 +0000 (11:29 +0100)
The atomic64_add_unless function compares an atomic variable with
a given value and, if they are not equal, adds another given value
to the atomic variable. The function returns zero if the addition
did not occur and non-zero otherwise.

On ARM, the return value is initialised to 1 in C code. Inline assembly
code then performs the atomic64_add_unless operation, setting the
return value to 0 iff the addition does not occur. This means that
when the addition *does* occur, the value of ret must be preserved
across the inline assembly and therefore requires a "+r" constraint
rather than the current one of "=&r".

Thanks to Nicolas Pitre for helping to spot this.

Cc: stable@kernel.org
Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/include/asm/atomic.h

index a0162fa9456496662adb28898fcb44776e628414..e9e56c00b858c628aa375660ad1ce121377c9187 100644 (file)
@@ -440,7 +440,7 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
 "      teq     %2, #0\n"
 "      bne     1b\n"
 "2:"
-       : "=&r" (val), "=&r" (ret), "=&r" (tmp)
+       : "=&r" (val), "+r" (ret), "=&r" (tmp)
        : "r" (&v->counter), "r" (u), "r" (a)
        : "cc");