summaryrefslogtreecommitdiff
path: root/chip/stm32/spi.c
diff options
context:
space:
mode:
authorYen Lin <yelin@nvidia.com>2014-06-16 10:43:36 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-07-08 02:13:25 +0000
commita02cb09bb744f130348f50707d7e9ca3ba8ef7de (patch)
tree9a82d25eeb68e2ebb10040abab8dd41dcd3739f7 /chip/stm32/spi.c
parentb1dec633cb59fa79d4d9c4d2104eba84f280d7b2 (diff)
downloadchrome-ec-a02cb09bb744f130348f50707d7e9ca3ba8ef7de.tar.gz
stm32: spi: read spi->dr into a dummy variable
(cherry-pick back to ToT) 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 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> (cherry picked from commit 2b043665850f7c74cd6a4a7f24d7a18b01b378ac) Change-Id: Ia412fadcd7621f45bbb096771615ce75fe445592 Oiginal-Change-Id: I308ea954d6242fce5b3a70a14660767ac88d8242 Reviewed-on: https://chromium-review.googlesource.com/206920 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Yung-chieh Lo <yjlou@chromium.org> Tested-by: Yung-chieh Lo <yjlou@chromium.org>
Diffstat (limited to 'chip/stm32/spi.c')
-rw-r--r--chip/stm32/spi.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/chip/stm32/spi.c b/chip/stm32/spi.c
index f47ef89b85..960c6934b6 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);