SPL: FIT: refactor FDT loading
authorAndre Przywara <andre.przywara@arm.com>
Wed, 26 Apr 2017 00:32:33 +0000 (01:32 +0100)
committerJason Liu <jason.hui.liu@nxp.com>
Thu, 2 Nov 2017 18:37:22 +0000 (02:37 +0800)
commitb245bb70d4d13c3fcb1fffb36e2d55d3ab54cefe
treeb879370b7b2a4ef048bf59217d6b92121fd1f900
parent5ad9ab25cbd66a212c05f73e4a4c4482dd460a83
SPL: FIT: refactor FDT loading

Currently the SPL FIT loader uses the spl_fit_select_fdt() function to
find the offset to the right DTB within the FIT image.
For this it iterates over all subnodes of the /configuration node in
the FIT tree and compares all "description" strings therein using a
board specific matching function.
If that finds a match, it uses the string in the "fdt" property of that
subnode to locate the matching subnode in the /images node, which points
to the DTB data.
Now this works very well, but is quite specific to cover this particular
use case. To open up the door for a more generic usage, let's split this
function into:
1) a function that just returns the node offset for the matching
   configuration node (spl_fit_find_config_node())
2) a function that returns the image data any given property in a given
   configuration node points to, additionally using a given index into
   a possbile list of strings (spl_fit_select_index())
This allows us to replace the specific function above by asking for the
image the _first string of the "fdt" property_ in the matching
configuration subnode points to.

This patch introduces no functional changes, it just refactors the code
to allow reusing it later.

(diff is overly clever here and produces a hard-to-read patch, so I
recommend to throw a look at the result instead).

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Lokesh Vutla <lokeshvuta@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Tested-by: Kever Yang <kever.yang@rock-chips.com>
Tested-by: Jagan Teki <jagan@openedev.com>
(cherry picked from commit 4b9340abdc23f25b75282cdc8b84a06c8b10cd27)
common/spl/spl_fit.c