summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominic Chen <ddchen@chromium.org>2014-07-21 12:15:48 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-07-23 11:09:06 +0000
commit205f6f6746c8a1788b93c7ce27ce62d0d6af02a5 (patch)
tree9a01950549badad028cc7e7ea2ca339f86843dc5
parent054c9fe6a6b32098f5fa881d49c6f43707d8d042 (diff)
downloadchrome-ec-205f6f6746c8a1788b93c7ce27ce62d0d6af02a5.tar.gz
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 <ddchen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209116 Reviewed-by: Vic Yang <victoryang@chromium.org>
-rw-r--r--chip/stm32/spi_master.c11
1 files changed, 8 insertions, 3 deletions
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,