[PATCH 3/4] bsps/shared/ofw: Make rtems_ofw_get_effective_phandle iterative

Niteesh G. S. niteesh.gs at gmail.com
Sat Feb 6 04:46:31 UTC 2021


Hello Gedare,

On Fri, Feb 5, 2021 at 11:53 PM Gedare Bloom <gedare at rtems.org> wrote:

>
>
> On Fri, Feb 5, 2021 at 10:41 AM G S Niteesh Babu <niteesh.gs at gmail.com>
> wrote:
>
>> Refactored recursive rtems_ofw_get_effective_phandle into a
>> iterative function.
>> ---
>>  bsps/shared/ofw/ofw.c | 9 +++++----
>>  1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/bsps/shared/ofw/ofw.c b/bsps/shared/ofw/ofw.c
>> index 9dec310247..e3626747fa 100644
>> --- a/bsps/shared/ofw/ofw.c
>> +++ b/bsps/shared/ofw/ofw.c
>> @@ -509,11 +509,12 @@ static phandle_t rtems_ofw_get_effective_phandle(
>>  {
>>    phandle_t child;
>>    phandle_t ref;
>> +  int node_offset;
>>
>> -  for (child = rtems_ofw_child(node); child != 0; child =
>> rtems_ofw_peer(child)) {
>> -    ref = rtems_ofw_get_effective_phandle(child, xref);
>> -    if (ref != -1)
>> -      return ref;
>> +  node_offset = fdt_path_offset(fdtp, "/");
>> +
>> +  while ((node_offset = fdt_next_node(fdtp, node_offset, NULL)) > 0) {
>> +    child = rtems_fdt_offset_to_phandle(node_offset);
>>
>> Assuming this works, it is much better now :) Thanks.
>
Yes, it does. I checked it by creating a small test outside of RTEMS using
real DTB
files (Rpi.dtb and Beagle.dtb). I basically mmap the dtb file and
initialize fdtp with the
mapped address, and use this with libFDT and ofw.c to test and debug. This
creates
a much easier env to work with. Finally, when satisfied with the results I
test them
on real hardware.

Thanks,
Niteesh.


>
>>      if (rtems_ofw_get_enc_prop(child, "phandle", &ref, sizeof(ref)) ==
>> -1 &&
>>          rtems_ofw_get_enc_prop(child, "ibm,phandle", &ref, sizeof(ref))
>> == -1 &&
>> --
>> 2.17.1
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20210206/e9b1e2bf/attachment.html>


More information about the devel mailing list