lkml.org 
[lkml]   [2016]   [Nov]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Mfd: used devm_kzalloc in place of kzalloc
Switch to resource-managed function devm_kzalloc instead
of kzalloc and remove unneeded kzfree

Remove kfree in probe function and remove
function as it is now has nothing to do

The Coccinelle semantic patch used to make this change is as follows:
//<smpl>
@platform@
identifier p, probefn, removefn;
@@

struct platform_driver p = {
.probe = probefn,
.remove = removefn,
};
@prb@
identifier platform.probefn, pdev;
expression e, e1, e2,x;
@@
probefn(struct platform_device *pdev, ...) {
... when != x = f(...);
- e = kzalloc(e1, e2)
+ e = devm_kzalloc(&pdev->dev, e1, e2)
...
-kfree(e);
... when != g(...);

}
@rem depends on prb@
identifier platform.removefn;
expression prb.e;
@@
removefn(...) {
<...
- kfree(e);
...>
}
//</smpl>

Signed-off-by: Nadim Almas <nadim.902@gmail.com>
---
drivers/mfd/t7l66xb.c | 4 +---
drivers/mfd/tc6387xb.c | 4 +---
drivers/mfd/tc6393xb.c | 4 +---
3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/t7l66xb.c b/drivers/mfd/t7l66xb.c
index 94bd89c..9a2086b 100644
--- a/drivers/mfd/t7l66xb.c
+++ b/drivers/mfd/t7l66xb.c
@@ -317,7 +317,7 @@ static int t7l66xb_probe(struct platform_device *dev)
if (!iomem)
return -EINVAL;

- t7l66xb = kzalloc(sizeof *t7l66xb, GFP_KERNEL);
+ t7l66xb = devm_kzalloc(&dev->dev, sizeof(*t7l66xb), GFP_KERNEL);
if (!t7l66xb)
return -ENOMEM;

@@ -395,7 +395,6 @@ static int t7l66xb_probe(struct platform_device *dev)
clk_put(t7l66xb->clk32k);
err_clk32k_get:
err_noirq:
- kfree(t7l66xb);
return ret;
}

@@ -414,7 +413,6 @@ static int t7l66xb_remove(struct platform_device *dev)
iounmap(t7l66xb->scr);
release_resource(&t7l66xb->rscr);
mfd_remove_devices(&dev->dev);
- kfree(t7l66xb);

return ret;

diff --git a/drivers/mfd/tc6387xb.c b/drivers/mfd/tc6387xb.c
index 85fab37..aaab422 100644
--- a/drivers/mfd/tc6387xb.c
+++ b/drivers/mfd/tc6387xb.c
@@ -150,7 +150,7 @@ static int tc6387xb_probe(struct platform_device *dev)
if (!iomem)
return -EINVAL;

- tc6387xb = kzalloc(sizeof(*tc6387xb), GFP_KERNEL);
+ tc6387xb = devm_kzalloc(&dev->dev, sizeof(*tc6387xb), GFP_KERNEL);
if (!tc6387xb)
return -ENOMEM;

@@ -203,7 +203,6 @@ static int tc6387xb_probe(struct platform_device *dev)
clk_put(clk32k);
err_no_clk:
err_no_irq:
- kfree(tc6387xb);
return ret;
}

@@ -216,7 +215,6 @@ static int tc6387xb_remove(struct platform_device *dev)
release_resource(&tc6387xb->rscr);
clk_disable_unprepare(tc6387xb->clk32k);
clk_put(tc6387xb->clk32k);
- kfree(tc6387xb);

return 0;
}
diff --git a/drivers/mfd/tc6393xb.c b/drivers/mfd/tc6393xb.c
index d42d322..bdb48e0 100644
--- a/drivers/mfd/tc6393xb.c
+++ b/drivers/mfd/tc6393xb.c
@@ -622,7 +622,7 @@ static int tc6393xb_probe(struct platform_device *dev)
if (!iomem)
return -EINVAL;

- tc6393xb = kzalloc(sizeof *tc6393xb, GFP_KERNEL);
+ tc6393xb = devm_kzalloc(&dev->dev, sizeof(*tc6393xb), GFP_KERNEL);
if (!tc6393xb) {
ret = -ENOMEM;
goto err_kzalloc;
@@ -735,7 +735,6 @@ static int tc6393xb_probe(struct platform_device *dev)
clk_put(tc6393xb->clk);
err_noirq:
err_clk_get:
- kfree(tc6393xb);
err_kzalloc:
return ret;
}
@@ -761,7 +760,6 @@ static int tc6393xb_remove(struct platform_device *dev)
iounmap(tc6393xb->scr);
release_resource(&tc6393xb->rscr);
clk_put(tc6393xb->clk);
- kfree(tc6393xb);

return ret;
}
--
2.7.4
\
 
 \ /
  Last update: 2016-11-05 20:24    [W:0.029 / U:0.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site