aboutsummaryrefslogtreecommitdiffstats
path: root/arch/hexagon
diff options
context:
space:
mode:
authorRichard Kuo <rkuo@codeaurora.org>2013-03-21 19:24:19 -0400
committerRichard Kuo <rkuo@codeaurora.org>2013-04-30 20:40:22 -0400
commite0025a72c37ca404fbf31d569439c20bfb04295e (patch)
tree4e7566fd7876f23d5ea5cf2eec5a6d26c5989ce3 /arch/hexagon
parent22493cfd78e4db0ba9c9f46dac4757bee5a0294a (diff)
Hexagon: fix __atomic_add_unless
Signed-off-by: Richard Kuo <rkuo@codeaurora.org>
Diffstat (limited to 'arch/hexagon')
-rw-r--r--arch/hexagon/include/asm/atomic.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/arch/hexagon/include/asm/atomic.h b/arch/hexagon/include/asm/atomic.h
index 468fbb0781cd..c6670390d255 100644
--- a/arch/hexagon/include/asm/atomic.h
+++ b/arch/hexagon/include/asm/atomic.h
@@ -117,35 +117,37 @@ static inline int atomic_sub_return(int i, atomic_t *v)
117#define atomic_sub(i, v) atomic_sub_return(i, (v)) 117#define atomic_sub(i, v) atomic_sub_return(i, (v))
118 118
119/** 119/**
120 * atomic_add_unless - add unless the number is a given value 120 * __atomic_add_unless - add unless the number is a given value
121 * @v: pointer to value 121 * @v: pointer to value
122 * @a: amount to add 122 * @a: amount to add
123 * @u: unless value is equal to u 123 * @u: unless value is equal to u
124 * 124 *
125 * Returns 1 if the add happened, 0 if it didn't. 125 * Returns old value.
126 *
126 */ 127 */
128
127static inline int __atomic_add_unless(atomic_t *v, int a, int u) 129static inline int __atomic_add_unless(atomic_t *v, int a, int u)
128{ 130{
129 int output, __oldval; 131 int __oldval;
132 register int tmp;
133
130 asm volatile( 134 asm volatile(
131 "1: %0 = memw_locked(%2);" 135 "1: %0 = memw_locked(%2);"
132 " {" 136 " {"
133 " p3 = cmp.eq(%0, %4);" 137 " p3 = cmp.eq(%0, %4);"
134 " if (p3.new) jump:nt 2f;" 138 " if (p3.new) jump:nt 2f;"
135 " %0 = add(%0, %3);" 139 " %1 = add(%0, %3);"
136 " %1 = #0;"
137 " }" 140 " }"
138 " memw_locked(%2, p3) = %0;" 141 " memw_locked(%2, p3) = %1;"
139 " {" 142 " {"
140 " if !p3 jump 1b;" 143 " if !p3 jump 1b;"
141 " %1 = #1;"
142 " }" 144 " }"
143 "2:" 145 "2:"
144 : "=&r" (__oldval), "=&r" (output) 146 : "=&r" (__oldval), "=&r" (tmp)
145 : "r" (v), "r" (a), "r" (u) 147 : "r" (v), "r" (a), "r" (u)
146 : "memory", "p3" 148 : "memory", "p3"
147 ); 149 );
148 return output; 150 return __oldval;
149} 151}
150 152
151#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 153#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)