Skip to contentSkip to conversation

frv: add atomic64_add_unless()

PATCH New [email protected] 1 participant 1 message Jan 24, 2017 Atomic infrastructure

lore
Share & tools
lore
#0 lore raw

PATCH 14/26 frv: add atomic64_add_unless()

From: Sudip Mukherjee <[email protected]>
Subject: frv: add atomic64_add_unless()

The build of frv allmodconfig was failing with the error:
lib/atomic64_test.c:209:9: error:

implicit declaration of function 'atomic64_add_unless'

All the atomic64 operations were defined in frv, but atomic64_add_unless() was not done. Implement atomic64_add_unless() as done in other arches.

---

 arch/frv/include/asm/atomic.h |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/frv/include/asm/atomic.h renamed from arch/frv/include/asm/atomic.h~frv-add-atomic64_add_unless +16 -0
diff -puN arch/frv/include/asm/atomic.h~frv-add-atomic64_add_unless arch/frv/include/asm/atomic.h
@@ -161,6 +161,22 @@ static __inline__ int __atomic_add_unles
 	return c;
 }
 
+static inline int atomic64_add_unless(atomic64_t *v, long long i, long long u)
+{
+	long long c, old;
+
+	c = atomic64_read(v);
+	for (;;) {
+		if (unlikely(c == u))
+			break;
+		old = atomic64_cmpxchg(v, c, c + i);
+		if (likely(old == c))
+			break;
+		c = old;
+	}
+	return c != u;
+}
+
 #define ATOMIC_OP(op)							\
 static inline int atomic_fetch_##op(int i, atomic_t *v)			\
 {									\

_