[U-Boot] [PATCH] ARM: global_data: make tbl long long

Dirk Behme dirk.behme at de.bosch.com
Mon Mar 4 10:00:37 CET 2013


From: Dirk Behme <dirk.behme at de.bosch.com>

Several ARM timer implementations use gd->arch.tbl to record the
absolute tick count of 32-bit counters, including timer overflows.
For example arch/arm/imx-common/timer.c does:

ulong lastinc;
ulong now = counter value;
if (no overflow) {
	...
} else { /* counter overflow */
	gd->arch.tbl += (0xFFFFFFFF - lastinc) + now;
}
lastinc =  now;

As we use a 32-bit counter and the two ulong (32-bit) variables 'lastinc'
and 'now' here, gd->arch.tbl should be long long (64-bit) to not overflow
at the same time, too.

Signed-off-by: Knut Wohlrab <knut.wohlrab at de.bosch.com>
Signed-off-by: Dirk Behme <dirk.behme at de.bosch.com>
---
 arch/arm/include/asm/global_data.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
index 37ac0da..1099af9 100644
--- a/arch/arm/include/asm/global_data.h
+++ b/arch/arm/include/asm/global_data.h
@@ -41,7 +41,7 @@ struct arch_global_data {
 	/* "static data" needed by most of timer.c on ARM platforms */
 	unsigned long timer_rate_hz;
 	unsigned long tbu;
-	unsigned long tbl;
+	unsigned long long tbl;
 	unsigned long lastinc;
 	unsigned long long timer_reset_value;
 #ifdef CONFIG_IXP425
-- 
1.7.10.4



More information about the U-Boot mailing list