
Hello,
attached you can find a patch implementing fdt_find_compatible_node():
/* * Find a node based on its device type and one of the tokens in * its its "compatible" property. On success, the offset of that * node is returned or an error code: * * startoffset - the node to start searching from or 0, the node * you pass will not be searched, only the next one * will; typically, you pass 0 to start the search * and then what the previous call returned. * type - the device type string to match against * compat - the string to match to one of the tokens * in the "compatible" list. */
It should be used as shown below:
offset = 0; do { offset = fdt_find_compatible_node(fdt, offset, "type", "comp"); } while (offset >= 0);
This first hack also implements a cached version as alternative, because tag re-scanning might take quite long. In principle, the cache could also be used for other functions, like fdt_path_offset(), and could be invalidated in case the FDT gets updated.
What do you think?
Thanks.
Wolfgang.