]> git.sur5r.net Git - u-boot/commitdiff
core: ofnode: add ofnode_get_parent function
authorPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Fri, 23 Feb 2018 16:38:49 +0000 (17:38 +0100)
committerAnatolij Gustschin <agust@denx.de>
Fri, 23 Feb 2018 19:47:47 +0000 (20:47 +0100)
The Rockchip video drivers need to walk the ofnode-parrents to find
an enclosing device that has a UCLASS_DISPLAY driver bound.  This
adds a ofnode_get_parent()-function that returns the parent-node.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Tested-by: Klaus Goger <klaus.goger@theobroma-systems.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
drivers/core/ofnode.c
include/dm/ofnode.h

index 98f4b539ea4d6de876f1058104a260b7a400e035..dd6d57c49bd5c48ea12e20895c5b0e48e2854123 100644 (file)
@@ -165,6 +165,20 @@ ofnode ofnode_next_subnode(ofnode node)
                fdt_next_subnode(gd->fdt_blob, ofnode_to_offset(node)));
 }
 
+ofnode ofnode_get_parent(ofnode node)
+{
+       ofnode parent;
+
+       assert(ofnode_valid(node));
+       if (ofnode_is_np(node))
+               parent = np_to_ofnode(of_get_parent(ofnode_to_np(node)));
+       else
+               parent.of_offset = fdt_parent_offset(gd->fdt_blob,
+                                                    ofnode_to_offset(node));
+
+       return parent;
+}
+
 const char *ofnode_get_name(ofnode node)
 {
        assert(ofnode_valid(node));
index c359a60f9536a78830d33c23497ba412991e111d..6938e62993e83b8d9cda7d8f53a28182e1bb23c9 100644 (file)
@@ -301,6 +301,14 @@ ofnode ofnode_first_subnode(ofnode node);
  */
 ofnode ofnode_next_subnode(ofnode node);
 
+/**
+ * ofnode_get_parent() - get the ofnode's parent (enclosing ofnode)
+ *
+ * @node: valid node to look up
+ * @return ofnode reference of the parent node
+ */
+ofnode ofnode_get_parent(ofnode node);
+
 /**
  * ofnode_get_name() - get the name of a node
  *