linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] msm: msm_fb: Add remove function for platform driver for clean unloading
@ 2014-08-04 14:55 Pramod Gurav
  2014-08-26 11:19 ` Tomi Valkeinen
  0 siblings, 1 reply; 2+ messages in thread
From: Pramod Gurav @ 2014-08-04 14:55 UTC (permalink / raw)
  To: linux-fbdev, linux-kernel
  Cc: Pramod Gurav, Jean-Christophe Plagniol-Villard, Tomi Valkeinen,
	Stephen Boyd, Jingoo Han, Rob Clark

This adds a  remove function to platform driver structure so that
resources are released when driver is unloaded.

Moved kzalloc to use managed resource and adds a return check if failed.

CC: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
CC: Tomi Valkeinen <tomi.valkeinen@ti.com>
CC: Stephen Boyd <sboyd@codeaurora.org>
CC: Jingoo Han <jg1.han@samsung.com>
CC: Rob Clark <robdclark@gmail.com>

Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
---
 drivers/video/fbdev/msm/msm_fb.c |   28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/msm/msm_fb.c b/drivers/video/fbdev/msm/msm_fb.c
index 1374803..ac277e2 100644
--- a/drivers/video/fbdev/msm/msm_fb.c
+++ b/drivers/video/fbdev/msm/msm_fb.c
@@ -553,6 +553,7 @@ static int msmfb_probe(struct platform_device *pdev)
 	fb = framebuffer_alloc(sizeof(struct msmfb_info), &pdev->dev);
 	if (!fb)
 		return -ENOMEM;
+
 	msmfb = fb->par;
 	msmfb->fb = fb;
 	msmfb->panel = panel;
@@ -569,8 +570,13 @@ static int msmfb_probe(struct platform_device *pdev)
 	mutex_init(&msmfb->panel_init_lock);
 	init_waitqueue_head(&msmfb->frame_wq);
 	INIT_WORK(&msmfb->resume_work, power_on_panel);
-	msmfb->black = kzalloc(msmfb->fb->var.bits_per_pixel*msmfb->xres,
-			       GFP_KERNEL);
+	msmfb->black = devm_kzalloc(&pdev->dev,
+				    msmfb->fb->var.bits_per_pixel*msmfb->xres,
+				    GFP_KERNEL);
+	if (!msmfb->black) {
+		ret = -ENOMEM;
+		goto error_register_framebuffer;
+	}
 
 	printk(KERN_INFO "msmfb_probe() installing %d x %d panel\n",
 	       msmfb->xres, msmfb->yres);
@@ -589,6 +595,8 @@ static int msmfb_probe(struct platform_device *pdev)
 
 	msmfb->sleeping = WAKING;
 
+	platform_set_drvdata(pdev, msmfb);
+
 	return 0;
 
 error_register_framebuffer:
@@ -598,13 +606,27 @@ error_setup_fbmem:
 	return ret;
 }
 
+static int msmfb_remove(struct platform_device *pdev)
+{
+	struct msmfb_info *msmfb = NULL;
+
+	msmfb = platform_get_drvdata(pdev);
+	if (msmfb) {
+		unregister_framebuffer(msmfb->fb);
+		iounmap(msmfb->fb->screen_base);
+		framebuffer_release(msmfb->fb);
+	}
+
+	return 0;
+}
+
 static struct platform_driver msm_panel_driver = {
 	/* need to write remove */
 	.probe = msmfb_probe,
+	.remove = msmfb_remove,
 	.driver = {.name = "msm_panel"},
 };
 
-
 static int msmfb_add_mdp_device(struct device *dev,
 				struct class_interface *class_intf)
 {
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] msm: msm_fb: Add remove function for platform driver for clean unloading
  2014-08-04 14:55 [PATCH] msm: msm_fb: Add remove function for platform driver for clean unloading Pramod Gurav
@ 2014-08-26 11:19 ` Tomi Valkeinen
  0 siblings, 0 replies; 2+ messages in thread
From: Tomi Valkeinen @ 2014-08-26 11:19 UTC (permalink / raw)
  To: Pramod Gurav, linux-fbdev, linux-kernel
  Cc: Jean-Christophe Plagniol-Villard, Stephen Boyd, Jingoo Han,
	Rob Clark

[-- Attachment #1: Type: text/plain, Size: 2624 bytes --]

Hi,

On 04/08/14 17:43, Pramod Gurav wrote:
> This adds a  remove function to platform driver structure so that
> resources are released when driver is unloaded.
> 
> Moved kzalloc to use managed resource and adds a return check if failed.

Please split this patch into two. You change two unrelated things here,
the unloading and the kzalloc part.

> CC: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
> CC: Tomi Valkeinen <tomi.valkeinen@ti.com>
> CC: Stephen Boyd <sboyd@codeaurora.org>
> CC: Jingoo Han <jg1.han@samsung.com>
> CC: Rob Clark <robdclark@gmail.com>
> 
> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
> ---
>  drivers/video/fbdev/msm/msm_fb.c |   28 +++++++++++++++++++++++++---
>  1 file changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/video/fbdev/msm/msm_fb.c b/drivers/video/fbdev/msm/msm_fb.c
> index 1374803..ac277e2 100644
> --- a/drivers/video/fbdev/msm/msm_fb.c
> +++ b/drivers/video/fbdev/msm/msm_fb.c
> @@ -553,6 +553,7 @@ static int msmfb_probe(struct platform_device *pdev)
>  	fb = framebuffer_alloc(sizeof(struct msmfb_info), &pdev->dev);
>  	if (!fb)
>  		return -ENOMEM;
> +
>  	msmfb = fb->par;
>  	msmfb->fb = fb;
>  	msmfb->panel = panel;
> @@ -569,8 +570,13 @@ static int msmfb_probe(struct platform_device *pdev)
>  	mutex_init(&msmfb->panel_init_lock);
>  	init_waitqueue_head(&msmfb->frame_wq);
>  	INIT_WORK(&msmfb->resume_work, power_on_panel);
> -	msmfb->black = kzalloc(msmfb->fb->var.bits_per_pixel*msmfb->xres,
> -			       GFP_KERNEL);
> +	msmfb->black = devm_kzalloc(&pdev->dev,
> +				    msmfb->fb->var.bits_per_pixel*msmfb->xres,
> +				    GFP_KERNEL);
> +	if (!msmfb->black) {
> +		ret = -ENOMEM;
> +		goto error_register_framebuffer;
> +	}
>  
>  	printk(KERN_INFO "msmfb_probe() installing %d x %d panel\n",
>  	       msmfb->xres, msmfb->yres);
> @@ -589,6 +595,8 @@ static int msmfb_probe(struct platform_device *pdev)
>  
>  	msmfb->sleeping = WAKING;
>  
> +	platform_set_drvdata(pdev, msmfb);
> +
>  	return 0;
>  
>  error_register_framebuffer:
> @@ -598,13 +606,27 @@ error_setup_fbmem:
>  	return ret;
>  }
>  
> +static int msmfb_remove(struct platform_device *pdev)
> +{
> +	struct msmfb_info *msmfb = NULL;

No need to initialize to NULL, msmfb is initialized always below.

> +
> +	msmfb = platform_get_drvdata(pdev);
> +	if (msmfb) {

Can msmfb ever be NULL here? If I'm not mistaken, remove is only called
if the probe had succeeded. And if probe had succeeded, the drvdata is
always set to a proper pointer to msmfb_info.

 Tomi



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-26 11:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-04 14:55 [PATCH] msm: msm_fb: Add remove function for platform driver for clean unloading Pramod Gurav
2014-08-26 11:19 ` Tomi Valkeinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).