avr32: fix asm operand constraint in cmpxchg()
authorMans Rullgard <mans@mansr.com>
Thu, 10 Mar 2016 14:23:49 +0000 (14:23 +0000)
committerHans-Christian Egtvedt <egtvedt@samfundet.no>
Mon, 14 Mar 2016 10:08:29 +0000 (11:08 +0100)
If the 'old' operand to cmpxchg() is a constant wider than 21 bits,
linking fails with a "relocation truncated to fit: R_AVR32_21S" error.

Fix this by replacing the "i" constraint with "Ks21" which makes the
compiler use a temporary register for out of range constants.

Signed-off-by: Mans Rullgard <mans@mansr.com>
Acked-by: Hans-Christian Noren Egtvedt <egtvedt@samfundet.no>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
arch/avr32/include/asm/cmpxchg.h

index 366bbea..572739b 100644 (file)
@@ -57,7 +57,7 @@ static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
                "       brne    1b\n"
                "2:\n"
                : [ret] "=&r"(ret), [m] "=m"(*m)
-               : "m"(m), [old] "ir"(old), [new] "r"(new)
+               : "m"(m), [old] "Ks21r"(old), [new] "r"(new)
                : "memory", "cc");
        return ret;
 }