public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] LIBFDT: first version of fdt_find_compatible_node
@ 2007-04-25  8:58 Wolfgang Grandegger
  2007-04-25 15:12 ` Jerry Van Baren
  0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Grandegger @ 2007-04-25  8:58 UTC (permalink / raw)
  To: u-boot

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 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-04-26 11:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-25  8:58 [U-Boot-Users] LIBFDT: first version of fdt_find_compatible_node Wolfgang Grandegger
2007-04-25 15:12 ` Jerry Van Baren
2007-04-25 19:37   ` Wolfgang Grandegger
2007-04-25 21:06     ` Jerry Van Baren
2007-04-26  7:39       ` Wolfgang Grandegger
2007-04-26  9:42         ` Wolfgang Grandegger
2007-04-26 10:45           ` Jerry Van Baren
2007-04-26 11:12             ` Wolfgang Grandegger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox