idr_alloc — allocate an id
int idr_alloc ( | struct idr * idr, |
| void * ptr, | |
| int start, | |
| int end, | |
gfp_t gfp); |
struct idr * idridr handle
void * ptrpointer to be associated with the new id
int startthe minimum id (inclusive)
int endthe maximum id (exclusive)
gfp_t gfpmemory allocation flags
Allocates an unused ID in the range [start, end). Returns -ENOSPC if there are no unused IDs in that range.
Note that end is treated as max when <= 0. This is to always allow
using start + N as end as long as N is inside integer range.
Simultaneous modifications to the idr are not allowed and should be
prevented by the user, usually with a lock. idr_alloc may be called
concurrently with read-only accesses to the idr, such as idr_find and
idr_for_each_entry.