[PATCH 07/36] dm: ofnode: fix parse_phandle_with_args API

Casey Connolly <[email protected]> Mon, 20 Jul 2026 17:40:34 +0100
Newsgroups io.groups.u-boot-amlogic
Message-ID <[email protected]>
When not using livetree, fdtdec_parse_phandle_with_args() is used both
to parse as well as to count the number of arguments. This means it
returns a positive integer in some cased (based on the index) which is
NOT valid for ofnode_parse_phandle_with_args().

Fix this by ignoring positive return value since it still indicates that
the phandle was parsed correctly.

Signed-off-by: Casey Connolly <[email protected]>
---
 drivers/core/ofnode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 1388b4810317..b82d48232ec3 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -1069,9 +1069,9 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name,
 		ret = fdtdec_parse_phandle_with_args(ofnode_to_fdt(node),
 						     ofnode_to_offset(node),
 						     list_name, cells_name,
 						     cell_count, index, &args);
-		if (ret)
+		if (ret < 0)
 			return ret;
 		ofnode_from_fdtdec_phandle_args(node, &args, out_args);
 	}
 
@@ -1102,9 +1102,9 @@ int oftree_parse_phandle_with_args(oftree tree, ofnode node, const char *list_na
 		ret = fdtdec_parse_phandle_with_args(tree.fdt,
 						     ofnode_to_offset(node),
 						     list_name, cells_name,
 						     cell_count, index, &args);
-		if (ret)
+		if (ret < 0)
 			return ret;
 		ofnode_from_fdtdec_phandle_args(node, &args, out_args);
 	}
 

-- 
2.55.0