diff options
author | Himangi Saraogi <himangi774@gmail.com> | 2014-05-25 06:40:35 -0400 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2014-06-24 03:54:41 -0400 |
commit | 6a902305936b056c6d2467d6c3efdb2a889c3702 (patch) | |
tree | 5f5ce379295a0c8189ed8a46355ffef1c906b97a | |
parent | 8c70f53370a9189afd6f0ee385aee82b8ea54cfc (diff) |
video: msm: 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. Also, linux/device.h is added to make sure the devm_*()
routine declarations are unambiguously available. The function
mddi_dummy_remove is removed as it is no longer required after
removing the kfree. The variable ret is also done away with.
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>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r-- | drivers/video/fbdev/msm/mddi_client_dummy.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/drivers/video/fbdev/msm/mddi_client_dummy.c b/drivers/video/fbdev/msm/mddi_client_dummy.c index f1b0dfcc9717..cdb8f69a5d88 100644 --- a/drivers/video/fbdev/msm/mddi_client_dummy.c +++ b/drivers/video/fbdev/msm/mddi_client_dummy.c | |||
@@ -15,6 +15,7 @@ | |||
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/device.h> | ||
18 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
19 | #include <linux/module.h> | 20 | #include <linux/module.h> |
20 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
@@ -51,8 +52,7 @@ static int mddi_dummy_probe(struct platform_device *pdev) | |||
51 | { | 52 | { |
52 | struct msm_mddi_client_data *client_data = pdev->dev.platform_data; | 53 | struct msm_mddi_client_data *client_data = pdev->dev.platform_data; |
53 | struct panel_info *panel = | 54 | struct panel_info *panel = |
54 | kzalloc(sizeof(struct panel_info), GFP_KERNEL); | 55 | devm_kzalloc(&pdev->dev, sizeof(struct panel_info), GFP_KERNEL); |
55 | int ret; | ||
56 | if (!panel) | 56 | if (!panel) |
57 | return -ENOMEM; | 57 | return -ENOMEM; |
58 | platform_set_drvdata(pdev, panel); | 58 | platform_set_drvdata(pdev, panel); |
@@ -67,24 +67,11 @@ static int mddi_dummy_probe(struct platform_device *pdev) | |||
67 | client_data->fb_resource, 1); | 67 | client_data->fb_resource, 1); |
68 | panel->panel_data.fb_data = client_data->private_client_data; | 68 | panel->panel_data.fb_data = client_data->private_client_data; |
69 | panel->pdev.dev.platform_data = &panel->panel_data; | 69 | panel->pdev.dev.platform_data = &panel->panel_data; |
70 | ret = platform_device_register(&panel->pdev); | 70 | return platform_device_register(&panel->pdev); |
71 | if (ret) { | ||
72 | kfree(panel); | ||
73 | return ret; | ||
74 | } | ||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | static int mddi_dummy_remove(struct platform_device *pdev) | ||
79 | { | ||
80 | struct panel_info *panel = platform_get_drvdata(pdev); | ||
81 | kfree(panel); | ||
82 | return 0; | ||
83 | } | 71 | } |
84 | 72 | ||
85 | static struct platform_driver mddi_client_dummy = { | 73 | static struct platform_driver mddi_client_dummy = { |
86 | .probe = mddi_dummy_probe, | 74 | .probe = mddi_dummy_probe, |
87 | .remove = mddi_dummy_remove, | ||
88 | .driver = { .name = "mddi_c_dummy" }, | 75 | .driver = { .name = "mddi_c_dummy" }, |
89 | }; | 76 | }; |
90 | 77 | ||