diff options
| -rw-r--r-- | include/linux/atomic.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/atomic.h b/include/linux/atomic.h index df4f369254c0..3d64c0852164 100644 --- a/include/linux/atomic.h +++ b/include/linux/atomic.h | |||
| @@ -559,6 +559,27 @@ static inline int atomic_dec_if_positive(atomic_t *v) | |||
| 559 | #endif | 559 | #endif |
| 560 | 560 | ||
| 561 | /** | 561 | /** |
| 562 | * atomic_fetch_or - perform *p |= mask and return old value of *p | ||
| 563 | * @p: pointer to atomic_t | ||
| 564 | * @mask: mask to OR on the atomic_t | ||
| 565 | */ | ||
| 566 | #ifndef atomic_fetch_or | ||
| 567 | static inline int atomic_fetch_or(atomic_t *p, int mask) | ||
| 568 | { | ||
| 569 | int old, val = atomic_read(p); | ||
| 570 | |||
| 571 | for (;;) { | ||
| 572 | old = atomic_cmpxchg(p, val, val | mask); | ||
| 573 | if (old == val) | ||
| 574 | break; | ||
| 575 | val = old; | ||
| 576 | } | ||
| 577 | |||
| 578 | return old; | ||
| 579 | } | ||
| 580 | #endif | ||
| 581 | |||
| 582 | /** | ||
| 562 | * fetch_or - perform *ptr |= mask and return old value of *ptr | 583 | * fetch_or - perform *ptr |= mask and return old value of *ptr |
| 563 | * @ptr: pointer to value | 584 | * @ptr: pointer to value |
| 564 | * @mask: mask to OR on the value | 585 | * @mask: mask to OR on the value |
