PATCH mtd CFI flash: timeout calculation underflow if imprecise 1kHz timer: fix
From 6cc63851e5e4c16012d9afad70cedb41b7340de7 Mon Sep 17 00:00:00 2001
From: Renato Andreola <[email protected]>
Date: Fri, 10 Apr 2009 12:52:55 +0200
Subject: drivers/mtd/cfi_flash: precision and underflow problem in tout calculation
With old configuration it could happen tout=0 if CONFIG_SYS_HZ<1000 solved using an unsigned long long
--- drivers/mtd/cfi_flash.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/mtd/cfi_flash.c +0 -0
@@ -660,7 +660,9 @@ static int flash_status_check (flash_info_t * info,
flash_sect_t sector,
ulong start;
#if CONFIG_SYS_HZ != 1000
- tout *= CONFIG_SYS_HZ/1000;
+ unsigned long long ull;
+ ull = tout*CONFIG_SYS_HZ + CONFIG_SYS_HZ/2;
+ tout = ull/1000; /* Compute: tout *= CONFIG_SYS_HZ/1000; */
#endif
/* Wait for command completion */
Signature · 1 line
1.5.5
Quoted 17 lines · Renato Andreola
From
6cc63851e5e4c16012d9afad70cedb41b7340de7Mon Sep 17 00:00:00 2001
From: Renato Andreola <[email protected]>
Date: Fri, 10 Apr 2009 12:52:55 +0200
Subject:drivers/mtd/cfi_flash: precision and underflow problem in tout calculationWith old configuration it could happen tout=0 if CONFIG_SYS_HZ<1000 solved using an unsigned long long
--- drivers/mtd/cfi_flash.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)drivers/mtd/cfi_flash.c +0
-0
drivers/mtd/cfi_flash.c static int flash_status_check (flash_info_t * info, · line 667
Quoted 9 lines
drivers/mtd/cfi_flash.c +3
-1@@ -660,7 +660,9 @@ static int flash_status_check (flash_info_t * info,flash_sect_t sector, ulong start;#if CONFIG_SYS_HZ !=1000 - tout *=CONFIG_SYS_HZ /1000 ; +unsigned long long ull; + ull = tout*CONFIG_SYS_HZ +CONFIG_SYS_HZ /2 ; + tout = ull/1000 ;/* Compute: tout *= CONFIG_SYS_HZ/1000; */ #endif
drop all of this and fix your CONFIG_SYS_HZ to 1000 (non configurable value) will be better
Best Regards,
J.