]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
spi/i.MX: fix broken error handling for gpio_request
authorJohn Ogness <john.ogness@linutronix.de>
Tue, 24 Nov 2009 16:53:07 +0000 (16:53 +0000)
committerGrant Likely <grant.likely@secretlab.ca>
Wed, 9 Dec 2009 01:48:16 +0000 (18:48 -0700)
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.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
drivers/spi/spi_imx.c

index 1b17f443dee702f60600be396328d90168c015e7..8ffa48ce570c8eaefecf399f0e139ce0a62a03a8 100644 (file)
@@ -516,11 +516,12 @@ static int __init spi_imx_probe(struct platform_device *pdev)
                        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;
                }
        }