diff mbox

[OPW,kernel] video:msm: Introduce the use of the managed version of kzalloc

Message ID 20140227155750.GA6200@himangi-Inspiron-N5110gmail.com
State New, archived
Headers show

Commit Message

HIMANGI SARAOGI Feb. 27, 2014, 3:57 p.m. UTC
This patch moves shared private data kzalloc to managed devm_kzalloc and
cleans now unneccessary kfree in probe and remove functions.

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
---
 drivers/video/msm/mddi_client_dummy.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Julia Lawall Feb. 27, 2014, 4:05 p.m. UTC | #1
>  	if (ret) {
> -		kfree(panel);
>  		return ret;
>  	}
>  	return 0;

This could be simplified.  First, if you adjust an if branch such that
there is only one statement left, you need to remove the surrounding
braces as well.  But actually the entire code shown above can be converted
to one line, if you think about the possible values of ret.

julia
Julia Lawall Feb. 27, 2014, 4:07 p.m. UTC | #2
On Thu, 27 Feb 2014, Julia Lawall wrote:

> >  	if (ret) {
> > -		kfree(panel);
> >  		return ret;
> >  	}
> >  	return 0;
>
> This could be simplified.  First, if you adjust an if branch such that
> there is only one statement left, you need to remove the surrounding
> braces as well.  But actually the entire code shown above can be converted
> to one line, if you think about the possible values of ret.

And actually, you don't even need the ret variable.

The remove function can be simplified down to only one line as well.

julia
diff mbox

Patch

diff --git a/drivers/video/msm/mddi_client_dummy.c b/drivers/video/msm/mddi_client_dummy.c
index f1b0dfc..77b6618 100644
--- a/drivers/video/msm/mddi_client_dummy.c
+++ b/drivers/video/msm/mddi_client_dummy.c
@@ -50,8 +50,9 @@  static int mddi_dummy_unblank(struct msm_panel_data *panel_data)
 static int mddi_dummy_probe(struct platform_device *pdev)
 {
 	struct msm_mddi_client_data *client_data = pdev->dev.platform_data;
-	struct panel_info *panel =
-		kzalloc(sizeof(struct panel_info), GFP_KERNEL);
+	struct panel_info *panel = devm_kzalloc(&pdev->dev,
+						sizeof(struct panel_info),
+						GFP_KERNEL);
 	int ret;
 	if (!panel)
 		return -ENOMEM;
@@ -69,7 +70,6 @@  static int mddi_dummy_probe(struct platform_device *pdev)
 	panel->pdev.dev.platform_data = &panel->panel_data;
 	ret = platform_device_register(&panel->pdev);
 	if (ret) {
-		kfree(panel);
 		return ret;
 	}
 	return 0;
@@ -78,7 +78,6 @@  static int mddi_dummy_probe(struct platform_device *pdev)
 static int mddi_dummy_remove(struct platform_device *pdev)
 {
 	struct panel_info *panel = platform_get_drvdata(pdev);
-	kfree(panel);
 	return 0;
 }