mirror of
https://github.com/u-boot/u-boot.git
synced 2024-11-26 05:34:30 +08:00
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>
This commit is contained in:
parent
7027d5622d
commit
c40c94a3d2
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user