diff mbox

SPI/i.MX: fix broken error handling for gpio_request

Message ID 807htfsw3w.fsf@merkur.tec.linutronix.de (mailing list archive)
State Accepted
Headers show

Commit Message

John Ogness Nov. 24, 2009, 4:53 p.m. UTC
None
diff mbox

Patch

--- 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;
 		}
 	}