summaryrefslogtreecommitdiffstats
path: root/include/linux/xarray.h
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2018-12-20 13:53:28 -0500
committerDavid S. Miller <davem@davemloft.net>2018-12-20 14:53:36 -0500
commit2be09de7d6a06f58e768de1255a687c9aaa66606 (patch)
tree298f9e04caf105873d987e807eccba27710a49cc /include/linux/xarray.h
parent44a7b3b6e3a458f9549c2cc28e74ecdc470e42f1 (diff)
parent1d51b4b1d3f2db0d6d144175e31a84e472fbd99a (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Lots of conflicts, by happily all cases of overlapping changes, parallel adds, things of that nature. Thanks to Stephen Rothwell, Saeed Mahameed, and others for their guidance in these resolutions. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/xarray.h')
-rw-r--r--include/linux/xarray.h54
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 */
571static 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 */
598static 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.