Release 4.14 arch/sh/include/asm/atomic.h
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_SH_ATOMIC_H
#define __ASM_SH_ATOMIC_H
#if defined(CONFIG_CPU_J2)
#include <asm-generic/atomic.h>
#else
/*
* Atomic operations that C can't guarantee us. Useful for
* resource counting etc..
*
*/
#include <linux/compiler.h>
#include <linux/types.h>
#include <asm/cmpxchg.h>
#include <asm/barrier.h>
#define ATOMIC_INIT(i) { (i) }
#define atomic_read(v) READ_ONCE((v)->counter)
#define atomic_set(v,i) WRITE_ONCE((v)->counter, (i))
#if defined(CONFIG_GUSA_RB)
#include <asm/atomic-grb.h>
#elif defined(CONFIG_CPU_SH4A)
#include <asm/atomic-llsc.h>
#else
#include <asm/atomic-irq.h>
#endif
#define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
#define atomic_dec_return(v) atomic_sub_return(1, (v))
#define atomic_inc_return(v) atomic_add_return(1, (v))
#define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
#define atomic_sub_and_test(i,v) (atomic_sub_return((i), (v)) == 0)
#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0)
#define atomic_inc(v) atomic_add(1, (v))
#define atomic_dec(v) atomic_sub(1, (v))
#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
/**
* __atomic_add_unless - add unless the number is a given value
* @v: pointer of type atomic_t
* @a: the amount to add to v...
* @u: ...unless v is equal to u.
*
* Atomically adds @a to @v, so long as it was not @u.
* Returns the old value of @v.
*/
static inline int __atomic_add_unless(atomic_t *v, int a, int u)
{
int c, old;
c = atomic_read(v);
for (;;) {
if (unlikely(c == (u)))
break;
old = atomic_cmpxchg((v), c, c + (a));
if (likely(old == c))
break;
c = old;
}
return c;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paul Mundt | 48 | 58.54% | 1 | 33.33% |
Nicholas Piggin | 33 | 40.24% | 1 | 33.33% |
Arun Sharma | 1 | 1.22% | 1 | 33.33% |
Total | 82 | 100.00% | 3 | 100.00% |
#endif /* CONFIG_CPU_J2 */
#endif /* __ASM_SH_ATOMIC_H */
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paul Mundt | 77 | 31.05% | 3 | 17.65% |
Linus Torvalds (pre-git) | 70 | 28.23% | 1 | 5.88% |
Nicholas Piggin | 39 | 15.73% | 2 | 11.76% |
Andrew Morton | 16 | 6.45% | 2 | 11.76% |
Stuart Menefy | 14 | 5.65% | 1 | 5.88% |
Rich Felker | 14 | 5.65% | 1 | 5.88% |
Matthew Wilcox | 8 | 3.23% | 1 | 5.88% |
Peter Zijlstra | 5 | 2.02% | 2 | 11.76% |
Arun Sharma | 2 | 0.81% | 1 | 5.88% |
Greg Kroah-Hartman | 1 | 0.40% | 1 | 5.88% |
David Howells | 1 | 0.40% | 1 | 5.88% |
Nobuhiro Iwamatsu | 1 | 0.40% | 1 | 5.88% |
Total | 248 | 100.00% | 17 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.