diff options
Diffstat (limited to 'include/asm-s390/atomic.h')
-rw-r--r-- | include/asm-s390/atomic.h | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/include/asm-s390/atomic.h b/include/asm-s390/atomic.h index be6fefe223d6..de1d9926aa60 100644 --- a/include/asm-s390/atomic.h +++ b/include/asm-s390/atomic.h | |||
@@ -89,10 +89,15 @@ static __inline__ int atomic_cmpxchg(atomic_t *v, int old, int new) | |||
89 | static __inline__ int atomic_add_unless(atomic_t *v, int a, int u) | 89 | static __inline__ int atomic_add_unless(atomic_t *v, int a, int u) |
90 | { | 90 | { |
91 | int c, old; | 91 | int c, old; |
92 | |||
93 | c = atomic_read(v); | 92 | c = atomic_read(v); |
94 | while (c != u && (old = atomic_cmpxchg(v, c, c + a)) != c) | 93 | for (;;) { |
94 | if (unlikely(c == u)) | ||
95 | break; | ||
96 | old = atomic_cmpxchg(v, c, c + a); | ||
97 | if (likely(old == c)) | ||
98 | break; | ||
95 | c = old; | 99 | c = old; |
100 | } | ||
96 | return c != u; | 101 | return c != u; |
97 | } | 102 | } |
98 | 103 | ||
@@ -167,10 +172,15 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, | |||
167 | long long a, long long u) | 172 | long long a, long long u) |
168 | { | 173 | { |
169 | long long c, old; | 174 | long long c, old; |
170 | |||
171 | c = atomic64_read(v); | 175 | c = atomic64_read(v); |
172 | while (c != u && (old = atomic64_cmpxchg(v, c, c + a)) != c) | 176 | for (;;) { |
177 | if (unlikely(c == u)) | ||
178 | break; | ||
179 | old = atomic64_cmpxchg(v, c, c + a); | ||
180 | if (likely(old == c)) | ||
181 | break; | ||
173 | c = old; | 182 | c = old; |
183 | } | ||
174 | return c != u; | 184 | return c != u; |
175 | } | 185 | } |
176 | 186 | ||