1IDR_ALLOC(9) Basic Kernel Library Functions IDR_ALLOC(9)
2
3
4
6 idr_alloc - allocate new idr entry
7
9 int idr_alloc(struct idr * idr, void * ptr, int start, int end,
10 gfp_t gfp_mask);
11
13 idr
14 the (initialized) idr
15
16 ptr
17 pointer to be associated with the new id
18
19 start
20 the minimum id (inclusive)
21
22 end
23 the maximum id (exclusive, <= 0 for max)
24
25 gfp_mask
26 memory allocation flags
27
29 Allocate an id in [start, end) and associate it with ptr. If no ID is
30 available in the specified range, returns -ENOSPC. On memory allocation
31 failure, returns -ENOMEM.
32
33 Note that end is treated as max when <= 0. This is to always allow
34 using start + N as end as long as N is inside integer range.
35
36 The user is responsible for exclusively synchronizing all operations
37 which may modify idr. However, read-only accesses such as idr_find or
38 iteration can be performed under RCU read lock provided the user
39 destroys ptr in RCU-safe way after removal from idr.
40
42Kernel Hackers Manual 3.10 June 2019 IDR_ALLOC(9)