Merge tag 'for-5.18-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
[linux-block.git] / scripts / atomic / fallbacks / dec_if_positive
CommitLineData
ace9bad4 1cat <<EOF
765dcd20 2static __always_inline ${ret}
f3e615b4 3arch_${atomic}_dec_if_positive(${atomic}_t *v)
ace9bad4 4{
f3e615b4 5 ${int} dec, c = arch_${atomic}_read(v);
ace9bad4
MR
6
7 do {
8 dec = c - 1;
9 if (unlikely(dec < 0))
10 break;
f3e615b4 11 } while (!arch_${atomic}_try_cmpxchg(v, &c, dec));
ace9bad4
MR
12
13 return dec;
14}
15EOF