mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-02 14:33:18 +02:00
Make sleep threshold for delays configurable
This allows the minimum time that default_delay() will choose to sleep for instead of polling to be configured at build-time. The default remains unchanged at 100 milliseconds for now. The test's correctness has been checked by testing with minimum sleep time left at its default and set to a non-default value smaller than 100 microseconds (both pass without sleeping, verified with strace) and with the minimum sleep time set to 0 (causing the test to be skipped). The configured value from the macro needs to be stored in a const to avoid -Werror=type-limits errors when configured to be zero. Change-Id: Ida96e0816ac914ed69d6fd82ad90ebe89cdef1cc Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/81606 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
@ -153,19 +153,20 @@ void internal_sleep(unsigned int usecs)
|
||||
usleep(usecs % 1000000);
|
||||
}
|
||||
|
||||
static const unsigned min_sleep = CONFIG_DELAY_MINIMUM_SLEEP_US;
|
||||
|
||||
/* Precise delay. */
|
||||
void default_delay(unsigned int usecs)
|
||||
{
|
||||
static bool calibrated = false;
|
||||
|
||||
/* If the delay is >0.1 s, use internal_sleep because timing does not need to be so precise. */
|
||||
if (usecs > 100000) {
|
||||
internal_sleep(usecs);
|
||||
} else {
|
||||
if (usecs < min_sleep) {
|
||||
if (!calibrated) {
|
||||
myusec_calibrate_delay();
|
||||
calibrated = true;
|
||||
}
|
||||
myusec_delay(usecs);
|
||||
} else {
|
||||
internal_sleep(usecs);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user