<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hello Gedare,</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 5, 2021 at 11:53 PM Gedare Bloom <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 5, 2021 at 10:41 AM G S Niteesh Babu <<a href="mailto:niteesh.gs@gmail.com" target="_blank">niteesh.gs@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Refactored recursive rtems_ofw_get_effective_phandle into a<br>
iterative function.<br>
---<br>
 bsps/shared/ofw/ofw.c | 9 +++++----<br>
 1 file changed, 5 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/bsps/shared/ofw/ofw.c b/bsps/shared/ofw/ofw.c<br>
index 9dec310247..e3626747fa 100644<br>
--- a/bsps/shared/ofw/ofw.c<br>
+++ b/bsps/shared/ofw/ofw.c<br>
@@ -509,11 +509,12 @@ static phandle_t rtems_ofw_get_effective_phandle(<br>
 {<br>
   phandle_t child;<br>
   phandle_t ref;<br>
+  int node_offset;<br>
<br>
-  for (child = rtems_ofw_child(node); child != 0; child = rtems_ofw_peer(child)) {<br>
-    ref = rtems_ofw_get_effective_phandle(child, xref);<br>
-    if (ref != -1)<br>
-      return ref;<br>
+  node_offset = fdt_path_offset(fdtp, "/");<br>
+<br>
+  while ((node_offset = fdt_next_node(fdtp, node_offset, NULL)) > 0) {<br>
+    child = rtems_fdt_offset_to_phandle(node_offset);<br>
<br></blockquote><div>Assuming this works, it is much better now :) Thanks.</div></div></div></blockquote><div><span class="gmail_default" style="font-size:small">Yes, it does. I checked it by creating a small test outside of RTEMS using real DTB</span></div><div><span class="gmail_default" style="font-size:small">files (Rpi.dtb and Beagle.dtb). I basically mmap the dtb file and initialize fdtp with the</span></div><div><span class="gmail_default" style="font-size:small">mapped address, and use this with libFDT and ofw.c to test and debug. This creates</span></div><div><span class="gmail_default" style="font-size:small">a much easier env to work with. Finally, when satisfied with the results I test them</span></div><div><div class="gmail_default" style="font-size:small">on real hardware.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Thanks,</div><div class="gmail_default" style="font-size:small">Niteesh.</div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
     if (rtems_ofw_get_enc_prop(child, "phandle", &ref, sizeof(ref)) == -1 &&<br>
         rtems_ofw_get_enc_prop(child, "ibm,phandle", &ref, sizeof(ref)) == -1 &&<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div></div>
</blockquote></div></div>