]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/microblaze/include/asm/atomic.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-bionic-kernel.git] / arch / microblaze / include / asm / atomic.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
10713b1d
MS
2#ifndef _ASM_MICROBLAZE_ATOMIC_H
3#define _ASM_MICROBLAZE_ATOMIC_H
4
c40d04df 5#include <asm/cmpxchg.h>
0a584583 6#include <asm-generic/atomic.h>
eacb6ec9 7#include <asm-generic/atomic64.h>
10713b1d
MS
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 */
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}
e79bee24 26#define atomic_dec_if_positive atomic_dec_if_positive
10713b1d 27
10713b1d 28#endif /* _ASM_MICROBLAZE_ATOMIC_H */