diff options
| author | Daiane Angolini <daiane.angolini@foundries.io> | 2025-01-03 10:59:26 -0300 |
|---|---|---|
| committer | Daiane Angolini <daiane.angolini@foundries.io> | 2025-01-03 10:59:26 -0300 |
| commit | c930b7842cfd5ccbb315735a35aa2011be20e5f7 (patch) | |
| tree | b0738739d89671e4794526fc2a3def9f0dcdbadb /lib/xarray.c | |
| parent | e1778dcaa00e0c13013abe353f88ae40047d8ff3 (diff) | |
| parent | 63a57420cf797edcfca41005dd6c805b77cfb596 (diff) | |
Merge tag 'v6.6.54' into 6.6-2.2.x-imx
This is the 6.6.54 stable release
Signed-off-by: Daiane Angolini <daiane.angolini@foundries.io>
Diffstat (limited to 'lib/xarray.c')
| -rw-r--r-- | lib/xarray.c | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/lib/xarray.c b/lib/xarray.c index 39f07bfc4dcc..da79128ad754 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -1750,39 +1750,52 @@ unlock: EXPORT_SYMBOL(xa_store_range); /** - * xa_get_order() - Get the order of an entry. - * @xa: XArray. - * @index: Index of the entry. + * xas_get_order() - Get the order of an entry. + * @xas: XArray operation state. + * + * Called after xas_load, the xas should not be in an error state. * * Return: A number between 0 and 63 indicating the order of the entry. */ -int xa_get_order(struct xarray *xa, unsigned long index) +int xas_get_order(struct xa_state *xas) { - XA_STATE(xas, xa, index); - void *entry; int order = 0; - rcu_read_lock(); - entry = xas_load(&xas); - - if (!entry) - goto unlock; - - if (!xas.xa_node) - goto unlock; + if (!xas->xa_node) + return 0; for (;;) { - unsigned int slot = xas.xa_offset + (1 << order); + unsigned int slot = xas->xa_offset + (1 << order); if (slot >= XA_CHUNK_SIZE) break; - if (!xa_is_sibling(xas.xa_node->slots[slot])) + if (!xa_is_sibling(xa_entry(xas->xa, xas->xa_node, slot))) break; order++; } - order += xas.xa_node->shift; -unlock: + order += xas->xa_node->shift; + return order; +} +EXPORT_SYMBOL_GPL(xas_get_order); + +/** + * xa_get_order() - Get the order of an entry. + * @xa: XArray. + * @index: Index of the entry. + * + * Return: A number between 0 and 63 indicating the order of the entry. + */ +int xa_get_order(struct xarray *xa, unsigned long index) +{ + XA_STATE(xas, xa, index); + int order = 0; + void *entry; + + rcu_read_lock(); + entry = xas_load(&xas); + if (entry) + order = xas_get_order(&xas); rcu_read_unlock(); return order; |
