]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: core: Pass a root node to of_find_node_by_phandle()
authorSimon Glass <sjg@chromium.org>
Wed, 7 Sep 2022 02:26:57 +0000 (20:26 -0600)
committerTom Rini <trini@konsulko.com>
Thu, 29 Sep 2022 20:07:58 +0000 (16:07 -0400)
This function currently assumes that the control FDT is used. Update it
to allow a root node to be passed, so it can work with any tree.

Also add a comment to ofnode_get_by_phandle() so that its purpose is
clear.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/core/of_access.c
drivers/core/ofnode.c
include/dm/of_access.h
include/dm/ofnode.h

index df007e642bfb0e87a7ad3739d58f0915ad06918e..f7743d406632aa6d9322a4783322c57228e14943 100644 (file)
@@ -445,14 +445,15 @@ struct device_node *of_find_node_by_prop_value(struct device_node *from,
        return np;
 }
 
-struct device_node *of_find_node_by_phandle(phandle handle)
+struct device_node *of_find_node_by_phandle(struct device_node *root,
+                                           phandle handle)
 {
        struct device_node *np;
 
        if (!handle)
                return NULL;
 
-       for_each_of_allnodes(np)
+       for_each_of_allnodes_from(root, np)
                if (np->phandle == handle)
                        break;
        (void)of_node_get(np);
@@ -697,7 +698,7 @@ static int __of_parse_phandle_with_args(const struct device_node *np,
                         * below.
                         */
                        if (cells_name || cur_index == index) {
-                               node = of_find_node_by_phandle(phandle);
+                               node = of_find_node_by_phandle(NULL, phandle);
                                if (!node) {
                                        debug("%s: could not find phandle\n",
                                              np->full_name);
index 42f3c09a5138bf9aa1359091c3a1877c4d9806e1..b241be3b9fc242c1a1323f77be71a6ddbdc4a304 100644 (file)
@@ -391,7 +391,7 @@ ofnode ofnode_get_by_phandle(uint phandle)
        ofnode node;
 
        if (of_live_active())
-               node = np_to_ofnode(of_find_node_by_phandle(phandle));
+               node = np_to_ofnode(of_find_node_by_phandle(NULL, phandle));
        else
                node.of_offset = fdt_node_offset_by_phandle(gd->fdt_blob,
                                                            phandle);
index 83f34f0d2ad9ad37b39ead3b68d9dea8001cb414..d8c6d11643333c011f08599ad102cb37a23a60b1 100644 (file)
@@ -258,11 +258,13 @@ struct device_node *of_find_node_by_prop_value(struct device_node *from,
 /**
  * of_find_node_by_phandle() - Find a node given a phandle
  *
+ * @root:      root node to start from (NULL for default device tree)
  * @handle:    phandle of the node to find
  *
  * Return: node pointer, or NULL if not found
  */
-struct device_node *of_find_node_by_phandle(phandle handle);
+struct device_node *of_find_node_by_phandle(struct device_node *root,
+                                           phandle handle);
 
 /**
  * of_read_u8() - Find and read a 8-bit integer from a property
index f6085231bbd87d32788586691d0ef3557f072042..6414b4648f9edeb4bfe46aee4f011539522d3e58 100644 (file)
@@ -501,6 +501,8 @@ int ofnode_get_path(ofnode node, char *buf, int buflen);
 /**
  * ofnode_get_by_phandle() - get ofnode from phandle
  *
+ * This uses the default (control) device tree
+ *
  * @phandle:   phandle to look up
  * Return: ofnode reference to the phandle
  */