Nick: stefanct E-mail: none Board: timer patch Contents: diff --git a/udelay.c b/udelay.c index 7c6961d..5bba40f 100644 --- a/udelay.c +++ b/udelay.c @@ -113,9 +113,13 @@ recalibrate: } tries ++; - /* Avoid division by zero, but in that case the loop is shot anyway. */ - if (!timeusec) - timeusec = 1; + /* Something is completely wrong. Avoid a possible endless loop and fall back to internal_delay(). */ + if (timeusec == 0) { + micro = 0; + msg_perr("Timing measurement seems to be broken.\n" + "Falling back to possibly insufficient timing sources!\n"); + return; + } /* Compute rounded up number of loops per microsecond. */ micro = (count * micro) / timeusec + 1; @@ -187,7 +191,7 @@ void internal_sleep(unsigned int usecs) void internal_delay(unsigned int usecs) { /* If the delay is >1 s, use internal_sleep because timing does not need to be so precise. */ - if (usecs > 1000000) { + if (micro == 0 || usecs > 1000000) { internal_sleep(usecs); } else { myusec_delay(usecs);