Skip to content

Commit bfc18e3

Browse files
mrutland-armingomolnar
authored andcommitted
atomics/treewide: Rename __atomic_add_unless() => atomic_fetch_add_unless()
While __atomic_add_unless() was originally intended as a building-block for atomic_add_unless(), it's now used in a number of places around the kernel. It's the only common atomic operation named __atomic*(), rather than atomic_*(), and for consistency it would be better named atomic_fetch_add_unless(). This lack of consistency is slightly confusing, and gets in the way of scripting atomics. Given that, let's clean things up and promote it to an official part of the atomics API, in the form of atomic_fetch_add_unless(). This patch converts definitions and invocations over to the new name, including the instrumented version, using the following script: ---- git grep -w __atomic_add_unless | while read line; do sed -i '{s/\<__atomic_add_unless\>/atomic_fetch_add_unless/}' "${line%%:*}"; done git grep -w __arch_atomic_add_unless | while read line; do sed -i '{s/\<__arch_atomic_add_unless\>/arch_atomic_fetch_add_unless/}' "${line%%:*}"; done ---- Note that we do not have atomic{64,_long}_fetch_add_unless(), which will be introduced by later patches. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Will Deacon <will.deacon@arm.com> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Palmer Dabbelt <palmer@sifive.com> Cc: Boqun Feng <boqun.feng@gmail.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/lkml/20180621121321.4761-2-mark.rutland@arm.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 356c6fe commit bfc18e3

31 files changed

Lines changed: 50 additions & 50 deletions

File tree

‎arch/alpha/include/asm/atomic.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,15 @@ ATOMIC_OPS(xor, xor)
206206
#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
207207

208208
/**
209-
* __atomic_add_unless - add unless the number is a given value
209+
* atomic_fetch_add_unless - add unless the number is a given value
210210
* @v: pointer of type atomic_t
211211
* @a: the amount to add to v...
212212
* @u: ...unless v is equal to u.
213213
*
214214
* Atomically adds @a to @v, so long as it was not @u.
215215
* Returns the old value of @v.
216216
*/
217-
static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
217+
static __inline__ int atomic_fetch_add_unless(atomic_t *v, int a, int u)
218218
{
219219
int c, new, old;
220220
smp_mb();

‎arch/arc/include/asm/atomic.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,15 @@ ATOMIC_OPS(xor, ^=, CTOP_INST_AXOR_DI_R2_R2_R3)
309309
#undef ATOMIC_OP
310310

311311
/**
312-
* __atomic_add_unless - add unless the number is a given value
312+
* atomic_fetch_add_unless - add unless the number is a given value
313313
* @v: pointer of type atomic_t
314314
* @a: the amount to add to v...
315315
* @u: ...unless v is equal to u.
316316
*
317317
* Atomically adds @a to @v, so long as it was not @u.
318318
* Returns the old value of @v
319319
*/
320-
#define __atomic_add_unless(v, a, u) \
320+
#define atomic_fetch_add_unless(v, a, u) \
321321
({ \
322322
int c, old; \
323323
\

‎arch/arm/include/asm/atomic.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static inline int atomic_cmpxchg_relaxed(atomic_t *ptr, int old, int new)
130130
}
131131
#define atomic_cmpxchg_relaxed atomic_cmpxchg_relaxed
132132

133-
static inline int __atomic_add_unless(atomic_t *v, int a, int u)
133+
static inline int atomic_fetch_add_unless(atomic_t *v, int a, int u)
134134
{
135135
int oldval, newval;
136136
unsigned long tmp;
@@ -215,7 +215,7 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
215215
return ret;
216216
}
217217

218-
static inline int __atomic_add_unless(atomic_t *v, int a, int u)
218+
static inline int atomic_fetch_add_unless(atomic_t *v, int a, int u)
219219
{
220220
int c, old;
221221

‎arch/arm64/include/asm/atomic.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
#define atomic_dec_and_test(v) (atomic_dec_return(v) == 0)
126126
#define atomic_sub_and_test(i, v) (atomic_sub_return((i), (v)) == 0)
127127
#define atomic_add_negative(i, v) (atomic_add_return((i), (v)) < 0)
128-
#define __atomic_add_unless(v, a, u) ___atomic_add_unless(v, a, u,)
128+
#define atomic_fetch_add_unless(v, a, u) ___atomic_add_unless(v, a, u,)
129129
#define atomic_andnot atomic_andnot
130130

131131
/*

‎arch/h8300/include/asm/atomic.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
9494
return ret;
9595
}
9696

97-
static inline int __atomic_add_unless(atomic_t *v, int a, int u)
97+
static inline int atomic_fetch_add_unless(atomic_t *v, int a, int u)
9898
{
9999
int ret;
100100
h8300flags flags;

‎arch/hexagon/include/asm/atomic.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ ATOMIC_OPS(xor)
164164
#undef ATOMIC_OP
165165

166166
/**
167-
* __atomic_add_unless - add unless the number is a given value
167+
* atomic_fetch_add_unless - add unless the number is a given value
168168
* @v: pointer to value
169169
* @a: amount to add
170170
* @u: unless value is equal to u
@@ -173,7 +173,7 @@ ATOMIC_OPS(xor)
173173
*
174174
*/
175175

176-
static inline int __atomic_add_unless(atomic_t *v, int a, int u)
176+
static inline int atomic_fetch_add_unless(atomic_t *v, int a, int u)
177177
{
178178
int __oldval;
179179
register int tmp;

‎arch/ia64/include/asm/atomic.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ ATOMIC64_FETCH_OP(xor, ^)
215215
(cmpxchg(&((v)->counter), old, new))
216216
#define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
217217

218-
static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
218+
static __inline__ int atomic_fetch_add_unless(atomic_t *v, int a, int u)
219219
{
220220
int c, old;
221221
c = atomic_read(v);

‎arch/m68k/include/asm/atomic.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static inline int atomic_add_negative(int i, atomic_t *v)
211211
return c != 0;
212212
}
213213

214-
static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
214+
static __inline__ int atomic_fetch_add_unless(atomic_t *v, int a, int u)
215215
{
216216
int c, old;
217217
c = atomic_read(v);

‎arch/mips/include/asm/atomic.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,15 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
275275
#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
276276

277277
/**
278-
* __atomic_add_unless - add unless the number is a given value
278+
* atomic_fetch_add_unless - add unless the number is a given value
279279
* @v: pointer of type atomic_t
280280
* @a: the amount to add to v...
281281
* @u: ...unless v is equal to u.
282282
*
283283
* Atomically adds @a to @v, so long as it was not @u.
284284
* Returns the old value of @v.
285285
*/
286-
static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
286+
static __inline__ int atomic_fetch_add_unless(atomic_t *v, int a, int u)
287287
{
288288
int c, old;
289289
c = atomic_read(v);

‎arch/openrisc/include/asm/atomic.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ ATOMIC_OP(xor)
100100
*
101101
* This is often used through atomic_inc_not_zero()
102102
*/
103-
static inline int __atomic_add_unless(atomic_t *v, int a, int u)
103+
static inline int atomic_fetch_add_unless(atomic_t *v, int a, int u)
104104
{
105105
int old, tmp;
106106

@@ -119,7 +119,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
119119

120120
return old;
121121
}
122-
#define __atomic_add_unless __atomic_add_unless
122+
#define atomic_fetch_add_unless atomic_fetch_add_unless
123123

124124
#include <asm-generic/atomic.h>
125125

0 commit comments

Comments
 (0)