summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2012-04-02 13:18:42 +0000
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>2012-05-15 08:31:36 +0200
commit3ddecfc74086aa185a2f671cc07cb826b72d35f0 (patch)
treeae643a3369183c2286b8e2a9c503eb4f40d759be /lib
parent96875e7d3b9900d0e63f0b591ff5693b31c4d9c3 (diff)
downloadu-boot-imx-3ddecfc74086aa185a2f671cc07cb826b72d35f0.zip
u-boot-imx-3ddecfc74086aa185a2f671cc07cb826b72d35f0.tar.gz
u-boot-imx-3ddecfc74086aa185a2f671cc07cb826b72d35f0.tar.bz2
fdt: Add function to return next compatible subnode
We need to iterate through subnodes of a parent, looking only at compatible nodes. Add a utility function to do this for us. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Warren <twarren@nvidia.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/fdtdec.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 4a5ab71..76d3808 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -133,6 +133,21 @@ int fdtdec_next_compatible(const void *blob, int node,
return fdt_node_offset_by_compatible(blob, node, compat_names[id]);
}
+int fdtdec_next_compatible_subnode(const void *blob, int node,
+ enum fdt_compat_id id, int *depthp)
+{
+ do {
+ node = fdt_next_node(blob, node, depthp);
+ } while (*depthp > 1);
+
+ /* If this is a direct subnode, and compatible, return it */
+ if (*depthp == 1 && 0 == fdt_node_check_compatible(
+ blob, node, compat_names[id]))
+ return node;
+
+ return -FDT_ERR_NOTFOUND;
+}
+
int fdtdec_next_alias(const void *blob, const char *name,
enum fdt_compat_id id, int *upto)
{