I'm probably missing something obvious, but: Aren't phandles in practiceHaven't noticed this earlier !! If following is known or true, we can avoid
small consecutive integers assigned by dtc? If so, why not just have a
smallish static array mapping the small phandle values directly to
device node, instead of adding a pointer to every struct device_node? Or
one could determine the size of the array dynamically (largest seen
phandle value, capping at something sensible, e.g. 1024).
In either case, one would still need to keep the code doing theI would refrain doing this because that will make this API inconsistent in terms
whole-tree traversal for handling large phandle values, but I think the
above should make lookup O(1) in most cases.
Alternatively, one could just count the number of nodes with a phandle,This is certainly doable if current approach is not welcomed due to
allocate an array of that many pointers (so the memory use is certainly
no more than if adding a pointer to each device_node), and sort it by
phandle, so one can do lookup using a binary search.
Rasmus