2009-03-27 16:25:36 +03:00
|
|
|
#ifndef _ASM_MICROBLAZE_ATOMIC_H
|
|
|
|
#define _ASM_MICROBLAZE_ATOMIC_H
|
|
|
|
|
2009-06-18 21:55:33 +04:00
|
|
|
#include <asm-generic/atomic.h>
|
2009-03-27 16:25:36 +03: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _ASM_MICROBLAZE_ATOMIC_H */
|