Merge branch 'iommu/fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/joro...
[pandora-kernel.git] / arch / microblaze / include / asm / atomic.h
1 #ifndef _ASM_MICROBLAZE_ATOMIC_H
2 #define _ASM_MICROBLAZE_ATOMIC_H
3
4 #include <asm-generic/atomic.h>
5 #include <asm-generic/atomic64.h>
6
7 /*
8  * Atomically test *v and decrement if it is greater than 0.
9  * The function returns the old value of *v minus 1.
10  */
11 static inline int atomic_dec_if_positive(atomic_t *v)
12 {
13         unsigned long flags;
14         int res;
15
16         local_irq_save(flags);
17         res = v->counter - 1;
18         if (res >= 0)
19                 v->counter = res;
20         local_irq_restore(flags);
21
22         return res;
23 }
24
25 #endif /* _ASM_MICROBLAZE_ATOMIC_H */