Skip to content

Commit

Permalink
spi/imx: simplify error handling to free gpios
Browse files Browse the repository at this point in the history
Simplify the error handling by moving the code to free gpios in one place.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
  • Loading branch information
Axel Lin authored and Grant Likely committed Mar 9, 2012
1 parent e290cf2 commit 00ffc13
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions drivers/spi/spi-imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,13 +793,8 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)

ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME);
if (ret) {
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\n");
goto out_master_put;
goto out_gpio_free;
}
}

Expand Down Expand Up @@ -881,10 +876,10 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)
out_release_mem:
release_mem_region(res->start, resource_size(res));
out_gpio_free:
for (i = 0; i < master->num_chipselect; i++)
while (--i >= 0) {
if (spi_imx->chipselect[i] >= 0)
gpio_free(spi_imx->chipselect[i]);
out_master_put:
}
spi_master_put(master);
kfree(master);
platform_set_drvdata(pdev, NULL);
Expand Down

0 comments on commit 00ffc13

Please sign in to comment.