'\" t .\" Title: idr_alloc .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: June 2017 .\" Manual: Basic Kernel Library Functions .\" Source: Kernel Hackers Manual 4.11.3 .\" Language: English .\" .TH "IDR_ALLOC" "9" "June 2017" "Kernel Hackers Manual 4\&.11\&" "Basic Kernel Library Functions" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" idr_alloc \- allocate an id .SH "SYNOPSIS" .HP \w'int\ idr_alloc('u .BI "int idr_alloc(struct\ idr\ *\ " "idr" ", void\ *\ " "ptr" ", int\ " "start" ", int\ " "end" ", gfp_t\ " "gfp" ");" .SH "ARGUMENTS" .PP \fIstruct idr * idr\fR .RS 4 idr handle .RE .PP \fIvoid * ptr\fR .RS 4 pointer to be associated with the new id .RE .PP \fIint start\fR .RS 4 the minimum id (inclusive) .RE .PP \fIint end\fR .RS 4 the maximum id (exclusive) .RE .PP \fIgfp_t gfp\fR .RS 4 memory allocation flags .RE .SH "DESCRIPTION" .PP Allocates an unused ID in the range [start, end)\&. Returns \-ENOSPC if there are no unused IDs in that range\&. .PP Note that \fIend\fR is treated as max when <= 0\&. This is to always allow using \fIstart\fR + N as \fIend\fR as long as N is inside integer range\&. .PP Simultaneous modifications to the \fIidr\fR are not allowed and should be prevented by the user, usually with a lock\&. \fBidr_alloc\fR may be called concurrently with read\-only accesses to the \fIidr\fR, such as \fBidr_find\fR and \fBidr_for_each_entry\fR\&. .SH "COPYRIGHT" .br