summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asm/atomic_compat.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/asm/atomic_compat.h b/include/asm/atomic_compat.h
index c769d6248..5eaccd7e7 100644
--- a/include/asm/atomic_compat.h
+++ b/include/asm/atomic_compat.h
@@ -32,6 +32,38 @@ static inline void atomic64_sub(__s64 i, atomic64_t *v)
spin_unlock_irqrestore(&v->lock, flags);
}
+#define atomic64_inc(v) (atomic64_add(1, (v)))
+#define atomic64_dec(v) (atomic64_sub(1, (v)))
+
+static inline __s64 atomic64_add_return(__s64 i, atomic64_t *v)
+{
+ unsigned long flags;
+ __s64 ret;
+
+ spin_lock_irqsave(&v->lock, flags);
+ v->val += i;
+ ret = v->val;
+ spin_unlock_irqrestore(&v->lock, flags);
+
+ return ret;
+}
+
+static inline __s64 atomic64_sub_return(__s64 i, atomic64_t *v)
+{
+ unsigned long flags;
+ __s64 ret;
+
+ spin_lock_irqsave(&v->lock, flags);
+ v->val -= i;
+ ret = v->val;
+ spin_unlock_irqrestore(&v->lock, flags);
+
+ return ret;
+}
+
+#define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
+#define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
+
static inline __s64 atomic64_read(atomic64_t *v)
{
unsigned long flags;