From: Michael Weiss <michael.weiss@ifm.com>
Date: Thu, 20 May 2010 14:09:35 +0000 (+0200)
Subject: powerpc/bootcount: Fix endianness problem
X-Git-Tag: v2025.01-rc5-pxa1908~20232
X-Git-Url: http://git.dujemihanovic.xyz/html/static/gitweb.css?a=commitdiff_plain;h=59dde44acb82e571808190ccd3cd6b82dc9d7001;p=u-boot.git

powerpc/bootcount: Fix endianness problem

For CONFIG_SYS_BOOTCOUNT_SINGLEWORD the code had an endianness problem.

Signed-off-by: Michael Weiss <michael.weiss@ifm.com>
Signed-off-by: Detlev Zundel <dzu@denx.de>
---

diff --git a/arch/powerpc/lib/bootcount.c b/arch/powerpc/lib/bootcount.c
index 6346527677..338c8486d7 100644
--- a/arch/powerpc/lib/bootcount.c
+++ b/arch/powerpc/lib/bootcount.c
@@ -77,10 +77,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;