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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With