From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sergei Shtylyov Date: Thu, 08 Jul 2010 13:43:47 +0400 Subject: [U-Boot] [PATCH] Fix condition where bootm_size not set and wrong memory size reported In-Reply-To: <1278535459-6255-1-git-send-email-msm@freescale.com> References: <1278535459-6255-1-git-send-email-msm@freescale.com> Message-ID: <4C359DD3.1030901@mvista.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello. Matthew McClintock wrote: > If the user sets bootm_low and does not set bootm_size, u-boot will > report the memory node in the flat device tree incorrectly. Instead > of reporting the remaining size of memory, it will report the total > available memory which is incorrect. > Specifically this fixes the situation when booting a relocatable > kernel and the memory is reported as an offset and size in the > device tree, and the size needs to be adjusted accordingly. > Signed-off-by: Matthew McClintock > --- > common/image.c | 12 +++++++++--- > 1 files changed, 9 insertions(+), 3 deletions(-) > > diff --git a/common/image.c b/common/image.c > index 2b6007e..bf2acb0 100644 > --- a/common/image.c > +++ b/common/image.c > @@ -433,17 +433,23 @@ ulong getenv_bootm_low(void) > > phys_size_t getenv_bootm_size(void) > { > + phys_size_t tmp; > char *s = getenv ("bootm_size"); > if (s) { > - phys_size_t tmp; > tmp = (phys_size_t)simple_strtoull (s, NULL, 16); > return tmp; > } > + s = getenv("bootm_low"); > + if (s) > + tmp = (phys_size_t)simple_strtoull (s, NULL, 16); > + else > + tmp = 0; > + > > #if defined(CONFIG_ARM) > - return gd->bd->bi_dram[0].size; > + return (gd->bd->bi_dram[0].size - tmp); > #else > - return gd->bd->bi_memsize; > + return (gd->bd->bi_memsize - tmp); Parens not useful here and above. WBR, Sergei