diff options
author | Philipp Tomsich <philipp.tomsich@theobroma-systems.com> | 2018-02-23 17:38:49 +0100 |
---|---|---|
committer | Anatolij Gustschin <agust@denx.de> | 2018-02-23 20:47:47 +0100 |
commit | e2d5997ffdf5cbf4f7d53584dab2ffc673f50987 (patch) | |
tree | f85fd1c36105b7a728145ec95b13dbc4a5b1e847 /drivers/core | |
parent | f0f6917188ad660cf002c10095f46ecf748b8f58 (diff) |
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.
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>
Diffstat (limited to 'drivers/core')
-rw-r--r-- | drivers/core/ofnode.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 98f4b539ea4..dd6d57c49bd 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -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)); |