Name

idr_alloc — allocate an id

Synopsis

int idr_alloc (struct idr * idr,
 void * ptr,
 int start,
 int end,
 gfp_t gfp);
 

Arguments

struct idr * idr

idr handle

void * ptr

pointer to be associated with the new id

int start

the minimum id (inclusive)

int end

the maximum id (exclusive)

gfp_t gfp

memory allocation flags

Description

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.