summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Harkin <ryan.harkin@linaro.org>2015-10-09 17:18:05 +0100
committerTom Rini <trini@konsulko.com>2015-10-11 17:12:04 -0400
commit6607d397c2a5ecd2fe7c940331da29692bab671e (patch)
tree62d40f33bab045645c29f1d0b81c8e82b22260a0
parent1a9717fb30c5cbb70dcc5d53791670967dfe3487 (diff)
downloadtalos-obmc-uboot-6607d397c2a5ecd2fe7c940331da29692bab671e.tar.gz
talos-obmc-uboot-6607d397c2a5ecd2fe7c940331da29692bab671e.zip
common/armflash: load_image returns success or failure
Change the load_image so that it returns success or failure of the command (using CMD_RET_SUCCESS or CMD_RET_FAILURE). This way, hush scripts can optionally load different files depending upon the system configuration. A simple example: if afs load ${kernel_name} ${kernel_addr}; then echo loaded; else echo \ not loaded; fi Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--common/cmd_armflash.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/common/cmd_armflash.c b/common/cmd_armflash.c
index a37f5c463a..af453f7b3b 100644
--- a/common/cmd_armflash.c
+++ b/common/cmd_armflash.c
@@ -175,7 +175,7 @@ static void parse_flash(void)
parse_bank(bank);
}
-static void load_image(const char * const name, const ulong address)
+static int load_image(const char * const name, const ulong address)
{
struct afs_image *afi = NULL;
int i;
@@ -191,7 +191,7 @@ static void load_image(const char * const name, const ulong address)
}
if (!afi) {
printf("image \"%s\" not found in flash\n", name);
- return;
+ return CMD_RET_FAILURE;
}
for (i = 0; i < afi->region_count; i++) {
@@ -204,7 +204,7 @@ static void load_image(const char * const name, const ulong address)
to = afi->regions[i].load_address;
} else {
printf("no valid load address\n");
- return;
+ return CMD_RET_FAILURE;
}
memcpy((void *)to, (void *)from, afi->regions[i].size);
@@ -215,6 +215,7 @@ static void load_image(const char * const name, const ulong address)
to,
afi->regions[i].size);
}
+ return CMD_RET_SUCCESS;
}
static void print_images(void)
@@ -274,12 +275,12 @@ static int do_afs(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
} else if (argc == 3 && !strcmp(argv[1], "exists")) {
ret = exists(argv[2]);
} else if (argc == 3 && !strcmp(argv[1], "load")) {
- load_image(argv[2], 0x0);
+ ret = load_image(argv[2], 0x0);
} else if (argc == 4 && !strcmp(argv[1], "load")) {
ulong load_addr;
load_addr = simple_strtoul(argv[3], NULL, 16);
- load_image(argv[2], load_addr);
+ ret = load_image(argv[2], load_addr);
} else {
return CMD_RET_USAGE;
}
OpenPOWER on IntegriCloud