diff mbox series

[2/3] fdtdec: correct test on return of fdt_node_offset_by_phandle

Message ID 20200925074116.16068-2-patrick.delaunay@st.com
State Accepted
Commit cba487c7fc0fea21757cd8dba10271469d5fde9c
Delegated to: Simon Glass
Headers show
Series [1/3] dm: add cells_count parameter in *_count_phandle_with_args | expand

Commit Message

Patrick DELAUNAY Sept. 25, 2020, 7:41 a.m. UTC
The result of fdt_node_offset_by_phandle is negative for error,
so this patch corrects the check of this result in
fdtdec_parse_phandle_with_args.

This patch allows to have the same behavior with or without OF_LIVE
for the function dev_read_phandle_with_args with cell_name = NULL and
with invalid phandle.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 lib/fdtdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Glass Oct. 5, 2020, 1:42 a.m. UTC | #1
On Fri, 25 Sep 2020 at 01:41, Patrick Delaunay <patrick.delaunay@st.com> wrote:
>
> The result of fdt_node_offset_by_phandle is negative for error,
> so this patch corrects the check of this result in
> fdtdec_parse_phandle_with_args.
>
> This patch allows to have the same behavior with or without OF_LIVE
> for the function dev_read_phandle_with_args with cell_name = NULL and
> with invalid phandle.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
>  lib/fdtdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Simon Glass Oct. 5, 2020, 9:32 p.m. UTC | #2
On Fri, 25 Sep 2020 at 01:41, Patrick Delaunay <patrick.delaunay@st.com> wrote:
>
> The result of fdt_node_offset_by_phandle is negative for error,
> so this patch corrects the check of this result in
> fdtdec_parse_phandle_with_args.
>
> This patch allows to have the same behavior with or without OF_LIVE
> for the function dev_read_phandle_with_args with cell_name = NULL and
> with invalid phandle.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
>  lib/fdtdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-dm/next, thanks!
diff mbox series

Patch

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index d3b22ec323..90d7e50646 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -746,7 +746,7 @@  int fdtdec_parse_phandle_with_args(const void *blob, int src_node,
 			if (cells_name || cur_index == index) {
 				node = fdt_node_offset_by_phandle(blob,
 								  phandle);
-				if (!node) {
+				if (node < 0) {
 					debug("%s: could not find phandle\n",
 					      fdt_get_name(blob, src_node,
 							   NULL));