Reputation: 11394
In the source code implementation it says idr_alloc()
is used to allocate new idr
entry. I couldn't find the man page
and want to know why it is used especially when writing drivers for MTD
devices.
Upvotes: 7
Views: 4183
Reputation: 6563
The idr
library is used in the kernel to manage assigning integer IDs to objects and looking up objects by id. See this LWN net article for a full introduction; the basic idea is that you have the following operations:
idr_get_new(struct idr *idp, void *ptr, int *id)
-- assign a new ID for the pointer ptr
and return it via id
void *idr_find(struct idr *idp, int id)
-- return the pointer corresponding to id
void idr_remove(struct idr *idp, int id)
-- clear the entry for id
This is useful anywhere a small integer ID that maps to a kernel object is useful -- eg minor numbers or other indexes that are returned to userspace.
Upvotes: 8