diff options
Diffstat (limited to 'include/linux/xarray.h')
-rw-r--r-- | include/linux/xarray.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/include/linux/xarray.h b/include/linux/xarray.h index 564892e19f8c..f492e21c4aa2 100644 --- a/include/linux/xarray.h +++ b/include/linux/xarray.h | |||
@@ -554,6 +554,60 @@ static inline void *xa_cmpxchg(struct xarray *xa, unsigned long index, | |||
554 | } | 554 | } |
555 | 555 | ||
556 | /** | 556 | /** |
557 | * xa_cmpxchg_bh() - Conditionally replace an entry in the XArray. | ||
558 | * @xa: XArray. | ||
559 | * @index: Index into array. | ||
560 | * @old: Old value to test against. | ||
561 | * @entry: New value to place in array. | ||
562 | * @gfp: Memory allocation flags. | ||
563 | * | ||
564 | * This function is like calling xa_cmpxchg() except it disables softirqs | ||
565 | * while holding the array lock. | ||
566 | * | ||
567 | * Context: Any context. Takes and releases the xa_lock while | ||
568 | * disabling softirqs. May sleep if the @gfp flags permit. | ||
569 | * Return: The old value at this index or xa_err() if an error happened. | ||
570 | */ | ||
571 | static inline void *xa_cmpxchg_bh(struct xarray *xa, unsigned long index, | ||
572 | void *old, void *entry, gfp_t gfp) | ||
573 | { | ||
574 | void *curr; | ||
575 | |||
576 | xa_lock_bh(xa); | ||
577 | curr = __xa_cmpxchg(xa, index, old, entry, gfp); | ||
578 | xa_unlock_bh(xa); | ||
579 | |||
580 | return curr; | ||
581 | } | ||
582 | |||
583 | /** | ||
584 | * xa_cmpxchg_irq() - Conditionally replace an entry in the XArray. | ||
585 | * @xa: XArray. | ||
586 | * @index: Index into array. | ||
587 | * @old: Old value to test against. | ||
588 | * @entry: New value to place in array. | ||
589 | * @gfp: Memory allocation flags. | ||
590 | * | ||
591 | * This function is like calling xa_cmpxchg() except it disables interrupts | ||
592 | * while holding the array lock. | ||
593 | * | ||
594 | * Context: Process context. Takes and releases the xa_lock while | ||
595 | * disabling interrupts. May sleep if the @gfp flags permit. | ||
596 | * Return: The old value at this index or xa_err() if an error happened. | ||
597 | */ | ||
598 | static inline void *xa_cmpxchg_irq(struct xarray *xa, unsigned long index, | ||
599 | void *old, void *entry, gfp_t gfp) | ||
600 | { | ||
601 | void *curr; | ||
602 | |||
603 | xa_lock_irq(xa); | ||
604 | curr = __xa_cmpxchg(xa, index, old, entry, gfp); | ||
605 | xa_unlock_irq(xa); | ||
606 | |||
607 | return curr; | ||
608 | } | ||
609 | |||
610 | /** | ||
557 | * xa_insert() - Store this entry in the XArray unless another entry is | 611 | * xa_insert() - Store this entry in the XArray unless another entry is |
558 | * already present. | 612 | * already present. |
559 | * @xa: XArray. | 613 | * @xa: XArray. |