public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
To: Wei Yongjun <weiyj.lk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	arnaud.patard-dQbF7i+pzddAfugRpC6u6w@public.gmane.org,
	s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org,
	b35083-KZfg59tc24xl57MIdRCFDg@public.gmane.org,
	fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org,
	jg1.han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
	yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH -next] i2c: imx: add missing clk_disable_unprepare() on error path
Date: Fri, 20 Dec 2013 18:40:06 +0100	[thread overview]
Message-ID: <20131220174006.GB9997@katana> (raw)
In-Reply-To: <CAPgLHd-zvCacvi5gN-PSqow5-NujhwtXa2RcnNQvorMmAEucrw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 2110 bytes --]

On Sat, Dec 14, 2013 at 10:26:10PM +0800, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY@public.gmane.org>
> 
> Add the missing clk_disable_unprepare() before return in
> the error handling cases.
> 
> Signed-off-by: Wei Yongjun <yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY@public.gmane.org>
> ---
>  drivers/i2c/busses/i2c-imx.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index d0cfbb4..e62f3be 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -328,8 +328,10 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx)
>  	temp |= I2CR_MSTA;
>  	imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
>  	result = i2c_imx_bus_busy(i2c_imx, 1);
> -	if (result)
> +	if (result) {
> +		clk_disable_unprepare(i2c_imx->clk);
>  		return result;
> +	}
>  	i2c_imx->stopped = 0;

Nice catch, but that is not enough. The logic between i2x_imx_start and
*_stop is still broken. *_start may return with clocks enabled or not
while stop will unconditionally disables them.


>  
>  	temp |= I2CR_IIEN | I2CR_MTX | I2CR_TXAK;
> @@ -654,7 +656,7 @@ static int i2c_imx_probe(struct platform_device *pdev)
>  				pdev->name, i2c_imx);
>  	if (ret) {
>  		dev_err(&pdev->dev, "can't claim irq %d\n", irq);
> -		return ret;
> +		goto err_out;
>  	}
>  
>  	/* Init queue */
> @@ -680,7 +682,7 @@ static int i2c_imx_probe(struct platform_device *pdev)
>  	ret = i2c_add_numbered_adapter(&i2c_imx->adapter);
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "registration failed\n");
> -		return ret;
> +		goto err_out;
>  	}
>  
>  	/* Set up platform driver data */
> @@ -697,6 +699,9 @@ static int i2c_imx_probe(struct platform_device *pdev)
>  	dev_info(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n");
>  
>  	return 0;   /* Return OK */
> +err_out:
> +	clk_disable_unprepare(i2c_imx->clk);
> +	return ret;

Why not just enabling the clocks around the small codeblock that needs
them?


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

      parent reply	other threads:[~2013-12-20 17:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-14 14:26 [PATCH -next] i2c: imx: add missing clk_disable_unprepare() on error path Wei Yongjun
     [not found] ` <CAPgLHd-zvCacvi5gN-PSqow5-NujhwtXa2RcnNQvorMmAEucrw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-12-20 17:40   ` Wolfram Sang [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=20131220174006.GB9997@katana \
    --to=wsa-z923lk4zbo2bacvfa/9k2g@public.gmane.org \
    --cc=arnaud.patard-dQbF7i+pzddAfugRpC6u6w@public.gmane.org \
    --cc=b35083-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=jg1.han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=weiyj.lk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox