All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] spi: imx: GPIO based chip selects should not be required
@ 2017-10-13 19:54 ` Trent Piepho
  0 siblings, 0 replies; 22+ messages in thread
From: Trent Piepho @ 2017-10-13 19:54 UTC (permalink / raw)
  To: linux-spi, linux-arm-kernel
  Cc: Shawn Guo, Sascha Hauer, Fabio Estevam, Greg Ungerer, Trent Piepho

The driver will fail to load if no gpio chip selects are specified,
this patch changes this so that it no longer fails.

It's possible to use all native chip selects, in which case there is
no reason to have a gpio chip select array.  This is what happens if
the *optional* device tree property "cs-gpios" is omitted.

The spi core already checks for the absence of gpio chip selects in
the master and assigns any slaves the gpio_cs value of -ENOENT.

Signed-off-by: Trent Piepho <tpiepho-cgc2CodaaHDQT0dZR+AlfA@public.gmane.org>
---
 drivers/spi/spi-imx.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index babb15f07995..07e6250f2dad 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -1457,22 +1457,19 @@ static int spi_imx_probe(struct platform_device *pdev)
 		goto out_clk_put;
 	}
 
-	if (!master->cs_gpios) {
-		dev_err(&pdev->dev, "No CS GPIOs available\n");
-		ret = -EINVAL;
-		goto out_clk_put;
-	}
-
-	for (i = 0; i < master->num_chipselect; i++) {
-		if (!gpio_is_valid(master->cs_gpios[i]))
-			continue;
-
-		ret = devm_gpio_request(&pdev->dev, master->cs_gpios[i],
-					DRIVER_NAME);
-		if (ret) {
-			dev_err(&pdev->dev, "Can't get CS GPIO %i\n",
-				master->cs_gpios[i]);
-			goto out_clk_put;
+	/* Request GPIO CS lines, if any */
+	if (master->cs_gpios) {
+		for (i = 0; i < master->num_chipselect; i++) {
+			if (!gpio_is_valid(master->cs_gpios[i]))
+				continue;
+
+			ret = devm_gpio_request(&pdev->dev, master->cs_gpios[i],
+						DRIVER_NAME);
+			if (ret) {
+				dev_err(&pdev->dev, "Can't get CS GPIO %i\n",
+					master->cs_gpios[i]);
+				goto out_clk_put;
+			}
 		}
 	}
 
-- 
2.13.6

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2017-10-30 23:47 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-13 19:54 [PATCH 1/4] spi: imx: GPIO based chip selects should not be required Trent Piepho
2017-10-13 19:54 ` Trent Piepho
     [not found] ` <20171013195410.30767-1-tpiepho-cgc2CodaaHDQT0dZR+AlfA@public.gmane.org>
2017-10-13 19:54   ` [PATCH 2/4] spi: imx: Fix failure path leak on GPIO request error Trent Piepho
2017-10-13 19:54     ` Trent Piepho
     [not found]     ` <20171013195410.30767-2-tpiepho-cgc2CodaaHDQT0dZR+AlfA@public.gmane.org>
2017-10-19 10:27       ` Oleksij Rempel
2017-10-19 10:27         ` Oleksij Rempel
2017-10-13 19:54   ` [PATCH 3/4] spi: imx: Don't require platform data chipselect array Trent Piepho
2017-10-13 19:54     ` Trent Piepho
2017-10-18  9:02     ` Julien Thierry
2017-10-18  9:02       ` Julien Thierry
     [not found]       ` <36d381de-ee3f-26d4-59c3-b9d361758ace-5wv7dgnIgG8@public.gmane.org>
2017-10-18 17:30         ` Trent Piepho
2017-10-18 17:30           ` Trent Piepho
2017-10-30 23:47         ` Trent Piepho
2017-10-30 23:47           ` Trent Piepho
2017-10-13 19:54   ` [PATCH 4/4] ARM: imx: Update spi_imx platform data to reflect current state Trent Piepho
2017-10-13 19:54     ` Trent Piepho
     [not found]     ` <20171013195410.30767-4-tpiepho-cgc2CodaaHDQT0dZR+AlfA@public.gmane.org>
2017-10-15 23:34       ` Greg Ungerer
2017-10-15 23:34         ` Greg Ungerer
2017-10-18  2:17       ` Shawn Guo
2017-10-18  2:17         ` Shawn Guo
2017-10-18 17:50         ` Trent Piepho
2017-10-18 17:50           ` Trent Piepho

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.