Patchwork [1/2] mtd: mxc_nand: fix unbalanced clk_disable() in error path

login
register
mail settings
Submitter Lothar Waßmann
Date Dec. 6, 2012, 7:42 a.m.
Message ID <1354779748-28869-1-git-send-email-LW@KARO-electronics.de>
Download mbox | patch
Permalink /patch/204168/
State Accepted
Commit c10d8ee3feaf725007e515b5f2972dffaa793f9a
Headers show

Comments

Lothar Waßmann - Dec. 6, 2012, 7:42 a.m.
If nand_scan_ident() or nand_scan_tail() fails, the NAND chip may have
been deselected and the clock already disabled. Thus, check 'clk_act'
in the error path to decide whether the clock still needs to be
disabled.

This fixes a:
|WARNING: at drivers/clk/clk.c:472 __clk_disable+0x3c/0x78()

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 drivers/mtd/nand/mxc_nand.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Sascha Hauer - Dec. 6, 2012, 7:45 a.m.
On Thu, Dec 06, 2012 at 08:42:27AM +0100, Lothar Waßmann wrote:
> If nand_scan_ident() or nand_scan_tail() fails, the NAND chip may have
> been deselected and the clock already disabled. Thus, check 'clk_act'
> in the error path to decide whether the clock still needs to be
> disabled.
> 
> This fixes a:
> |WARNING: at drivers/clk/clk.c:472 __clk_disable+0x3c/0x78()
> 
> Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>

Both: Acked-by: Sascha Hauer <s.hauer@pengutronix.de>

Sascha

> ---
>  drivers/mtd/nand/mxc_nand.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
> index d316324..d965809 100644
> --- a/drivers/mtd/nand/mxc_nand.c
> +++ b/drivers/mtd/nand/mxc_nand.c
> @@ -1556,7 +1556,8 @@ static int mxcnd_probe(struct platform_device *pdev)
>  	return 0;
>  
>  escan:
> -	clk_disable_unprepare(host->clk);
> +	if (host->clk_act)
> +		clk_disable_unprepare(host->clk);
>  
>  	return err;
>  }
> -- 
> 1.7.2.5
> 
>
Artem Bityutskiy - Dec. 10, 2012, 2:46 p.m.
On Thu, 2012-12-06 at 08:42 +0100, Lothar Waßmann wrote:
> If nand_scan_ident() or nand_scan_tail() fails, the NAND chip may have
> been deselected and the clock already disabled. Thus, check 'clk_act'
> in the error path to decide whether the clock still needs to be
> disabled.
> 
> This fixes a:
> |WARNING: at drivers/clk/clk.c:472 __clk_disable+0x3c/0x78()

Pushed to l2-mtd.git, thanks!

Patch

diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index d316324..d965809 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -1556,7 +1556,8 @@  static int mxcnd_probe(struct platform_device *pdev)
 	return 0;
 
 escan:
-	clk_disable_unprepare(host->clk);
+	if (host->clk_act)
+		clk_disable_unprepare(host->clk);
 
 	return err;
 }