Commit 0cb389dd1a3805db9639f70131e58f9bb602100e

Authored by Masahiro Yamada
Committed by Tom Rini
1 parent 89ab841088

image: fix getenv_bootm_size() function again

Commit 9c11135ce053 ("image: fix getenv_bootm_size() function") fixed
the case where "bootm_low" is defined, but "bootm_size" is not.
Instead, it broke the case where neither "bootm_low" nor "bootm_size"
is defined.  Fix this function again.

Fixes: 9c11135ce053 ("image: fix getenv_bootm_size() function")
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Tested-by: Matthias Weisser <m.weisser.m@gmail.com>
Tested-by: Hannes Schmelzer <oe5hpm@oevsv.at>

Showing 1 changed file with 13 additions and 8 deletions Side-by-side Diff

... ... @@ -458,24 +458,29 @@
458 458  
459 459 phys_size_t getenv_bootm_size(void)
460 460 {
461   - phys_size_t tmp;
  461 + phys_size_t tmp, size;
  462 + phys_addr_t start;
462 463 char *s = getenv("bootm_size");
463 464 if (s) {
464 465 tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
465 466 return tmp;
466 467 }
  468 +
  469 +#if defined(CONFIG_ARM) && defined(CONFIG_NR_DRAM_BANKS)
  470 + start = gd->bd->bi_dram[0].start;
  471 + size = gd->bd->bi_dram[0].size;
  472 +#else
  473 + start = gd->bd->bi_memstart;
  474 + size = gd->bd->bi_memsize;
  475 +#endif
  476 +
467 477 s = getenv("bootm_low");
468 478 if (s)
469 479 tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
470 480 else
471   - tmp = 0;
  481 + tmp = start;
472 482  
473   -
474   -#if defined(CONFIG_ARM) && defined(CONFIG_NR_DRAM_BANKS)
475   - return gd->bd->bi_dram[0].size - (tmp - gd->bd->bi_dram[0].start);
476   -#else
477   - return gd->bd->bi_memsize - (tmp - gd->bd->bi_memstart);
478   -#endif
  483 + return size - (tmp - start);
479 484 }
480 485  
481 486 phys_size_t getenv_bootm_mapsize(void)