diff options
author | Mark Brown <broonie@kernel.org> | 2015-11-25 11:54:56 +0000 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-11-25 11:54:56 +0000 |
commit | 4d920471d718618dab2c1dc867b1438c84b8d8ff (patch) | |
tree | 7976e8083c2d6a27813b5e4b79b66535cb917312 /drivers/spi/spi-mt65xx.c | |
parent | 4c3dbd35d4369ddb0f0e26dd329a6aab870703e2 (diff) | |
parent | 98c8dccf2b2771fb622d449b2ec1604fc5d260e5 (diff) |
Merge branch 'fix/mediatek' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi into spi-mtk
Diffstat (limited to 'drivers/spi/spi-mt65xx.c')
-rw-r--r-- | drivers/spi/spi-mt65xx.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index 2b3fcb8ca325..6c1a96eb49ee 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -407,7 +407,7 @@ static int mtk_spi_setup(struct spi_device *spi) if (!spi->controller_data) spi->controller_data = (void *)&mtk_default_chip_info; - if (mdata->dev_comp->need_pad_sel) + if (mdata->dev_comp->need_pad_sel && gpio_is_valid(spi->cs_gpio)) gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); return 0; @@ -629,13 +629,23 @@ static int mtk_spi_probe(struct platform_device *pdev) goto err_put_master; } - for (i = 0; i < master->num_chipselect; i++) { - ret = devm_gpio_request(&pdev->dev, master->cs_gpios[i], - dev_name(&pdev->dev)); - if (ret) { - dev_err(&pdev->dev, - "can't get CS GPIO %i\n", i); - goto err_put_master; + if (!master->cs_gpios && master->num_chipselect > 1) { + dev_err(&pdev->dev, + "cs_gpios not specified and num_chipselect > 1\n"); + ret = -EINVAL; + goto err_put_master; + } + + if (master->cs_gpios) { + for (i = 0; i < master->num_chipselect; i++) { + ret = devm_gpio_request(&pdev->dev, + master->cs_gpios[i], + dev_name(&pdev->dev)); + if (ret) { + dev_err(&pdev->dev, + "can't get CS GPIO %i\n", i); + goto err_put_master; + } } } } |