From 205f6f6746c8a1788b93c7ce27ce62d0d6af02a5 Mon Sep 17 00:00:00 2001 From: Dominic Chen Date: Mon, 21 Jul 2014 12:15:48 -0700 Subject: spi_flash: add error checking for dma timeouts BUG=none BRANCH=none TEST=verify timeouts are caught by spi_transaction_*() Change-Id: I2e28ccbce58e555262bc4448a1c2e1a50253613e Signed-off-by: Dominic Chen Reviewed-on: https://chromium-review.googlesource.com/209116 Reviewed-by: Vic Yang --- chip/stm32/spi_master.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'chip') diff --git a/chip/stm32/spi_master.c b/chip/stm32/spi_master.c index 0103362461..aa37f191d5 100644 --- a/chip/stm32/spi_master.c +++ b/chip/stm32/spi_master.c @@ -124,9 +124,12 @@ static int spi_dma_wait(void) { timestamp_t timeout; stm32_spi_regs_t *spi = SPI_REG; + int rv = EC_SUCCESS; /* Wait for DMA transmission to complete */ - dma_wait(dma_tx_option.channel); + rv = dma_wait(dma_tx_option.channel); + if (rv) + return rv; timeout.val = get_time().val + SPI_TRANSACTION_TIMEOUT_USEC; /* Wait for FIFO empty and BSY bit clear to indicate completion */ @@ -138,7 +141,9 @@ static int spi_dma_wait(void) dma_disable(dma_tx_option.channel); /* Wait for DMA reception to complete */ - dma_wait(dma_rx_option.channel); + rv = dma_wait(dma_rx_option.channel); + if (rv) + return rv; timeout.val = get_time().val + SPI_TRANSACTION_TIMEOUT_USEC; /* Wait for FRLVL[1:0] to indicate FIFO empty */ @@ -149,7 +154,7 @@ static int spi_dma_wait(void) /* Disable RX DMA */ dma_disable(dma_rx_option.channel); - return EC_SUCCESS; + return rv; } int spi_transaction_async(const uint8_t *txdata, int txlen, -- cgit v1.2.1