]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
spi: omap2-mcspi: Handle error on gpio_request
authorMichael Welling <mwelling@ieee.org>
Sun, 24 May 2015 02:13:45 +0000 (21:13 -0500)
committerMark Brown <broonie@kernel.org>
Mon, 25 May 2015 12:00:04 +0000 (13:00 +0100)
If a valid GPIO is specified but cannot be requested by the driver, print a
message and error out of omap2_mcspi_setup.

Signed-off-by: Michael Welling <mwelling@ieee.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-omap2-mcspi.c

index c4e21adb9bf7d8691b2c57e58d642c4706ccc3f9..58673841286c335adc123d5200c1a0f128ecab04 100644 (file)
@@ -1023,9 +1023,12 @@ static int omap2_mcspi_setup(struct spi_device *spi)
        }
 
        if (gpio_is_valid(spi->cs_gpio)) {
-               if (gpio_request(spi->cs_gpio, dev_name(&spi->dev)) == 0)
-                       gpio_direction_output(spi->cs_gpio,
-                       !(spi->mode & SPI_CS_HIGH));
+               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);