Patchwork mtd: gpmi: Use devm_kzalloc()

login
register
mail settings
Submitter Fabio Estevam
Date Nov. 5, 2013, 2:07 a.m.
Message ID <1383617225-8504-1-git-send-email-festevam@gmail.com>
Download mbox | patch
Permalink /patch/288358/
State New
Headers show

Comments

Fabio Estevam - Nov. 5, 2013, 2:07 a.m.
From: Fabio Estevam <fabio.estevam@freescale.com>

Using devm_kzalloc() can make the code simpler.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Huang Shijie - Nov. 5, 2013, 2:49 a.m.
于 2013年11月05日 10:07, Fabio Estevam 写道:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> Using devm_kzalloc() can make the code simpler.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> index 7ac2280..4b6d802 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> @@ -1732,7 +1732,7 @@ static int gpmi_nand_probe(struct platform_device *pdev)
>  		return -ENODEV;
>  	}
>  
> -	this = kzalloc(sizeof(*this), GFP_KERNEL);
> +	this = devm_kzalloc(&pdev->dev, sizeof(*this), GFP_KERNEL);
>  	if (!this) {
>  		pr_err("Failed to allocate per-device memory\n");
>  		return -ENOMEM;
> @@ -1762,7 +1762,6 @@ exit_nfc_init:
>  	release_resources(this);
>  exit_acquire_resources:
>  	dev_err(this->dev, "driver registration failed: %d\n", ret);
> -	kfree(this);
>  
>  	return ret;
>  }
> @@ -1773,7 +1772,6 @@ static int gpmi_nand_remove(struct platform_device *pdev)
>  
>  	gpmi_nfc_exit(this);
>  	release_resources(this);
> -	kfree(this);
>  	return 0;
>  }
>  

thanks!

Acked-by: Huang Shijie <b32955@freescale.com>
Brian Norris - Nov. 7, 2013, 6:40 p.m.
On Tue, Nov 05, 2013 at 12:07:05AM -0200, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Using devm_kzalloc() can make the code simpler.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Thanks, pushed to l2-mtd.git.

Brian

Patch

diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 7ac2280..4b6d802 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -1732,7 +1732,7 @@  static int gpmi_nand_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	this = kzalloc(sizeof(*this), GFP_KERNEL);
+	this = devm_kzalloc(&pdev->dev, sizeof(*this), GFP_KERNEL);
 	if (!this) {
 		pr_err("Failed to allocate per-device memory\n");
 		return -ENOMEM;
@@ -1762,7 +1762,6 @@  exit_nfc_init:
 	release_resources(this);
 exit_acquire_resources:
 	dev_err(this->dev, "driver registration failed: %d\n", ret);
-	kfree(this);
 
 	return ret;
 }
@@ -1773,7 +1772,6 @@  static int gpmi_nand_remove(struct platform_device *pdev)
 
 	gpmi_nfc_exit(this);
 	release_resources(this);
-	kfree(this);
 	return 0;
 }