diff options
| author | Matthew Wilcox <[email protected]> | 2016-12-14 15:09:19 -0800 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2016-12-14 16:04:10 -0800 |
| commit | 444306129a920015a2cc876d13fcbf52382f39bd (patch) | |
| tree | 97b472a7a3a5e556d9ed331cbee0a75233bc1efe /include/linux | |
| parent | 37f4915fef0572e41ab91b7d3f7feb237cddbd92 (diff) | |
rxrpc: abstract away knowledge of IDR internals
Add idr_get_cursor() / idr_set_cursor() APIs, and remove the reference
to IDR_SIZE.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Matthew Wilcox <[email protected]>
Reviewed-by: David Howells <[email protected]>
Tested-by: Kirill A. Shutemov <[email protected]>
Cc: Konstantin Khlebnikov <[email protected]>
Cc: Ross Zwisler <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/idr.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/idr.h b/include/linux/idr.h index 3639a28188c9..1eb755f77f2f 100644 --- a/include/linux/idr.h +++ b/include/linux/idr.h @@ -56,6 +56,32 @@ struct idr { #define DEFINE_IDR(name) struct idr name = IDR_INIT(name) /** + * idr_get_cursor - Return the current position of the cyclic allocator + * @idr: idr handle + * + * The value returned is the value that will be next returned from + * idr_alloc_cyclic() if it is free (otherwise the search will start from + * this position). + */ +static inline unsigned int idr_get_cursor(struct idr *idr) +{ + return READ_ONCE(idr->cur); +} + +/** + * idr_set_cursor - Set the current position of the cyclic allocator + * @idr: idr handle + * @val: new position + * + * The next call to idr_alloc_cyclic() will return @val if it is free + * (otherwise the search will start from this position). + */ +static inline void idr_set_cursor(struct idr *idr, unsigned int val) +{ + WRITE_ONCE(idr->cur, val); +} + +/** * DOC: idr sync * idr synchronization (stolen from radix-tree.h) * |