All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Axel Lin <axel.lin@gmail.com>, linux-kernel@vger.kernel.org
Cc: Shawn Guo <shawn.guo@linaro.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	spi-devel-general@lists.sourceforge.net
Subject: Re: [PATCH RESEND] spi/imx: simplify error handling to free gpios
Date: Fri, 09 Mar 2012 16:27:10 -0700	[thread overview]
Message-ID: <20120309232710.45C763E08B7@localhost> (raw)
In-Reply-To: <1326180456.4956.7.camel@phoenix>

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.

      reply	other threads:[~2012-03-09 23:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-10  7:27 [PATCH RESEND] spi/imx: simplify error handling to free gpios Axel Lin
2012-01-10  7:27 ` Axel Lin
2012-03-09 23:27 ` Grant Likely [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120309232710.45C763E08B7@localhost \
    --to=grant.likely@secretlab.ca \
    --cc=axel.lin@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawn.guo@linaro.org \
    --cc=spi-devel-general@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.