spi: omap2-mcspi: Prevent duplicate gpio_request

commit 2f538c017e1a8620d19553931199c6d6a6d31bb2 upstream.

Occasionally the setup function will be called multiple times. Only request
the gpio the first time otherwise -EBUSY will occur on subsequent calls to
setup.

Reported-by: Joseph Bell <joe@iachieved.it>

Signed-off-by: Michael Welling <mwelling@ieee.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Michael Welling 2015-11-30 09:02:39 -06:00 committed by Greg Kroah-Hartman
parent 3e90844662
commit 50d6040375

View file

@ -1024,13 +1024,6 @@ static int omap2_mcspi_setup(struct spi_device *spi)
spi->controller_state = cs; spi->controller_state = cs;
/* Link this to context save list */ /* Link this to context save list */
list_add_tail(&cs->node, &ctx->cs); list_add_tail(&cs->node, &ctx->cs);
}
if (!mcspi_dma->dma_rx || !mcspi_dma->dma_tx) {
ret = omap2_mcspi_request_dma(spi);
if (ret < 0 && ret != -EAGAIN)
return ret;
}
if (gpio_is_valid(spi->cs_gpio)) { if (gpio_is_valid(spi->cs_gpio)) {
ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev)); ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev));
@ -1038,7 +1031,15 @@ static int omap2_mcspi_setup(struct spi_device *spi)
dev_err(&spi->dev, "failed to request gpio\n"); dev_err(&spi->dev, "failed to request gpio\n");
return ret; return ret;
} }
gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); gpio_direction_output(spi->cs_gpio,
!(spi->mode & SPI_CS_HIGH));
}
}
if (!mcspi_dma->dma_rx || !mcspi_dma->dma_tx) {
ret = omap2_mcspi_request_dma(spi);
if (ret < 0 && ret != -EAGAIN)
return ret;
} }
ret = pm_runtime_get_sync(mcspi->dev); ret = pm_runtime_get_sync(mcspi->dev);