Commit 50d60403 authored by Michael Welling's avatar Michael Welling Committed by Greg Kroah-Hartman

spi: omap2-mcspi: Prevent duplicate gpio_request

commit 2f538c01 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: default avatarJoseph Bell <joe@iachieved.it>
Signed-off-by: default avatarMichael Welling <mwelling@ieee.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3e908446
...@@ -1024,6 +1024,16 @@ static int omap2_mcspi_setup(struct spi_device *spi) ...@@ -1024,6 +1024,16 @@ 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 (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) { if (!mcspi_dma->dma_rx || !mcspi_dma->dma_tx) {
...@@ -1032,15 +1042,6 @@ static int omap2_mcspi_setup(struct spi_device *spi) ...@@ -1032,15 +1042,6 @@ static int omap2_mcspi_setup(struct spi_device *spi)
return ret; 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); ret = pm_runtime_get_sync(mcspi->dev);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment