Commit e2d5997ffdf5cbf4f7d53584dab2ffc673f50987

Authored by Philipp Tomsich
Committed by Anatolij Gustschin
1 parent f0f6917188

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>

Showing 2 changed files with 22 additions and 0 deletions Side-by-side Diff

drivers/core/ofnode.c
... ... @@ -165,6 +165,20 @@
165 165 fdt_next_subnode(gd->fdt_blob, ofnode_to_offset(node)));
166 166 }
167 167  
  168 +ofnode ofnode_get_parent(ofnode node)
  169 +{
  170 + ofnode parent;
  171 +
  172 + assert(ofnode_valid(node));
  173 + if (ofnode_is_np(node))
  174 + parent = np_to_ofnode(of_get_parent(ofnode_to_np(node)));
  175 + else
  176 + parent.of_offset = fdt_parent_offset(gd->fdt_blob,
  177 + ofnode_to_offset(node));
  178 +
  179 + return parent;
  180 +}
  181 +
168 182 const char *ofnode_get_name(ofnode node)
169 183 {
170 184 assert(ofnode_valid(node));
... ... @@ -302,6 +302,14 @@
302 302 ofnode ofnode_next_subnode(ofnode node);
303 303  
304 304 /**
  305 + * ofnode_get_parent() - get the ofnode's parent (enclosing ofnode)
  306 + *
  307 + * @node: valid node to look up
  308 + * @return ofnode reference of the parent node
  309 + */
  310 +ofnode ofnode_get_parent(ofnode node);
  311 +
  312 +/**
305 313 * ofnode_get_name() - get the name of a node
306 314 *
307 315 * @node: valid node to look up