diff options
author | Yen Lin <yelin@nvidia.com> | 2014-06-16 10:43:36 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-06-17 19:56:55 +0000 |
commit | 2b043665850f7c74cd6a4a7f24d7a18b01b378ac (patch) | |
tree | b9d5e6bda73fb53798e390f1b31fc0197228fa17 | |
parent | 0545d079de36da23b9514a11c9cac886ab244fee (diff) | |
download | chrome-ec-2b043665850f7c74cd6a4a7f24d7a18b01b378ac.tar.gz |
stm32: spi: read spi->dr into a dummy variable
In setup_for_transaction(), read spi->dr into a dummy variable instead
of into in_msg[0]. Since in_msg[0] is an alias for a command's port number,
this will prevent a command's port number from being over-written if spi
transaction is terminated early while a command is still in progress.
BUG=chrome-os-partner:28979
BRANCH=nyan
TEST=passed factory_test.reboot2 test for >1000 cycles
Change-Id: I4385572b2903fa906207977259b456d72fc7f52e
Signed-off-by: Yen Lin <yelin@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/204355
Reviewed-by: Yung-chieh Lo <yjlou@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | chip/stm32/spi.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/chip/stm32/spi.c b/chip/stm32/spi.c index 960067f955..26b3bfbc8d 100644 --- a/chip/stm32/spi.c +++ b/chip/stm32/spi.c @@ -234,6 +234,7 @@ static void reply(stm32_dma_chan_t *txdma, static void setup_for_transaction(void) { stm32_spi_regs_t *spi = STM32_SPI1_REGS; + volatile uint8_t dummy __attribute__((unused)); /* Not ready to receive yet */ spi->dr = EC_SPI_NOT_READY; @@ -248,7 +249,7 @@ static void setup_for_transaction(void) * Read a byte in case there is one pending; this prevents the receive * DMA from getting that byte right when we start it */ - *in_msg = spi->dr; + dummy = spi->dr; /* Start DMA */ dma_start_rx(&dma_rx_option, sizeof(in_msg), in_msg); |