Patchwork [U-Boot] powerpc/mpc85xx: explicit cast the SDRAM size to type phys_size_t

login
register
mail settings
Submitter Mingkai Hu
Date April 12, 2013, 7:56 a.m.
Message ID <1365753388-14203-1-git-send-email-Mingkai.Hu@freescale.com>
Download mbox | patch
Permalink /patch/235992/
State Accepted
Delegated to: Andy Fleming
Headers show

Comments

Mingkai Hu - April 12, 2013, 7:56 a.m.
To avoid sign extension problem, use explicit casting to cast
the SDRAM size to type phys_size_t, or else, if the SDRAM size
is 2G(0x80000000), it will be extended to 0xffffffff80000000
when phys_size_t is type 'unsigned long long'.

Signed-off-by: Mingkai Hu <Mingkai.Hu@freescale.com>
---

Based on master branch of git://git.denx.de/u-boot.git
Also can apply direcly to git://www.denx.de/git/u-boot-mpc85xx.git

 arch/powerpc/cpu/mpc85xx/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Andy Fleming - June 21, 2013, 8:40 p.m.
On Fri, Apr 12, 2013 at 03:56:28PM +0800, Mingkai Hu wrote:
> To avoid sign extension problem, use explicit casting to cast
> the SDRAM size to type phys_size_t, or else, if the SDRAM size
> is 2G(0x80000000), it will be extended to 0xffffffff80000000
> when phys_size_t is type 'unsigned long long'.
> 
> Signed-off-by: Mingkai Hu <Mingkai.Hu@freescale.com>

Applied, thanks!

Andy

Patch

diff --git a/arch/powerpc/cpu/mpc85xx/cpu.c b/arch/powerpc/cpu/mpc85xx/cpu.c
index df2ab6d..ee6fac3 100644
--- a/arch/powerpc/cpu/mpc85xx/cpu.c
+++ b/arch/powerpc/cpu/mpc85xx/cpu.c
@@ -339,7 +339,7 @@  phys_size_t initdram(int board_type)
 #if defined(CONFIG_SPD_EEPROM) || defined(CONFIG_DDR_SPD)
 	return fsl_ddr_sdram_size();
 #else
-	return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
+	return (phys_size_t)CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
 #endif
 }
 #else /* CONFIG_SYS_RAMBOOT */