Skip to contentSkip to conversation

mtd: gpmi: Use devm_kzalloc()

PATCH In review Fabio Estevam 3 participants 3 messages Nov 5, 2013 – Nov 7, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: gpmi: Use devm_kzalloc()

From: Fabio Estevam <[email protected]>

Using devm_kzalloc() can make the code simpler.

---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +1 -3
index 7ac2280..4b6d802 100644
@@ -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;
 }
 
Signature · 1 line
1.8.1.2
Acked-by on v1 1/1
#1 lore raw
Quoted 31 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Using devm_kzalloc() can make the code simpler.

---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +1 -2
index 7ac2280..4b6d802 100644
@@ -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;
 }

drivers/mtd/nand/gpmi-nand/gpmi-nand.c static int gpmi_nand_remove(struct platform_device *pdev) · line 1777

Quoted 7 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +0 -1
@@ -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!