linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] video: mxsfb: Convert to devm_ioremap_resource()
@ 2013-03-11 23:52 Fabio Estevam
  2013-03-12 12:06 ` Shawn Guo
  0 siblings, 1 reply; 3+ messages in thread
From: Fabio Estevam @ 2013-03-11 23:52 UTC (permalink / raw)
  To: FlorianSchandinat; +Cc: akpm, shawn.guo, linux-kernel, Fabio Estevam

From: Fabio Estevam <fabio.estevam@freescale.com>

Converting to devm_ioremap_resource() can make the code cleaner and smaller.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/video/mxsfb.c |   19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 755556c..26cbc56 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -801,22 +801,17 @@ static int mxsfb_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	if (!request_mem_region(res->start, resource_size(res), pdev->name))
-		return -EBUSY;
-
 	fb_info = framebuffer_alloc(sizeof(struct mxsfb_info), &pdev->dev);
 	if (!fb_info) {
 		dev_err(&pdev->dev, "Failed to allocate fbdev\n");
-		ret = -ENOMEM;
-		goto error_alloc_info;
+		return -ENOMEM;
 	}
 
 	host = to_imxfb_host(fb_info);
 
-	host->base = ioremap(res->start, resource_size(res));
-	if (!host->base) {
-		dev_err(&pdev->dev, "ioremap failed\n");
-		ret = -ENOMEM;
+	host->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(host->base)) {
+		return PTR_ERR(host->base);
 		goto error_ioremap;
 	}
 
@@ -904,11 +899,8 @@ error_panel_enable:
 	clk_put(host->clk);
 error_getclock:
 error_getpin:
-	iounmap(host->base);
 error_ioremap:
 	framebuffer_release(fb_info);
-error_alloc_info:
-	release_mem_region(res->start, resource_size(res));
 
 	return ret;
 }
@@ -917,7 +909,6 @@ static int mxsfb_remove(struct platform_device *pdev)
 {
 	struct fb_info *fb_info = platform_get_drvdata(pdev);
 	struct mxsfb_info *host = to_imxfb_host(fb_info);
-	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
 	if (host->enabled)
 		mxsfb_disable_controller(fb_info);
@@ -925,11 +916,9 @@ static int mxsfb_remove(struct platform_device *pdev)
 	unregister_framebuffer(fb_info);
 	kfree(fb_info->pseudo_palette);
 	mxsfb_free_videomem(host);
-	iounmap(host->base);
 	clk_put(host->clk);
 
 	framebuffer_release(fb_info);
-	release_mem_region(res->start, resource_size(res));
 
 	platform_set_drvdata(pdev, NULL);
 
-- 
1.7.9.5


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

* Re: [PATCH] video: mxsfb: Convert to devm_ioremap_resource()
  2013-03-11 23:52 [PATCH] video: mxsfb: Convert to devm_ioremap_resource() Fabio Estevam
@ 2013-03-12 12:06 ` Shawn Guo
  2013-03-12 12:29   ` Shawn Guo
  0 siblings, 1 reply; 3+ messages in thread
From: Shawn Guo @ 2013-03-12 12:06 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: FlorianSchandinat, akpm, linux-kernel, Fabio Estevam

On Mon, Mar 11, 2013 at 08:52:17PM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Converting to devm_ioremap_resource() can make the code cleaner and smaller.
> 
While you are there, you may want to use devm_kzalloc() and
devm_clk_get() as well.

Shawn

> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  drivers/video/mxsfb.c |   19 ++++---------------
>  1 file changed, 4 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
> index 755556c..26cbc56 100644
> --- a/drivers/video/mxsfb.c
> +++ b/drivers/video/mxsfb.c
> @@ -801,22 +801,17 @@ static int mxsfb_probe(struct platform_device *pdev)
>  		return -ENODEV;
>  	}
>  
> -	if (!request_mem_region(res->start, resource_size(res), pdev->name))
> -		return -EBUSY;
> -
>  	fb_info = framebuffer_alloc(sizeof(struct mxsfb_info), &pdev->dev);
>  	if (!fb_info) {
>  		dev_err(&pdev->dev, "Failed to allocate fbdev\n");
> -		ret = -ENOMEM;
> -		goto error_alloc_info;
> +		return -ENOMEM;
>  	}
>  
>  	host = to_imxfb_host(fb_info);
>  
> -	host->base = ioremap(res->start, resource_size(res));
> -	if (!host->base) {
> -		dev_err(&pdev->dev, "ioremap failed\n");
> -		ret = -ENOMEM;
> +	host->base = devm_ioremap_resource(&pdev->dev, res);
> +	if (IS_ERR(host->base)) {
> +		return PTR_ERR(host->base);
>  		goto error_ioremap;
>  	}
>  
> @@ -904,11 +899,8 @@ error_panel_enable:
>  	clk_put(host->clk);
>  error_getclock:
>  error_getpin:
> -	iounmap(host->base);
>  error_ioremap:
>  	framebuffer_release(fb_info);
> -error_alloc_info:
> -	release_mem_region(res->start, resource_size(res));
>  
>  	return ret;
>  }
> @@ -917,7 +909,6 @@ static int mxsfb_remove(struct platform_device *pdev)
>  {
>  	struct fb_info *fb_info = platform_get_drvdata(pdev);
>  	struct mxsfb_info *host = to_imxfb_host(fb_info);
> -	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  
>  	if (host->enabled)
>  		mxsfb_disable_controller(fb_info);
> @@ -925,11 +916,9 @@ static int mxsfb_remove(struct platform_device *pdev)
>  	unregister_framebuffer(fb_info);
>  	kfree(fb_info->pseudo_palette);
>  	mxsfb_free_videomem(host);
> -	iounmap(host->base);
>  	clk_put(host->clk);
>  
>  	framebuffer_release(fb_info);
> -	release_mem_region(res->start, resource_size(res));
>  
>  	platform_set_drvdata(pdev, NULL);
>  
> -- 
> 1.7.9.5
> 


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

* Re: [PATCH] video: mxsfb: Convert to devm_ioremap_resource()
  2013-03-12 12:06 ` Shawn Guo
@ 2013-03-12 12:29   ` Shawn Guo
  0 siblings, 0 replies; 3+ messages in thread
From: Shawn Guo @ 2013-03-12 12:29 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: FlorianSchandinat, akpm, linux-kernel, Fabio Estevam

On 12 March 2013 20:06, Shawn Guo <shawn.guo@linaro.org> wrote:
> On Mon, Mar 11, 2013 at 08:52:17PM -0300, Fabio Estevam wrote:
>> From: Fabio Estevam <fabio.estevam@freescale.com>
>>
>> Converting to devm_ioremap_resource() can make the code cleaner and smaller.
>>
> While you are there, you may want to use devm_kzalloc() and
> devm_clk_get() as well.
>
Actually I'm working on a series to convert mxsfb driver to generic
of_videomode bindings, and already had a cleanup patch to move all
these calls to managed functions.  To ease the merge process, I plan
to have the series go via arm-soc tree.

Shawn

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

end of thread, other threads:[~2013-03-12 12:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-11 23:52 [PATCH] video: mxsfb: Convert to devm_ioremap_resource() Fabio Estevam
2013-03-12 12:06 ` Shawn Guo
2013-03-12 12:29   ` Shawn Guo

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).