diff options
author | Raul E Rangel <rrangel@chromium.org> | 2022-04-28 16:17:01 -0600 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-05-02 14:04:33 +0000 |
commit | b10cbd0d085e6ab3127e5cae27494a9c69a89268 (patch) | |
tree | 6c837fccadc58f75584b3b883c21543820ec7e14 /src/drivers | |
parent | 471f2eefddaa715b9765b7572133c4dde3a25b0c (diff) |
drivers/spi: Convert spi_flash_cmd_poll_bit to use stopwatch API
The previous code required a bit too much effort to read. It also didn't
print out the actual duration.
BUG=b:228289365
TEST=Boot guybrush
Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Change-Id: Ia620e789c5186f2e1d3cf3c548bda00a294d23bf
Reviewed-on: https://review.coreboot.org/c/coreboot/+/63939
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Rob Barnes <robbarnes@google.com>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
Diffstat (limited to 'src/drivers')
-rw-r--r-- | src/drivers/spi/spi_flash.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index ded88eda09..0142fad442 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -193,22 +193,19 @@ int spi_flash_cmd_poll_bit(const struct spi_flash *flash, unsigned long timeout, const struct spi_slave *spi = &flash->spi; int ret; u8 status; - struct mono_time current, end; - - timer_monotonic_get(¤t); - end = current; - mono_time_add_msecs(&end, timeout); + struct stopwatch sw; + stopwatch_init_msecs_expire(&sw, timeout); do { ret = do_spi_flash_cmd(spi, &cmd, 1, &status, 1); if (ret) return -1; if ((status & poll_bit) == 0) return 0; - timer_monotonic_get(¤t); - } while (!mono_time_after(¤t, &end)); + } while (!stopwatch_expired(&sw)); + + printk(BIOS_WARNING, "SF: timeout at %ld msec\n", stopwatch_duration_msecs(&sw)); - printk(BIOS_DEBUG, "SF: timeout at %ld msec\n",timeout); return -1; } |