From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Grandegger Date: Wed, 25 Apr 2007 10:58:25 +0200 Subject: [U-Boot-Users] LIBFDT: first version of fdt_find_compatible_node Message-ID: <462F1831.7070902@grandegger.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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. -------------- next part -------------- A non-text attachment was scrubbed... Name: u-boot-fdt-find-compatible.patch Type: text/x-patch Size: 6384 bytes Desc: not available Url : http://lists.denx.de/pipermail/u-boot/attachments/20070425/c8d036c1/attachment.bin