[U-Boot-Users] [RFC] Remove some redundant fdt code from do_bootm_linux

Jerry Van Baren
2007-05-18T03:34:09Z

Andy Fleming wrote:
> There were a number of places where libfdt and the old ft code
> were doing essentially the same thing. By adding some stubs for
> some of the libfdt convenience functions, we can eliminate some
> of these redundancies.
>
> This patch has some overlap with a patch Jerry already submitted, so I'm
> not expecting this to apply. I'm just interested in opinions as to
> whether this is a good approach.
>
> In the process:
> * Eliminated a bug in the libfdt error handling for uImages where
> a correct header would trigger an error

Did my latest patch set fix this or am I still missing it?

> * Moved the debug message about transferring control to Linux
> next to the first potential invocation of Linux

Yup, that's all changed now, hopefully for the better... If I missed
something or if something could be improved, hollar.

> * Did a few minor formatting tweaks to improve readability
> * Removed what appeared to be redundant calls to fdt_chosen,
> fdt_env, and fdt_bd_t

Hmm, that sure looks redundant. What was I thinking??? Oh yeah, that's
right, I wasn't thinking when I hacked up bootm. :-(

> * Eliminated the #ifdef protecting the if statement which checked
> if we had an of_flat_tree. If CONFIG_OF_FLAT_TREE or
> CONFIG_OF_LIBFDT aren't defined, then of_flat_tree will be NULL
> (and any compiler will eliminate the check in that case)

Makes sense. Simplifying is GOOD. We may want to keep the #ifdef
around "of_data" to prevent a "unused variable" compiler warning (or
maybe it isn't a problem, I didn't really look at it).

> * Made clear in a few places that LIBFDT and OF_FLAT_TREE are
> mutually exclusive
> * Added definition for fdt_check_header (evaluates to 0 if the
> header is of type OF_DT_HEADER
> * Added definition for fdt_totalsize() (evaluates to the value of totalsize)
> * Added a stub for fdt_open_into() which just does the memmove and returns 0

WRT the above, my intent is to evangelize for LIBFDT, convert the other
targets that use fdt to LIBFDT, and remove OF_FLAT_TREE. That solves
the above bullets in a whole lot cleaner fashion. LIBFDT does
everything OF_FLAT_TREE does and much more. It's just a problem of time
(unlike Wolfgang, I need to sleep ;-).

The conversion is not difficult, following my lead on the MPC8360.
There are three functions that need to be updated. The three functions
that need to be converted are:
* ft_board_setup
* ft_cpu_setup
* ft_pci_setup

See the table in the ToDo section:
<http://www.denx.de/wiki/view/UBoot/UBootFdtInfo#ToDo>

> Signed-off-by: Andy Fleming <afleming@freescale.com>

Thanks for the thoughts & proposals,
gvb