blob: 472d8bf726df41ae4e82d2b4ba320c3de3172ee9 [file] [log] [blame]
Michal Simek10713b12009-03-27 14:25:36 +01001#ifndef _ASM_MICROBLAZE_ATOMIC_H
2#define _ASM_MICROBLAZE_ATOMIC_H
3
David Howellsc40d04d2012-03-28 18:30:02 +01004#include <asm/cmpxchg.h>
Remis Lima Baima0a584582009-06-18 19:55:33 +02005#include <asm-generic/atomic.h>
Daniel Borkmanneacb6ec2012-01-19 12:37:13 +01006#include <asm-generic/atomic64.h>
Michal Simek10713b12009-03-27 14:25:36 +01007
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}
25
Michal Simek10713b12009-03-27 14:25:36 +010026#endif /* _ASM_MICROBLAZE_ATOMIC_H */