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/1480369871-5271-65-git-send-email-mawilcox@linuxonhyperv.com Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com> Reviewed-by: David Howells <dhowells@redhat.com> Tested-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Konstantin Khlebnikov <koct9i@gmail.com> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Cc: Matthew Wilcox <mawilcox@microsoft.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:

committed by
Linus Torvalds

parent
37f4915fef
commit
444306129a
@@ -55,6 +55,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)
|
||||
|
Reference in New Issue
Block a user