From 9c97e3421fa0aeec131689008181f8ee1dac5e99 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Tue, 1 Oct 2013 13:15:25 -0700 Subject: 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 Cc: Marek Vasut Cc: Fabio Estevam Cc: Shawn Guo Signed-off-by: Mark Brown --- drivers/spi/spi-mxs.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'drivers/spi/spi-mxs.c') diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c index 8cb5d8b..e9cbdb6 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, static int mxs_spi_setup(struct spi_device *dev) { - int err = 0; - if (!dev->bits_per_word) dev->bits_per_word = 8; if (dev->mode & ~(SPI_CPOL | SPI_CPHA)) return -EINVAL; - err = mxs_spi_setup_transfer(dev, NULL); - if (err) { - dev_err(&dev->dev, - "Failed to setup transfer, error = %d\n", err); - } - - return err; + return 0; } static uint32_t mxs_spi_cs_to_reg(unsigned cs) -- cgit v1.1