aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/sbus/char/display7seg.c
diff options
context:
space:
mode:
authorHimangi Saraogi <himangi774@gmail.com>2014-05-26 17:32:07 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-22 00:37:05 -0400
commit57a4a3d7f7568c487d5db3e26540bff958000255 (patch)
tree447f335c094aace4df79f0e503742b1904fe544d /drivers/sbus/char/display7seg.c
parentf6d4fb5cc0475c36437a618db31cbb7f2bf7c282 (diff)
display7seg: Introduce the use of the managed version of kzalloc
This patch moves data allocated using kzalloc to managed data allocated using devm_kzalloc and cleans now unnecessary kfrees in probe and remove functions. The header file is added to make the devm function explicitly available. The following Coccinelle semantic patch was used for making a part of the change: @platform@ identifier p, probefn, removefn; @@ struct platform_driver p = { .probe = probefn, .remove = removefn, }; @prb@ identifier platform.probefn, pdev; expression e, e1, e2; @@ probefn(struct platform_device *pdev, ...) { <+... - e = kzalloc(e1, e2) + e = devm_kzalloc(&pdev->dev, e1, e2) ... ?-kfree(e); ...+> } @rem depends on prb@ identifier platform.removefn; expression e; @@ removefn(...) { <... - kfree(e); ...> } Signed-off-by: Himangi Saraogi <himangi774@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Acked-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/sbus/char/display7seg.c')
-rw-r--r--drivers/sbus/char/display7seg.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c
index 7c71e7b4febf..b48899ce8506 100644
--- a/drivers/sbus/char/display7seg.c
+++ b/drivers/sbus/char/display7seg.c
@@ -4,6 +4,7 @@
4 * Copyright (c) 2000 Eric Brower (ebrower@usa.net) 4 * Copyright (c) 2000 Eric Brower (ebrower@usa.net)
5 */ 5 */
6 6
7#include <linux/device.h>
7#include <linux/kernel.h> 8#include <linux/kernel.h>
8#include <linux/module.h> 9#include <linux/module.h>
9#include <linux/fs.h> 10#include <linux/fs.h>
@@ -180,7 +181,7 @@ static int d7s_probe(struct platform_device *op)
180 if (d7s_device) 181 if (d7s_device)
181 goto out; 182 goto out;
182 183
183 p = kzalloc(sizeof(*p), GFP_KERNEL); 184 p = devm_kzalloc(&op->dev, sizeof(*p), GFP_KERNEL);
184 err = -ENOMEM; 185 err = -ENOMEM;
185 if (!p) 186 if (!p)
186 goto out; 187 goto out;
@@ -231,7 +232,6 @@ out_iounmap:
231 of_iounmap(&op->resource[0], p->regs, sizeof(u8)); 232 of_iounmap(&op->resource[0], p->regs, sizeof(u8));
232 233
233out_free: 234out_free:
234 kfree(p);
235 goto out; 235 goto out;
236} 236}
237 237
@@ -251,7 +251,6 @@ static int d7s_remove(struct platform_device *op)
251 251
252 misc_deregister(&d7s_miscdev); 252 misc_deregister(&d7s_miscdev);
253 of_iounmap(&op->resource[0], p->regs, sizeof(u8)); 253 of_iounmap(&op->resource[0], p->regs, sizeof(u8));
254 kfree(p);
255 254
256 return 0; 255 return 0;
257} 256}