2009-03-27 07:25:36 -06:00
|
|
|
#ifndef _ASM_MICROBLAZE_ATOMIC_H
|
|
|
|
#define _ASM_MICROBLAZE_ATOMIC_H
|
|
|
|
|
2012-03-28 11:30:02 -06:00
|
|
|
#include <asm/cmpxchg.h>
|
2009-06-18 11:55:33 -06:00
|
|
|
#include <asm-generic/atomic.h>
|
2012-01-19 04:37:13 -07:00
|
|
|
#include <asm-generic/atomic64.h>
|
2009-03-27 07:25:36 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Atomically test *v and decrement if it is greater than 0.
|
|
|
|
* The function returns the old value of *v minus 1.
|
|
|
|
*/
|
|
|
|
static inline int atomic_dec_if_positive(atomic_t *v)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int res;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
res = v->counter - 1;
|
|
|
|
if (res >= 0)
|
|
|
|
v->counter = res;
|
|
|
|
local_irq_restore(flags);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2012-10-08 17:32:18 -06:00
|
|
|
#define atomic_dec_if_positive atomic_dec_if_positive
|
2009-03-27 07:25:36 -06:00
|
|
|
|
|
|
|
#endif /* _ASM_MICROBLAZE_ATOMIC_H */
|