'\" t .\" Title: idr_alloc .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: January 2017 .\" Manual: Basic Kernel Library Functions .\" Source: Kernel Hackers Manual 4.8.15 .\" Language: English .\" .TH "IDR_ALLOC" "9" "January 2017" "Kernel Hackers Manual 4\&.8\&." "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 new idr entry .SH "SYNOPSIS" .HP \w'int\ idr_alloc('u .BI "int idr_alloc(struct\ idr\ *\ " "idr" ", void\ *\ " "ptr" ", int\ " "start" ", int\ " "end" ", gfp_t\ " "gfp_mask" ");" .SH "ARGUMENTS" .PP \fIidr\fR .RS 4 the (initialized) idr .RE .PP \fIptr\fR .RS 4 pointer to be associated with the new id .RE .PP \fIstart\fR .RS 4 the minimum id (inclusive) .RE .PP \fIend\fR .RS 4 the maximum id (exclusive, <= 0 for max) .RE .PP \fIgfp_mask\fR .RS 4 memory allocation flags .RE .SH "DESCRIPTION" .PP Allocate an id in [start, end) and associate it with \fIptr\fR\&. If no ID is available in the specified range, returns \-ENOSPC\&. On memory allocation failure, returns \-ENOMEM\&. .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 The user is responsible for exclusively synchronizing all operations which may modify \fIidr\fR\&. However, read\-only accesses such as \fBidr_find\fR or iteration can be performed under RCU read lock provided the user destroys \fIptr\fR in RCU\-safe way after removal from idr\&. .SH "COPYRIGHT" .br