Message ID | 1519403933-64408-2-git-send-email-philipp.tomsich@theobroma-systems.com |
---|---|
State | Accepted |
Commit | e2d5997ffdf5cbf4f7d53584dab2ffc673f50987 |
Delegated to: | Anatolij Gustschin |
Headers | show |
Series | rockchip: video: migrate RK3399 w/ HDMI to livetree | expand |
On Fri, 23 Feb 2018 17:38:49 +0100 Philipp Tomsich philipp.tomsich@theobroma-systems.com wrote: > 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>
On 23 February 2018 at 09:38, Philipp Tomsich <philipp.tomsich@theobroma-systems.com> wrote: > > 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> > --- > > drivers/core/ofnode.c | 14 ++++++++++++++ > include/dm/ofnode.h | 8 ++++++++ > 2 files changed, 22 insertions(+) > Reviewed-by: Simon Glass <sjg@chromium.org> Do you think we could have a simple ofnode test in test/dm to call this new function?
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 98f4b53..dd6d57c 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)); diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index c359a60..6938e62 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -302,6 +302,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 * * @node: valid node to look up