The of_parse_phandle() looks for the phandle in the root device tree,
but as np is resolved for the target device tree, the phandle refers to
the target device tree and may return a wrong node in the root tree.

Therefore, we must ensure that we look for the manager-node in the
target device tree, which is the root node of np, and look for the
manager with that name.

firmwaremgr_find_by_node already uses the name for the lookup.

Signed-off-by: Michael Tretter <m.tret...@pengutronix.de>
---
Changelog:

v1 -> v2:

- Use of_parse_phandle_from instead of open coding the phandle lookup
---
 drivers/of/of_firmware.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/of/of_firmware.c b/drivers/of/of_firmware.c
index 80feb3b90dba..c1b69aac045c 100644
--- a/drivers/of/of_firmware.c
+++ b/drivers/of/of_firmware.c
@@ -11,7 +11,8 @@ static struct firmware_mgr *of_node_get_mgr(struct 
device_node *np)
        struct device_node *mgr_node;
 
        do {
-               mgr_node = of_parse_phandle(np, "fpga-mgr", 0);
+               mgr_node = of_parse_phandle_from(np, of_find_root_node(np),
+                                                "fpga-mgr", 0);
                if (mgr_node)
                        return firmwaremgr_find_by_node(mgr_node);
        } while ((np = of_get_parent(np)) != NULL);
-- 
2.39.2


Reply via email to