aboutsummaryrefslogtreecommitdiffstats
path: root/lib/xarray.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xarray.c')
-rw-r--r--lib/xarray.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/xarray.c b/lib/xarray.c
index e7be4e47c6a9..9cab8cfef8a8 100644
--- a/lib/xarray.c
+++ b/lib/xarray.c
@@ -1488,7 +1488,7 @@ void *__xa_cmpxchg(struct xarray *xa, unsigned long index,
1488EXPORT_SYMBOL(__xa_cmpxchg); 1488EXPORT_SYMBOL(__xa_cmpxchg);
1489 1489
1490/** 1490/**
1491 * xa_reserve() - Reserve this index in the XArray. 1491 * __xa_reserve() - Reserve this index in the XArray.
1492 * @xa: XArray. 1492 * @xa: XArray.
1493 * @index: Index into array. 1493 * @index: Index into array.
1494 * @gfp: Memory allocation flags. 1494 * @gfp: Memory allocation flags.
@@ -1496,33 +1496,29 @@ EXPORT_SYMBOL(__xa_cmpxchg);
1496 * Ensures there is somewhere to store an entry at @index in the array. 1496 * Ensures there is somewhere to store an entry at @index in the array.
1497 * If there is already something stored at @index, this function does 1497 * If there is already something stored at @index, this function does
1498 * nothing. If there was nothing there, the entry is marked as reserved. 1498 * nothing. If there was nothing there, the entry is marked as reserved.
1499 * Loads from @index will continue to see a %NULL pointer until a 1499 * Loading from a reserved entry returns a %NULL pointer.
1500 * subsequent store to @index.
1501 * 1500 *
1502 * If you do not use the entry that you have reserved, call xa_release() 1501 * If you do not use the entry that you have reserved, call xa_release()
1503 * or xa_erase() to free any unnecessary memory. 1502 * or xa_erase() to free any unnecessary memory.
1504 * 1503 *
1505 * Context: Process context. Takes and releases the xa_lock, IRQ or BH safe 1504 * Context: Any context. Expects the xa_lock to be held on entry. May
1506 * if specified in XArray flags. May sleep if the @gfp flags permit. 1505 * release the lock, sleep and reacquire the lock if the @gfp flags permit.
1507 * Return: 0 if the reservation succeeded or -ENOMEM if it failed. 1506 * Return: 0 if the reservation succeeded or -ENOMEM if it failed.
1508 */ 1507 */
1509int xa_reserve(struct xarray *xa, unsigned long index, gfp_t gfp) 1508int __xa_reserve(struct xarray *xa, unsigned long index, gfp_t gfp)
1510{ 1509{
1511 XA_STATE(xas, xa, index); 1510 XA_STATE(xas, xa, index);
1512 unsigned int lock_type = xa_lock_type(xa);
1513 void *curr; 1511 void *curr;
1514 1512
1515 do { 1513 do {
1516 xas_lock_type(&xas, lock_type);
1517 curr = xas_load(&xas); 1514 curr = xas_load(&xas);
1518 if (!curr) 1515 if (!curr)
1519 xas_store(&xas, XA_ZERO_ENTRY); 1516 xas_store(&xas, XA_ZERO_ENTRY);
1520 xas_unlock_type(&xas, lock_type); 1517 } while (__xas_nomem(&xas, gfp));
1521 } while (xas_nomem(&xas, gfp));
1522 1518
1523 return xas_error(&xas); 1519 return xas_error(&xas);
1524} 1520}
1525EXPORT_SYMBOL(xa_reserve); 1521EXPORT_SYMBOL(__xa_reserve);
1526 1522
1527#ifdef CONFIG_XARRAY_MULTI 1523#ifdef CONFIG_XARRAY_MULTI
1528static void xas_set_range(struct xa_state *xas, unsigned long first, 1524static void xas_set_range(struct xa_state *xas, unsigned long first,