mirror of https://gitee.com/openkylin/linux.git
spi/imx: use gpio_is_valid to determine if a gpio is valid
Use gpio_is_valid() to replace "gpio >= 0" or "gpio < 0". Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Hui Wang <jason77.wang@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
872675df27
commit
8b17e0559f
|
@ -626,7 +626,7 @@ static void spi_imx_chipselect(struct spi_device *spi, int is_active)
|
||||||
int active = is_active != BITBANG_CS_INACTIVE;
|
int active = is_active != BITBANG_CS_INACTIVE;
|
||||||
int dev_is_lowactive = !(spi->mode & SPI_CS_HIGH);
|
int dev_is_lowactive = !(spi->mode & SPI_CS_HIGH);
|
||||||
|
|
||||||
if (gpio < 0)
|
if (!gpio_is_valid(gpio))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gpio_set_value(gpio, dev_is_lowactive ^ active);
|
gpio_set_value(gpio, dev_is_lowactive ^ active);
|
||||||
|
@ -736,7 +736,7 @@ static int spi_imx_setup(struct spi_device *spi)
|
||||||
dev_dbg(&spi->dev, "%s: mode %d, %u bpw, %d hz\n", __func__,
|
dev_dbg(&spi->dev, "%s: mode %d, %u bpw, %d hz\n", __func__,
|
||||||
spi->mode, spi->bits_per_word, spi->max_speed_hz);
|
spi->mode, spi->bits_per_word, spi->max_speed_hz);
|
||||||
|
|
||||||
if (gpio >= 0)
|
if (gpio_is_valid(gpio))
|
||||||
gpio_direction_output(gpio, spi->mode & SPI_CS_HIGH ? 0 : 1);
|
gpio_direction_output(gpio, spi->mode & SPI_CS_HIGH ? 0 : 1);
|
||||||
|
|
||||||
spi_imx_chipselect(spi, BITBANG_CS_INACTIVE);
|
spi_imx_chipselect(spi, BITBANG_CS_INACTIVE);
|
||||||
|
@ -789,11 +789,11 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
for (i = 0; i < master->num_chipselect; i++) {
|
for (i = 0; i < master->num_chipselect; i++) {
|
||||||
int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
|
int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
|
||||||
if (cs_gpio < 0 && mxc_platform_info)
|
if (!gpio_is_valid(cs_gpio) && mxc_platform_info)
|
||||||
cs_gpio = mxc_platform_info->chipselect[i];
|
cs_gpio = mxc_platform_info->chipselect[i];
|
||||||
|
|
||||||
spi_imx->chipselect[i] = cs_gpio;
|
spi_imx->chipselect[i] = cs_gpio;
|
||||||
if (cs_gpio < 0)
|
if (!gpio_is_valid(cs_gpio))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME);
|
ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME);
|
||||||
|
@ -895,7 +895,7 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)
|
||||||
release_mem_region(res->start, resource_size(res));
|
release_mem_region(res->start, resource_size(res));
|
||||||
out_gpio_free:
|
out_gpio_free:
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
if (spi_imx->chipselect[i] >= 0)
|
if (gpio_is_valid(spi_imx->chipselect[i]))
|
||||||
gpio_free(spi_imx->chipselect[i]);
|
gpio_free(spi_imx->chipselect[i]);
|
||||||
}
|
}
|
||||||
spi_master_put(master);
|
spi_master_put(master);
|
||||||
|
@ -920,7 +920,7 @@ static int __devexit spi_imx_remove(struct platform_device *pdev)
|
||||||
iounmap(spi_imx->base);
|
iounmap(spi_imx->base);
|
||||||
|
|
||||||
for (i = 0; i < master->num_chipselect; i++)
|
for (i = 0; i < master->num_chipselect; i++)
|
||||||
if (spi_imx->chipselect[i] >= 0)
|
if (gpio_is_valid(spi_imx->chipselect[i]))
|
||||||
gpio_free(spi_imx->chipselect[i]);
|
gpio_free(spi_imx->chipselect[i]);
|
||||||
|
|
||||||
spi_master_put(master);
|
spi_master_put(master);
|
||||||
|
|
Loading…
Reference in New Issue