linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] spi/imx: simplify error handling to free gpios
@ 2012-01-10  7:27 Axel Lin
  2012-03-09 23:27 ` Grant Likely
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-01-10  7:27 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Shawn Guo

Simplify the error handling by moving the code to free gpios in one place.

Signed-off-by: Axel Lin <axel.lin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Acked-by: Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/spi/spi-imx.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index c6e697f..31054e3 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -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;
 		}
 	}
 
@@ -881,10 +876,10 @@ out_iounmap:
 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);
-- 
1.7.5.4




------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev

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

* Re: [PATCH RESEND] spi/imx: simplify error handling to free gpios
  2012-01-10  7:27 [PATCH RESEND] spi/imx: simplify error handling to free gpios Axel Lin
@ 2012-03-09 23:27 ` Grant Likely
  0 siblings, 0 replies; 2+ messages in thread
From: Grant Likely @ 2012-03-09 23:27 UTC (permalink / raw)
  To: Axel Lin, linux-kernel; +Cc: Shawn Guo, Sascha Hauer, spi-devel-general

On Tue, 10 Jan 2012 15:27:36 +0800, Axel Lin <axel.lin@gmail.com> wrote:
> 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>

Applied, thanks.

g.

> ---
>  drivers/spi/spi-imx.c |   11 +++--------
>  1 files changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> index c6e697f..31054e3 100644
> --- a/drivers/spi/spi-imx.c
> +++ b/drivers/spi/spi-imx.c
> @@ -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;
>  		}
>  	}
>  
> @@ -881,10 +876,10 @@ out_iounmap:
>  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);
> -- 
> 1.7.5.4
> 
> 
> 

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies,Ltd.

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

end of thread, other threads:[~2012-03-09 23:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-10  7:27 [PATCH RESEND] spi/imx: simplify error handling to free gpios Axel Lin
2012-03-09 23:27 ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).