chromeec: use stopwatch API
Simplify the SPI timeout by using the stopwatch. BUG=None BRANCH=None TEST=Built nyan. Confirmed stopwatch works independently. Change-Id: Ida26a0748d4b5a6a28aa8f6e2b92fe2ee4cbe17f Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: 900d7ac826b76d49290033c87849bf776684f2c1 Original-Change-Id: I84b7949060326b7c6cc1872420b93bd44604c4d3 Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/219493 Original-Reviewed-by: Julius Werner <jwerner@chromium.org> Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org> Original-Reviewed-by: David Hendricks <dhendrix@chromium.org> Reviewed-on: http://review.coreboot.org/8816 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
f65153ef07
commit
4869111443
|
@ -57,9 +57,9 @@ static int crosec_spi_io(size_t req_size, size_t resp_size, void *context)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
struct mono_time start;
|
struct stopwatch sw;
|
||||||
struct rela_time rt;
|
// Wait 1s for a framing byte.
|
||||||
timer_monotonic_get(&start);
|
stopwatch_init_usecs_expire(&sw, USECS_PER_SEC);
|
||||||
while (1) {
|
while (1) {
|
||||||
if (spi_xfer(slave, NULL, 0, &byte, sizeof(byte))) {
|
if (spi_xfer(slave, NULL, 0, &byte, sizeof(byte))) {
|
||||||
printk(BIOS_ERR, "%s: Failed to receive byte.\n",
|
printk(BIOS_ERR, "%s: Failed to receive byte.\n",
|
||||||
|
@ -70,9 +70,7 @@ static int crosec_spi_io(size_t req_size, size_t resp_size, void *context)
|
||||||
if (byte == EcFramingByte)
|
if (byte == EcFramingByte)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Wait 1s for a framing byte.
|
if (stopwatch_expired(&sw)) {
|
||||||
rt = current_time_from(&start);
|
|
||||||
if (rela_time_in_microseconds(&rt) > 1000 * 1000) {
|
|
||||||
printk(BIOS_ERR,
|
printk(BIOS_ERR,
|
||||||
"%s: Timeout waiting for framing byte.\n",
|
"%s: Timeout waiting for framing byte.\n",
|
||||||
__func__);
|
__func__);
|
||||||
|
|
Loading…
Reference in New Issue