1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _ASM_MICROBLAZE_ATOMIC_H 3 #define _ASM_MICROBLAZE_ATOMIC_H 4 5 #include <asm/cmpxchg.h> 6 #include <asm-generic/atomic.h> 7 #include <asm-generic/atomic64.h> 8 9 /* 10 * Atomically test *v and decrement if it is greater than 0. 11 * The function returns the old value of *v minus 1. 12 */ atomic_dec_if_positive(atomic_t * v)13static inline int atomic_dec_if_positive(atomic_t *v) 14 { 15 unsigned long flags; 16 int res; 17 18 local_irq_save(flags); 19 res = v->counter - 1; 20 if (res >= 0) 21 v->counter = res; 22 local_irq_restore(flags); 23 24 return res; 25 } 26 #define atomic_dec_if_positive atomic_dec_if_positive 27 28 #endif /* _ASM_MICROBLAZE_ATOMIC_H */ 29