mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-14 15:54:15 +08:00
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>
This commit is contained in:
parent
f6d4fb5cc0
commit
57a4a3d7f7
@ -4,6 +4,7 @@
|
|||||||
* Copyright (c) 2000 Eric Brower (ebrower@usa.net)
|
* Copyright (c) 2000 Eric Brower (ebrower@usa.net)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <linux/device.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
@ -180,7 +181,7 @@ static int d7s_probe(struct platform_device *op)
|
|||||||
if (d7s_device)
|
if (d7s_device)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
p = kzalloc(sizeof(*p), GFP_KERNEL);
|
p = devm_kzalloc(&op->dev, sizeof(*p), GFP_KERNEL);
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
if (!p)
|
if (!p)
|
||||||
goto out;
|
goto out;
|
||||||
@ -231,7 +232,6 @@ out_iounmap:
|
|||||||
of_iounmap(&op->resource[0], p->regs, sizeof(u8));
|
of_iounmap(&op->resource[0], p->regs, sizeof(u8));
|
||||||
|
|
||||||
out_free:
|
out_free:
|
||||||
kfree(p);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +251,6 @@ static int d7s_remove(struct platform_device *op)
|
|||||||
|
|
||||||
misc_deregister(&d7s_miscdev);
|
misc_deregister(&d7s_miscdev);
|
||||||
of_iounmap(&op->resource[0], p->regs, sizeof(u8));
|
of_iounmap(&op->resource[0], p->regs, sizeof(u8));
|
||||||
kfree(p);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user