Merge tag 'platform-drivers-x86-v4.2-2' of git://git.infradead.org/users/dvhart/linux...
[linux-2.6-block.git] / arch / microblaze / include / asm / atomic.h
CommitLineData
10713b1d
MS
1#ifndef _ASM_MICROBLAZE_ATOMIC_H
2#define _ASM_MICROBLAZE_ATOMIC_H
3
c40d04df 4#include <asm/cmpxchg.h>
0a584583 5#include <asm-generic/atomic.h>
eacb6ec9 6#include <asm-generic/atomic64.h>
10713b1d
MS
7
8/*
9 * Atomically test *v and decrement if it is greater than 0.
10 * The function returns the old value of *v minus 1.
11 */
12static inline int atomic_dec_if_positive(atomic_t *v)
13{
14 unsigned long flags;
15 int res;
16
17 local_irq_save(flags);
18 res = v->counter - 1;
19 if (res >= 0)
20 v->counter = res;
21 local_irq_restore(flags);
22
23 return res;
24}
e79bee24 25#define atomic_dec_if_positive atomic_dec_if_positive
10713b1d 26
10713b1d 27#endif /* _ASM_MICROBLAZE_ATOMIC_H */