Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f538c01 authored by Michael Welling's avatar Michael Welling Committed by Mark Brown
Browse files

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: default avatarJoseph Bell <joe@iachieved.it>

Signed-off-by: default avatarMichael Welling <mwelling@ieee.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent beca3655
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -1025,13 +1025,6 @@ 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 (!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)) {
			ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev));
@@ -1039,7 +1032,15 @@ static int omap2_mcspi_setup(struct spi_device *spi)
				dev_err(&spi->dev, "failed to request gpio\n");
				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);