From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alessandro Rubini Date: Thu, 6 Aug 2009 12:12:41 +0200 Subject: [U-Boot] PATCH mtd CFI flash: timeout calculation underflow if imprecise 1kHz timer: fix In-Reply-To: <4A7AA72C.8010704@imagos.it> References: <4A7AA72C.8010704@imagos.it> Message-ID: <20090806101241.GA23106@mail.gnudd.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de > 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