summaryrefslogtreecommitdiff
path: root/drivers/spi
diff options
context:
space:
mode:
authorJohn Watts <contact@jookia.org>2023-01-25 07:05:55 +1100
committerSascha Hauer <s.hauer@pengutronix.de>2023-01-26 09:14:21 +0100
commit47a4ddb1a292c09daf1d11983f53f3fb95a63bbc (patch)
tree0f1d113564977411eb49d0c26fec128eeb2b56ae /drivers/spi
parentf6f5cbfef751f728bfa985f846fab468d222a019 (diff)
downloadbarebox-47a4ddb1a292c09daf1d11983f53f3fb95a63bbc.tar.gz
spi: Fix probing SPI drivers with no cs-gpios
of_gpio_named_count returns a negative value on error but this is discarded and cast to a u16, making error handling impossible. With debug logging enabled this effectively halts booting so the board can print an error over serial 65534 times. Introduce of_gpio_count_csgpios which returns 0 in the case of an error rather than a negative value. Signed-off-by: John Watts <contact@jookia.org> Link: https://lore.barebox.org/20230124200554.1701687-1-contact@jookia.org Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/atmel_spi.c2
-rw-r--r--drivers/spi/imx_spi.c2
-rw-r--r--drivers/spi/stm32_spi.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 399c47c81d..9bf85874c5 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -408,7 +408,7 @@ static int atmel_spi_probe(struct device *dev)
master->num_chipselect = pdata->num_chipselect;
as->cs_pins = pdata->chipselect;
} else {
- master->num_chipselect = of_gpio_named_count(node, "cs-gpios");
+ master->num_chipselect = of_gpio_count_csgpios(node);
as->cs_pins = xzalloc(sizeof(u32) * master->num_chipselect);
for (i = 0; i < master->num_chipselect; i++) {
diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c
index eb30d757d5..f81d9e851f 100644
--- a/drivers/spi/imx_spi.c
+++ b/drivers/spi/imx_spi.c
@@ -568,7 +568,7 @@ static int imx_spi_dt_probe(struct imx_spi *imx)
if (!node)
return -ENODEV;
- imx->master.num_chipselect = of_gpio_named_count(node, "cs-gpios");
+ imx->master.num_chipselect = of_gpio_count_csgpios(node);
imx->cs_array = xzalloc(sizeof(u32) * imx->master.num_chipselect);
for (i = 0; i < imx->master.num_chipselect; i++)
diff --git a/drivers/spi/stm32_spi.c b/drivers/spi/stm32_spi.c
index 821a95980f..0d7407c279 100644
--- a/drivers/spi/stm32_spi.c
+++ b/drivers/spi/stm32_spi.c
@@ -514,7 +514,7 @@ static void stm32_spi_dt_probe(struct stm32_spi_priv *priv)
struct device_node *node = priv->master.dev->of_node;
int i;
- priv->master.num_chipselect = of_gpio_named_count(node, "cs-gpios");
+ priv->master.num_chipselect = of_gpio_count_csgpios(node);
priv->cs_gpios = xzalloc(sizeof(u32) * priv->master.num_chipselect);
for (i = 0; i < priv->master.num_chipselect; i++)