* [PATCH] SPI/i.MX: fix broken error handling for gpio_request
@ 2009-11-24 16:53 John Ogness
0 siblings, 0 replies; only message in thread
From: John Ogness @ 2009-11-24 16:53 UTC (permalink / raw)
To: s.hauer; +Cc: spi-devel-general, linux-kernel
i.MX35-provided chipselects are represented using negative numbers. If
gpio_request() fails and the previous chipselect was a negative number,
the while loop is endless (i is never decremented).
Also, the error loop would never call gpio_free on chipselect[0].
And finally, the error message was missing an endline.
This patch is against 2.6.32-rc8.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
spi_imx.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -513,11 +513,12 @@ static int __init spi_imx_probe(struct p
continue;
ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME);
if (ret) {
- i--;
- while (i > 0)
+ while (i > 0) {
+ i--;
if (spi_imx->chipselect[i] >= 0)
- gpio_free(spi_imx->chipselect[i--]);
- dev_err(&pdev->dev, "can't get cs gpios");
+ gpio_free(spi_imx->chipselect[i]);
+ }
+ dev_err(&pdev->dev, "can't get cs gpios\n");
goto out_master_put;
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-11-24 16:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-24 16:53 [PATCH] SPI/i.MX: fix broken error handling for gpio_request John Ogness
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®