UPSTREAM: core: ofnode: add ofnode_get_parent function

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.

Change-Id: I312236c966348aaa36ffc30e3f7dbc83d706fb36
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>
Signed-off-by: Wyon Bi <bivvy.bi@rock-chips.com>
(cherry picked from commit e2d5997ffdf5cbf4f7d53584dab2ffc673f50987)
This commit is contained in:
Philipp Tomsich 2018-02-23 17:38:49 +01:00 committed by Jianhong Chen
parent 280f977d91
commit e7ca7e39ee
2 changed files with 22 additions and 0 deletions

View 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)
{
if(!ofnode_valid(node)){

View 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
*