1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-01 08:42:12 +02:00

imagetool: replace image registration function by linker_lists feature

The registration was introduced in commit f86ed6a8d5

This commit also removes all registration functions, and the member "next"
from image_type_params struct

Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
This commit is contained in:
Guilherme Maciel Ferreira
2015-01-15 02:48:07 -02:00
committed by Tom Rini
parent 067d156075
commit a93648d197
18 changed files with 254 additions and 376 deletions

View File

@@ -20,41 +20,6 @@ static struct image_tool_params params = {
.type = IH_TYPE_KERNEL,
};
/**
* dumpimage_register() - register respective image generation/list support
*
* the input struct image_type_params is checked and appended to the link
* list, if the input structure is already registered, issue an error
*
* @tparams: Image type parameters
*/
static void dumpimage_register(struct image_type_params *tparams)
{
struct image_type_params **tp;
if (!tparams) {
fprintf(stderr, "%s: %s: Null input\n", params.cmdname,
__func__);
exit(EXIT_FAILURE);
}
/* scan the linked list, check for registry and point the last one */
for (tp = &dumpimage_tparams; *tp != NULL; tp = &(*tp)->next) {
if (!strcmp((*tp)->name, tparams->name)) {
fprintf(stderr, "%s: %s already registered\n",
params.cmdname, tparams->name);
return;
}
}
/* add input struct entry at the end of link list */
*tp = tparams;
/* mark input entry as last entry in the link list */
tparams->next = NULL;
debug("Registered %s\n", tparams->name);
}
/*
* dumpimage_extract_datafile -
*
@@ -70,8 +35,12 @@ static int dumpimage_extract_datafile(void *ptr, struct stat *sbuf)
{
int retval = -1;
struct image_type_params *curr;
struct image_type_params *start = ll_entry_start(
struct image_type_params, image_type);
struct image_type_params *end = ll_entry_end(
struct image_type_params, image_type);
for (curr = dumpimage_tparams; curr != NULL; curr = curr->next) {
for (curr = start; curr != end; curr++) {
if (curr->verify_header) {
retval = curr->verify_header((unsigned char *)ptr,
sbuf->st_size, &params);
@@ -104,9 +73,6 @@ int main(int argc, char **argv)
int retval = 0;
struct image_type_params *tparams = NULL;
/* Init all image generation/list support */
register_image_tool(dumpimage_register);
params.cmdname = *argv;
while ((opt = getopt(argc, argv, "li:o:p:V")) != -1) {
@@ -142,7 +108,7 @@ int main(int argc, char **argv)
usage();
/* set tparams as per input type_id */
tparams = imagetool_get_type(params.type, dumpimage_tparams);
tparams = imagetool_get_type(params.type);
if (tparams == NULL) {
fprintf(stderr, "%s: unsupported type %s\n",
params.cmdname, genimg_get_type_name(params.type));