blob: 615f53992c654e4f78625bf8708d5d92c7c12b09 [file] [log] [blame]
Michal Simek10713b12009-03-27 14:25:36 +01001#ifndef _ASM_MICROBLAZE_ATOMIC_H
2#define _ASM_MICROBLAZE_ATOMIC_H
3
Remis Lima Baima0a584582009-06-18 19:55:33 +02004#include <asm-generic/atomic.h>
Daniel Borkmanneacb6ec2012-01-19 12:37:13 +01005#include <asm-generic/atomic64.h>
Michal Simek10713b12009-03-27 14:25:36 +01006
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 */
11static 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
Michal Simek10713b12009-03-27 14:25:36 +010025#endif /* _ASM_MICROBLAZE_ATOMIC_H */