提交 9c97e342 编写于 作者: T Trent Piepho 提交者: Mark Brown

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: NTrent 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: NMark Brown <broonie@linaro.org>
上级 1a33073f
...@@ -103,21 +103,13 @@ static int mxs_spi_setup_transfer(struct spi_device *dev, ...@@ -103,21 +103,13 @@ static int mxs_spi_setup_transfer(struct spi_device *dev,
static int mxs_spi_setup(struct spi_device *dev) static int mxs_spi_setup(struct spi_device *dev)
{ {
int err = 0;
if (!dev->bits_per_word) if (!dev->bits_per_word)
dev->bits_per_word = 8; dev->bits_per_word = 8;
if (dev->mode & ~(SPI_CPOL | SPI_CPHA)) if (dev->mode & ~(SPI_CPOL | SPI_CPHA))
return -EINVAL; return -EINVAL;
err = mxs_spi_setup_transfer(dev, NULL); return 0;
if (err) {
dev_err(&dev->dev,
"Failed to setup transfer, error = %d\n", err);
}
return err;
} }
static uint32_t mxs_spi_cs_to_reg(unsigned cs) static uint32_t mxs_spi_cs_to_reg(unsigned cs)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册