[4/5] spi: lpspi: handle EPROBE_DEFER when get cs-gpios number
diff mbox series

Message ID 20200714075251.12777-5-xiaoning.wang@nxp.com
State Superseded
Headers show
Series
  • Some bug fix for lpspi
Related show

Commit Message

Clark Wang July 14, 2020, 7:52 a.m. UTC
From: Fabrice Goucem <fabrice.goucem@nxp.com>

If SPI is probed before the GPIO driver, it may miss the cs-gpio
configuration in dtb.
Add defer probe handler to wait GPIO driver probe.

Signed-off-by: Fabrice Goucem <fabrice.goucem@nxp.com>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
---
 drivers/spi/spi-fsl-lpspi.c | 5 +++++
 1 file changed, 5 insertions(+)

Patch
diff mbox series

diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index 6fb77f0f657a..05b6ecd82974 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -887,6 +887,11 @@  static int fsl_lpspi_probe(struct platform_device *pdev)
 		for (i = 0; i < controller->num_chipselect; i++) {
 			int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
 
+			if (cs_gpio == -EPROBE_DEFER) {
+				ret = -EPROBE_DEFER;
+				goto out_controller_put;
+			}
+
 			if (!gpio_is_valid(cs_gpio) && lpspi_platform_info)
 				cs_gpio = lpspi_platform_info->chipselect[i];