What is idr_alloc ()

The source code implementation says that it is idr_alloc()used to highlight a new record idr. I could not find man pageand want to know why it is used, especially when writing drivers for devices MTD.

+5
source share
1 answer

The library is idrused in the kernel to control the assignment of whole identifiers to objects and search for objects by identifier. See this article with the LWN net article for a complete reference; The basic idea is that you have the following operations:

  • idr_get_new(struct idr *idp, void *ptr, int *id)- assign a new identifier for the pointer ptrand return it viaid

  • void *idr_find(struct idr *idp, int id) - return the pointer corresponding id

  • void idr_remove(struct idr *idp, int id) - id

, , - , , .

+6

All Articles