From: Fabrice Goucem <fabrice.gou...@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.gou...@nxp.com>
Signed-off-by: Clark Wang <xiaoning.w...@nxp.com>
---
 drivers/spi/spi-fsl-lpspi.c | 5 +++++
 1 file changed, 5 insertions(+)

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];
 
-- 
2.17.1

Reply via email to