[U-Boot] why does fdt_fixup_ethernet() need to worry about an edited FDT?

Bin Meng bmeng.cn at gmail.com
Wed May 25 04:23:49 CEST 2016


On Tue, May 24, 2016 at 8:55 PM, Robert P. J. Day <rpjday at crashcourse.ca> wrote:
>
>   looking at the code for fdt_fixup_ethernet() in fdt_support.c, and
> i'm puzzled by the extra work being done ostensibly to take an
> "edited" FDT into account:
>
>   void fdt_fixup_ethernet(void *fdt)
>   {
>         int i, j, prop;
>         char *tmp, *end;
>         char mac[16];
>         const char *path;
>         unsigned char mac_addr[6];
>         int offset;
>
>         if (fdt_path_offset(fdt, "/aliases") < 0)
>                 return;
>
>         /* Cycle through all aliases */
>         for (prop = 0; ; prop++) {
>                 const char *name;
>                 int len = strlen("ethernet");
>
>                 /* FDT might have been edited, recompute the offset */
>                 offset = fdt_first_property_offset(fdt,
>                         fdt_path_offset(fdt, "/aliases"));
>                 /* Select property number 'prop' */
>                 for (i = 0; i < prop; i++)
>                         offset = fdt_next_property_offset(fdt, offset);
>                 ... snip ...
>
>   why is it that *this* routine has to worry about an edited FDT, but
> nothing else i see in that entire source file has to? as a (hopefully)
> relevant example:
>
>   #if defined(OF_STDOUT_PATH)
>   static int fdt_fixup_stdout(void *fdt, int chosenoff)
>   {
>         return fdt_setprop(fdt, chosenoff, "linux,stdout-path",
>                               OF_STDOUT_PATH, strlen(OF_STDOUT_PATH) + 1);
>   }
>
> that routine simply calls fdt_setprop() ... what is it about
> fdt_fixup_ethernet() that needs to take extra care compared to every
> other function in that file?
>

Commit a434fd1d282fd32d81296c6d4c2e0911f6e488b3 explains this.

Regards,
Bin


More information about the U-Boot mailing list