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

Robert P. J. Day rpjday at crashcourse.ca
Tue May 24 14:55:11 CEST 2016


  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?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================



More information about the U-Boot mailing list