* [PATCH -next] i2c: imx: add missing clk_disable_unprepare() on error path
@ 2013-12-14 14:26 Wei Yongjun
[not found] ` <CAPgLHd-zvCacvi5gN-PSqow5-NujhwtXa2RcnNQvorMmAEucrw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2013-12-14 14:26 UTC (permalink / raw)
To: wsa-z923LK4zBo2bacvFa/9K2g, grant.likely-QSEj5FYQhm4dnm+yROfE0A,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
arnaud.patard-dQbF7i+pzddAfugRpC6u6w,
s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ, b35083-KZfg59tc24xl57MIdRCFDg,
fabio.estevam-KZfg59tc24xl57MIdRCFDg,
jg1.han-Sze3O3UU22JBDgjK7y7TUQ
Cc: yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY,
linux-i2c-u79uwXL29TY76Z2rM5mHXA
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;
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;
}
static int i2c_imx_remove(struct platform_device *pdev)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] i2c: imx: add missing clk_disable_unprepare() on error path
[not found] ` <CAPgLHd-zvCacvi5gN-PSqow5-NujhwtXa2RcnNQvorMmAEucrw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-12-20 17:40 ` Wolfram Sang
0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2013-12-20 17:40 UTC (permalink / raw)
To: Wei Yongjun
Cc: grant.likely-QSEj5FYQhm4dnm+yROfE0A,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
arnaud.patard-dQbF7i+pzddAfugRpC6u6w,
s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ, b35083-KZfg59tc24xl57MIdRCFDg,
fabio.estevam-KZfg59tc24xl57MIdRCFDg,
jg1.han-Sze3O3UU22JBDgjK7y7TUQ,
yongjun_wei-zrsr2BFq86L20UzCJQGyNP8+0UxHXcjY,
linux-i2c-u79uwXL29TY76Z2rM5mHXA
[-- 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 --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-12-20 17:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).