Patchwork mtd: gpmi: Use devm_clk_get()

login
register
mail settings
Submitter Fabio Estevam
Date Nov. 8, 2013, 12:32 a.m.
Message ID <1383870758-29777-1-git-send-email-festevam@gmail.com>
Download mbox | patch
Permalink /patch/289538/
State New
Headers show

Comments

Fabio Estevam - Nov. 8, 2013, 12:32 a.m.
From: Fabio Estevam <fabio.estevam@freescale.com>

Using devm_clk_get() can make the code smaller and cleaner.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)
Huang Shijie - Nov. 8, 2013, 2:25 a.m.
于 2013年11月08日 08:32, Fabio Estevam 写道:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> Using devm_clk_get() can make the code smaller and cleaner.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 21 ++-------------------
>  1 file changed, 2 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> index 7ac2280..43d25ec 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> @@ -579,21 +579,6 @@ acquire_err:
>  	return -EINVAL;
>  }
>  
> -static void gpmi_put_clks(struct gpmi_nand_data *this)
> -{
> -	struct resources *r = &this->resources;
> -	struct clk *clk;
> -	int i;
> -
> -	for (i = 0; i < GPMI_CLK_MAX; i++) {
> -		clk = r->clock[i];
> -		if (clk) {
> -			clk_put(clk);
> -			r->clock[i] = NULL;
> -		}
> -	}
> -}
> -
>  static char *extra_clks_for_mx6q[GPMI_CLK_MAX] = {
>  	"gpmi_apb", "gpmi_bch", "gpmi_bch_apb", "per1_bch",
>  };
> @@ -606,7 +591,7 @@ static int gpmi_get_clks(struct gpmi_nand_data *this)
>  	int err, i;
>  
>  	/* The main clock is stored in the first. */
> -	r->clock[0] = clk_get(this->dev, "gpmi_io");
> +	r->clock[0] = devm_clk_get(this->dev, "gpmi_io");
>  	if (IS_ERR(r->clock[0])) {
>  		err = PTR_ERR(r->clock[0]);
>  		goto err_clock;
> @@ -622,7 +607,7 @@ static int gpmi_get_clks(struct gpmi_nand_data *this)
>  		if (extra_clks[i - 1] == NULL)
>  			break;
>  
> -		clk = clk_get(this->dev, extra_clks[i - 1]);
> +		clk = devm_clk_get(this->dev, extra_clks[i - 1]);
>  		if (IS_ERR(clk)) {
>  			err = PTR_ERR(clk);
>  			goto err_clock;
> @@ -644,7 +629,6 @@ static int gpmi_get_clks(struct gpmi_nand_data *this)
>  
>  err_clock:
>  	dev_dbg(this->dev, "failed in finding the clocks.\n");
> -	gpmi_put_clks(this);
>  	return err;
>  }
>  
> @@ -684,7 +668,6 @@ exit_regs:
>  
>  static void release_resources(struct gpmi_nand_data *this)
>  {
> -	gpmi_put_clks(this);
>  	release_register_block(this);
>  	release_bch_irq(this);
>  	release_dma_channels(this);
I ever planed to do the gpmi-nand's clean-up myself.

Since you like to do it, i am happy too.

thanks.

Acked-by: Huang Shijie <b32955@freescale.com>
Brian Norris - Nov. 13, 2013, 8:40 p.m.
On Thu, Nov 07, 2013 at 10:32:38PM -0200, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Using devm_clk_get() can make the code smaller and cleaner.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Pushed to l2-mtd.git/next. Thanks!

Brian

Patch

diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 7ac2280..43d25ec 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -579,21 +579,6 @@  acquire_err:
 	return -EINVAL;
 }
 
-static void gpmi_put_clks(struct gpmi_nand_data *this)
-{
-	struct resources *r = &this->resources;
-	struct clk *clk;
-	int i;
-
-	for (i = 0; i < GPMI_CLK_MAX; i++) {
-		clk = r->clock[i];
-		if (clk) {
-			clk_put(clk);
-			r->clock[i] = NULL;
-		}
-	}
-}
-
 static char *extra_clks_for_mx6q[GPMI_CLK_MAX] = {
 	"gpmi_apb", "gpmi_bch", "gpmi_bch_apb", "per1_bch",
 };
@@ -606,7 +591,7 @@  static int gpmi_get_clks(struct gpmi_nand_data *this)
 	int err, i;
 
 	/* The main clock is stored in the first. */
-	r->clock[0] = clk_get(this->dev, "gpmi_io");
+	r->clock[0] = devm_clk_get(this->dev, "gpmi_io");
 	if (IS_ERR(r->clock[0])) {
 		err = PTR_ERR(r->clock[0]);
 		goto err_clock;
@@ -622,7 +607,7 @@  static int gpmi_get_clks(struct gpmi_nand_data *this)
 		if (extra_clks[i - 1] == NULL)
 			break;
 
-		clk = clk_get(this->dev, extra_clks[i - 1]);
+		clk = devm_clk_get(this->dev, extra_clks[i - 1]);
 		if (IS_ERR(clk)) {
 			err = PTR_ERR(clk);
 			goto err_clock;
@@ -644,7 +629,6 @@  static int gpmi_get_clks(struct gpmi_nand_data *this)
 
 err_clock:
 	dev_dbg(this->dev, "failed in finding the clocks.\n");
-	gpmi_put_clks(this);
 	return err;
 }
 
@@ -684,7 +668,6 @@  exit_regs:
 
 static void release_resources(struct gpmi_nand_data *this)
 {
-	gpmi_put_clks(this);
 	release_register_block(this);
 	release_bch_irq(this);
 	release_dma_channels(this);