[U-Boot] [PATCH 2/2] powerpc/bootcount: Fix endianness problem

Detlev Zundel dzu at denx.de
Thu May 20 16:09:35 CEST 2010


From: Michael Weiss <michael.weiss at ifm.com>

For CONFIG_SYS_BOOTCOUNT_SINGLEWORD the code had an endianness problem.

Signed-off-by: Michael Weiss <michael.weiss at ifm.com>
Signed-off-by: Detlev Zundel <dzu at denx.de>
---
 arch/powerpc/lib/bootcount.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/lib/bootcount.c b/arch/powerpc/lib/bootcount.c
index 0373a20..07ef28d 100644
--- a/arch/powerpc/lib/bootcount.c
+++ b/arch/powerpc/lib/bootcount.c
@@ -82,10 +82,12 @@ ulong bootcount_load(void)
 	void *reg = (void *)CONFIG_SYS_BOOTCOUNT_ADDR;
 
 #if defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD)
-	if (in_be16(reg + 2) != (BOOTCOUNT_MAGIC & 0xffff))
+	u32 tmp = in_be32(reg);
+
+	if ((tmp & 0xffff0000) != (BOOTCOUNT_MAGIC & 0xffff0000))
 		return 0;
 	else
-		return in_be16(reg);
+		return (tmp & 0x0000ffff);
 #else
 	if (in_be32(reg + 4) != BOOTCOUNT_MAGIC)
 		return 0;
-- 
1.6.2.5



More information about the U-Boot mailing list