I was going through chipidea usb otg driver code and I see such similar definitions numerous times.
static DEFINE_IDA(ci_ida);
I don't get what it meant in the programming world and its purpose. Can someone please explain the same?
As already noted, DEFINE_IDE(name)
is #define
d as struct ida name = IDA_INIT(name)
. You should check out LXR which is very convenient for browsing kernel source.
IDR is a subsystem in the kernel that provides an efficient way to map ids to pointers. Normally you would use the id as an offset into an array of pointers, but this limits how big your ids are. IDR solves this by using radix trees instead for lookup.
Sometimes you just want unique ids without associating them with pointers and that's what IDA is for.
/* IDA - IDR based ID allocator
*
* This is id allocator without id -> pointer translation. Memory
* usage is much lower than full blown idr because each id only
* occupies a bit.