spl: fit: add spl_fit_load_blob()

Move code to a function in order to be shared with other code.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I0d54ea7bb28a54a54eb313cda11c33f4d4564a84
This commit is contained in:
Joseph Chen 2020-06-23 18:34:51 +08:00 committed by Jianhong Chen
parent 8b16d676d3
commit 569a1737e3
1 changed files with 30 additions and 13 deletions

View File

@ -347,27 +347,24 @@ __weak int spl_fit_standalone_release(uintptr_t entry_point)
return 0; return 0;
} }
static int spl_internal_load_simple_fit(struct spl_image_info *spl_image, static void *spl_fit_load_blob(struct spl_load_info *info,
struct spl_load_info *info, ulong sector, void *fit_header,
ulong sector, void *fit) int *base_offset)
{ {
int sectors; int align_len = ARCH_DMA_MINALIGN - 1;
ulong count;
ulong size; ulong size;
unsigned long count; int sectors;
struct spl_image_info image_info; void *fit;
int node = -1;
int images, ret;
int base_offset, align_len = ARCH_DMA_MINALIGN - 1;
int index = 0;
/* /*
* For FIT with external data, figure out where the external images * For FIT with external data, figure out where the external images
* start. This is the base for the data-offset properties in each * start. This is the base for the data-offset properties in each
* image. * image.
*/ */
size = fdt_totalsize(fit); size = fdt_totalsize(fit_header);
size = FIT_ALIGN(size); size = FIT_ALIGN(size);
base_offset = FIT_ALIGN(size); *base_offset = FIT_ALIGN(size);
/* /*
* So far we only have one block of data from the FIT. Read the entire * So far we only have one block of data from the FIT. Read the entire
@ -393,7 +390,27 @@ static int spl_internal_load_simple_fit(struct spl_image_info *spl_image,
debug("fit read sector %lx, sectors=%d, dst=%p, count=%lu\n", debug("fit read sector %lx, sectors=%d, dst=%p, count=%lu\n",
sector, sectors, fit, count); sector, sectors, fit, count);
if (count == 0) if (count == 0)
return -EIO; return NULL;
return fit;
}
static int spl_internal_load_simple_fit(struct spl_image_info *spl_image,
struct spl_load_info *info,
ulong sector, void *fit_header)
{
struct spl_image_info image_info;
int base_offset;
int images, ret;
int index = 0;
int node = -1;
void *fit;
fit = spl_fit_load_blob(info, sector, fit_header, &base_offset);
if (!fit) {
debug("%s: Cannot load blob\n", __func__);
return -1;
}
/* find the node holding the images information */ /* find the node holding the images information */
images = fdt_path_offset(fit, FIT_IMAGES_PATH); images = fdt_path_offset(fit, FIT_IMAGES_PATH);