Skip to content
Snippets Groups Projects
Commit c40c94a3 authored by Renato Andreola's avatar Renato Andreola Committed by Stefan Roese
Browse files

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: default avatarRenato Andreola <renato.andreola@imagos.it>
Signed-off-by: default avatarAlessandro Rubini <rubini@gnudd.com>
Signed-off-by: default avatarThomas Chou <thomas@wytron.com.tw>
Signed-off-by: default avatarStefan Roese <sr@denx.de>
parent 7027d562
No related branches found
No related tags found
No related merge requests found
...@@ -537,7 +537,10 @@ static int flash_status_check (flash_info_t * info, flash_sect_t sector, ...@@ -537,7 +537,10 @@ static int flash_status_check (flash_info_t * info, flash_sect_t sector,
ulong start; ulong start;
#if CONFIG_SYS_HZ != 1000 #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 #endif
/* Wait for command completion */ /* Wait for command completion */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment