mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 1/2] spi: atmel_spi: Fix GPIO-based chip select handling to support multiple valid entries
@ 2024-06-22 17:48 Oleksij Rempel
  2024-06-22 17:48 ` [PATCH v2 2/2] ARM: at91: microchip-sama5d3-eds: implement MDIO and SPI extension boards detection Oleksij Rempel
  2024-07-01 12:44 ` (subset) [PATCH v2 1/2] spi: atmel_spi: Fix GPIO-based chip select handling to support multiple valid entries Sascha Hauer
  0 siblings, 2 replies; 4+ messages in thread
From: Oleksij Rempel @ 2024-06-22 17:48 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

Current implementation of GPIO-based chip select configuration in this
driver only considers the first valid GPIO and ignores
subsequent entries. This patch ensures that all valid GPIO entries are
processed correctly, enabling configurations with multiple valid and
invalid entries.

Specifically, this change addresses the issue where configurations like
`cs-gpios = <&pioC 25 0>, <0>, <0>, <&pioC 28 0>;` are not handled
correctly, leading to the last valid GPIO being ignored.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/spi/atmel_spi.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 90f655dc3e..4adad241b4 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -414,11 +414,7 @@ static int atmel_spi_probe(struct device *dev)
 		for (i = 0; i < master->num_chipselect; i++) {
 			as->cs_pins[i] = of_get_named_gpio(node, "cs-gpios", i);
 
-			if (!gpio_is_valid(as->cs_pins[i]))
-			    break;
 		}
-
-		master->num_chipselect = i;
 	}
 
 	as->clk = clk_get(dev, "spi_clk");
@@ -438,9 +434,10 @@ static int atmel_spi_probe(struct device *dev)
 	atmel_get_caps(as);
 
 	for (i = 0; i < master->num_chipselect; i++) {
-		ret = gpio_request(as->cs_pins[i], dev_name(dev));
-		if (ret)
-			goto out_gpio;
+		if (gpio_is_valid(as->cs_pins[i]))
+			ret = gpio_request(as->cs_pins[i], dev_name(dev));
+			if (ret)
+				goto out_gpio;
 	}
 
 	/* Initialize the hardware */
-- 
2.39.2




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-07-01 12:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-22 17:48 [PATCH v2 1/2] spi: atmel_spi: Fix GPIO-based chip select handling to support multiple valid entries Oleksij Rempel
2024-06-22 17:48 ` [PATCH v2 2/2] ARM: at91: microchip-sama5d3-eds: implement MDIO and SPI extension boards detection Oleksij Rempel
2024-07-01 12:43   ` Sascha Hauer
2024-07-01 12:44 ` (subset) [PATCH v2 1/2] spi: atmel_spi: Fix GPIO-based chip select handling to support multiple valid entries Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox