Commit 6607d397c2a5ecd2fe7c940331da29692bab671e
Committed by
Tom Rini
1 parent
1a9717fb30
Exists in
v2017.01-smarct4x
and in
30 other branches
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>
Showing 1 changed file with 6 additions and 5 deletions Side-by-side Diff
common/cmd_armflash.c
... | ... | @@ -175,7 +175,7 @@ |
175 | 175 | parse_bank(bank); |
176 | 176 | } |
177 | 177 | |
178 | -static void load_image(const char * const name, const ulong address) | |
178 | +static int load_image(const char * const name, const ulong address) | |
179 | 179 | { |
180 | 180 | struct afs_image *afi = NULL; |
181 | 181 | int i; |
... | ... | @@ -191,7 +191,7 @@ |
191 | 191 | } |
192 | 192 | if (!afi) { |
193 | 193 | printf("image \"%s\" not found in flash\n", name); |
194 | - return; | |
194 | + return CMD_RET_FAILURE; | |
195 | 195 | } |
196 | 196 | |
197 | 197 | for (i = 0; i < afi->region_count; i++) { |
... | ... | @@ -204,7 +204,7 @@ |
204 | 204 | to = afi->regions[i].load_address; |
205 | 205 | } else { |
206 | 206 | printf("no valid load address\n"); |
207 | - return; | |
207 | + return CMD_RET_FAILURE; | |
208 | 208 | } |
209 | 209 | |
210 | 210 | memcpy((void *)to, (void *)from, afi->regions[i].size); |
... | ... | @@ -215,6 +215,7 @@ |
215 | 215 | to, |
216 | 216 | afi->regions[i].size); |
217 | 217 | } |
218 | + return CMD_RET_SUCCESS; | |
218 | 219 | } |
219 | 220 | |
220 | 221 | static void print_images(void) |
221 | 222 | |
... | ... | @@ -274,12 +275,12 @@ |
274 | 275 | } else if (argc == 3 && !strcmp(argv[1], "exists")) { |
275 | 276 | ret = exists(argv[2]); |
276 | 277 | } else if (argc == 3 && !strcmp(argv[1], "load")) { |
277 | - load_image(argv[2], 0x0); | |
278 | + ret = load_image(argv[2], 0x0); | |
278 | 279 | } else if (argc == 4 && !strcmp(argv[1], "load")) { |
279 | 280 | ulong load_addr; |
280 | 281 | |
281 | 282 | load_addr = simple_strtoul(argv[3], NULL, 16); |
282 | - load_image(argv[2], load_addr); | |
283 | + ret = load_image(argv[2], load_addr); | |
283 | 284 | } else { |
284 | 285 | return CMD_RET_USAGE; |
285 | 286 | } |