[U-Boot] PATCH mtd CFI flash: timeout calculation underflow if imprecise 1kHz timer: fix
Alessandro Rubini
rubini-list at gnudd.com
Thu Aug 6 12:12:41 CEST 2009
> With old configuration it could happen tout=0 if CONFIG_SYS_HZ<1000
> solved using an unsigned long long
I had the same problem with an ancient version of a vendor-ported u-boot. There
my CFG_HZ was 100, so the timeout was 0.
I used this, which avoids the preprocessor conditional. Since the HZ value
is a compile-time constant, the compiler chooses the if or else branch and doesn't
spit a run-time conditional.2
if (CFG_HZ > 100000)
tout *= CFG_HZ/1000; /* for a big HZ, avoid overflow */
else
tout = tout * CFG_HZ / 1000 + 1;
/alessandro
More information about the U-Boot
mailing list