summaryrefslogtreecommitdiff
path: root/drivers/spi/spi-omap2-mcspi.c
diff options
context:
space:
mode:
authorMichael Welling <mwelling@ieee.org>2015-11-30 18:02:39 +0300
committerMark Brown <broonie@kernel.org>2015-12-01 20:05:34 +0300
commit2f538c017e1a8620d19553931199c6d6a6d31bb2 (patch)
tree8695571786a4c1a27d2fea132757ee9ca495380e /drivers/spi/spi-omap2-mcspi.c
parentbeca365565d8f8912dce67567f54ad4c71734843 (diff)
downloadlinux-2f538c017e1a8620d19553931199c6d6a6d31bb2.tar.xz
spi: omap2-mcspi: Prevent duplicate gpio_request
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>
Diffstat (limited to 'drivers/spi/spi-omap2-mcspi.c')
-rw-r--r--drivers/spi/spi-omap2-mcspi.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 02aa1d0607b3..7273820275e9 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1025,6 +1025,16 @@ static int omap2_mcspi_setup(struct spi_device *spi)
spi->controller_state = cs;
/* Link this to context save list */
list_add_tail(&cs->node, &ctx->cs);
+
+ if (gpio_is_valid(spi->cs_gpio)) {
+ ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev));
+ if (ret) {
+ dev_err(&spi->dev, "failed to request gpio\n");
+ return ret;
+ }
+ gpio_direction_output(spi->cs_gpio,
+ !(spi->mode & SPI_CS_HIGH));
+ }
}
if (!mcspi_dma->dma_rx || !mcspi_dma->dma_tx) {
@@ -1033,15 +1043,6 @@ static int omap2_mcspi_setup(struct spi_device *spi)
return ret;
}
- if (gpio_is_valid(spi->cs_gpio)) {
- ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev));
- if (ret) {
- dev_err(&spi->dev, "failed to request gpio\n");
- return ret;
- }
- gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
- }
-
ret = pm_runtime_get_sync(mcspi->dev);
if (ret < 0)
return ret;