aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-mxs.c
diff options
context:
space:
mode:
authorTrent Piepho <tpiepho@gmail.com>2013-10-01 16:15:25 -0400
committerMark Brown <broonie@linaro.org>2013-10-17 20:00:31 -0400
commit9c97e3421fa0aeec131689008181f8ee1dac5e99 (patch)
tree365c0f4bce04f8c6b26099521256e3cfa07e8c00 /drivers/spi/spi-mxs.c
parent1a33073fcf11e70447b704c0228e28099e6ab39d (diff)
spi: spi-mxs: Fix race in setup method
Despite many warnings in the SPI documentation and code, the spi-mxs driver sets shared chip registers in the ->setup method. This method can be called when transfers are in progress on other slaves controlled by the master. Setting registers or any other shared state will corrupt those transfers. So fix mxs_spi_setup() to not call mxs_spi_setup_transfer(). mxs_spi_setup_transfer() is already called for each transfer when they are actually performed in mxs_spi_transfer_one(), so the call in mxs_spi_setup() isn't necessary to setup anything. Signed-off-by: Trent Piepho <tpiepho@gmail.com> Cc: Marek Vasut <marex@denx.de> Cc: Fabio Estevam <fabio.estevam@freescale.com> Cc: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi-mxs.c')
-rw-r--r--drivers/spi/spi-mxs.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c
index 8cb5d8b6f042..e9cbdb6b1309 100644
--- a/drivers/spi/spi-mxs.c
+++ b/drivers/spi/spi-mxs.c
@@ -103,21 +103,13 @@ static int mxs_spi_setup_transfer(struct spi_device *dev,
103 103
104static int mxs_spi_setup(struct spi_device *dev) 104static int mxs_spi_setup(struct spi_device *dev)
105{ 105{
106 int err = 0;
107
108 if (!dev->bits_per_word) 106 if (!dev->bits_per_word)
109 dev->bits_per_word = 8; 107 dev->bits_per_word = 8;
110 108
111 if (dev->mode & ~(SPI_CPOL | SPI_CPHA)) 109 if (dev->mode & ~(SPI_CPOL | SPI_CPHA))
112 return -EINVAL; 110 return -EINVAL;
113 111
114 err = mxs_spi_setup_transfer(dev, NULL); 112 return 0;
115 if (err) {
116 dev_err(&dev->dev,
117 "Failed to setup transfer, error = %d\n", err);
118 }
119
120 return err;
121} 113}
122 114
123static uint32_t mxs_spi_cs_to_reg(unsigned cs) 115static uint32_t mxs_spi_cs_to_reg(unsigned cs)