aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRenato Andreola <renato.andreola@imagos.it>2010-03-24 23:00:47 +0800
committerStefan Roese <sr@denx.de>2010-03-25 09:44:58 +0100
commitc40c94a3d20a8616264c2dfcda85279185d69aeb (patch)
treeb2d1d3a8fe732f0fda392bafcb56653e2e3c9287 /drivers
parent7027d5622d56ee2292713773044fb6352e431f31 (diff)
downloadu-boot-c40c94a3d20a8616264c2dfcda85279185d69aeb.zip
u-boot-c40c94a3d20a8616264c2dfcda85279185d69aeb.tar.gz
u-boot-c40c94a3d20a8616264c2dfcda85279185d69aeb.tar.bz2
cfi_flash: precision and underflow problem in tout calculation
With old configuration it could happen tout=0 if CONFIG_SYS_HZ<1000. Signed-off-by: Renato Andreola <renato.andreola@imagos.it> Signed-off-by: Alessandro Rubini <rubini@gnudd.com> Signed-off-by: Thomas Chou <thomas@wytron.com.tw> Signed-off-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/cfi_flash.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index fdba297..cd1a86e 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -537,7 +537,10 @@ 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;
+ if ((ulong)CONFIG_SYS_HZ > 100000)
+ tout *= (ulong)CONFIG_SYS_HZ / 1000; /* for a big HZ, avoid overflow */
+ else
+ tout = DIV_ROUND_UP(tout * (ulong)CONFIG_SYS_HZ, 1000);
#endif
/* Wait for command completion */