Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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