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

Commit 98c8dccf authored by Nicolas Boichat's avatar Nicolas Boichat Committed by Mark Brown
Browse files

spi: mediatek: single device does not require cs_gpios



When only one device is present, it is not necessary to specify
cs_gpios, as the CS line can be controlled by the hardware
module.

Without this patch, older device tree bindings used before
37457607 "spi: mediatek: mt8173 spi multiple devices support"
would cause a panic on boot. This fixes the crash, and
re-introduces backward compatibility.

Signed-off-by: default avatarNicolas Boichat <drinkcat@chromium.org>
Acked-by: default avatarLeilk Liu <leilk.liu@mediatek.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 8005c49d
Loading
Loading
Loading
Loading
+18 −8
Original line number Original line Diff line number Diff line
@@ -410,7 +410,7 @@ static int mtk_spi_setup(struct spi_device *spi)
	if (!spi->controller_data)
	if (!spi->controller_data)
		spi->controller_data = (void *)&mtk_default_chip_info;
		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));
		gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));


	return 0;
	return 0;
@@ -632,8 +632,17 @@ static int mtk_spi_probe(struct platform_device *pdev)
			goto err_put_master;
			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++) {
			for (i = 0; i < master->num_chipselect; i++) {
			ret = devm_gpio_request(&pdev->dev, master->cs_gpios[i],
				ret = devm_gpio_request(&pdev->dev,
							master->cs_gpios[i],
							dev_name(&pdev->dev));
							dev_name(&pdev->dev));
				if (ret) {
				if (ret) {
					dev_err(&pdev->dev,
					dev_err(&pdev->dev,
@@ -642,6 +651,7 @@ static int mtk_spi_probe(struct platform_device *pdev)
				}
				}
			}
			}
		}
		}
	}


	return 0;
	return 0;