Mark Rutland | ace9bad | 2018-09-04 11:48:25 +0100 | [diff] [blame] | 1 | cat <<EOF |
| 2 | /** |
Mark Rutland | f3e615b | 2021-07-13 11:52:50 +0100 | [diff] [blame] | 3 | * arch_${atomic}_inc_not_zero - increment unless the number is zero |
Mark Rutland | ace9bad | 2018-09-04 11:48:25 +0100 | [diff] [blame] | 4 | * @v: pointer of type ${atomic}_t |
| 5 | * |
| 6 | * Atomically increments @v by 1, if @v is non-zero. |
| 7 | * Returns true if the increment was done. |
| 8 | */ |
Marco Elver | 765dcd2 | 2019-11-26 15:04:05 +0100 | [diff] [blame] | 9 | static __always_inline bool |
Mark Rutland | f3e615b | 2021-07-13 11:52:50 +0100 | [diff] [blame] | 10 | arch_${atomic}_inc_not_zero(${atomic}_t *v) |
Mark Rutland | ace9bad | 2018-09-04 11:48:25 +0100 | [diff] [blame] | 11 | { |
Mark Rutland | f3e615b | 2021-07-13 11:52:50 +0100 | [diff] [blame] | 12 | return arch_${atomic}_add_unless(v, 1, 0); |
Mark Rutland | ace9bad | 2018-09-04 11:48:25 +0100 | [diff] [blame] | 13 | } |
| 14 | EOF |