public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma: mxs-dma: Convert to devm_ioremap_resource()
@ 2013-03-11 23:50 Fabio Estevam
  2013-03-12 12:04 ` Shawn Guo
  0 siblings, 1 reply; 3+ messages in thread
From: Fabio Estevam @ 2013-03-11 23:50 UTC (permalink / raw)
  To: vinod.koul; +Cc: shawn.guo, linux-kernel, Fabio Estevam

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

Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 drivers/dma/mxs-dma.c |   18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index 8f6d30d..8a9939e4 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -689,16 +689,9 @@ static int __init mxs_dma_probe(struct platform_device *pdev)
 	mxs_dma->dev_id = dma_type->id;
 
 	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
-	if (!request_mem_region(iores->start, resource_size(iores),
-				pdev->name)) {
-		ret = -EBUSY;
-		goto err_request_region;
-	}
-
-	mxs_dma->base = ioremap(iores->start, resource_size(iores));
-	if (!mxs_dma->base) {
-		ret = -ENOMEM;
+	mxs_dma->base = devm_ioremap_resource(&pdev->dev, iores);
+	if (IS_ERR(mxs_dma->base)) {
+		ret = PTR_ERR(mxs_dma->base);
 		goto err_ioremap;
 	}
 
@@ -761,10 +754,7 @@ static int __init mxs_dma_probe(struct platform_device *pdev)
 err_init:
 	clk_put(mxs_dma->clk);
 err_clk:
-	iounmap(mxs_dma->base);
-err_ioremap:
-	release_mem_region(iores->start, resource_size(iores));
-err_request_region:
+err_ioremap:
 	kfree(mxs_dma);
 	return ret;
 }
-- 
1.7.9.5


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

* Re: [PATCH] dma: mxs-dma: Convert to devm_ioremap_resource()
  2013-03-11 23:50 [PATCH] dma: mxs-dma: Convert to devm_ioremap_resource() Fabio Estevam
@ 2013-03-12 12:04 ` Shawn Guo
  2013-03-12 12:14   ` Shawn Guo
  0 siblings, 1 reply; 3+ messages in thread
From: Shawn Guo @ 2013-03-12 12:04 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: vinod.koul, linux-kernel

On Mon, Mar 11, 2013 at 08:50:33PM -0300, Fabio Estevam wrote:
> 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 <festevam@gmail.com>
> ---
>  drivers/dma/mxs-dma.c |   18 ++++--------------
>  1 file changed, 4 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
> index 8f6d30d..8a9939e4 100644
> --- a/drivers/dma/mxs-dma.c
> +++ b/drivers/dma/mxs-dma.c
> @@ -689,16 +689,9 @@ static int __init mxs_dma_probe(struct platform_device *pdev)
>  	mxs_dma->dev_id = dma_type->id;
>  
>  	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -
> -	if (!request_mem_region(iores->start, resource_size(iores),
> -				pdev->name)) {
> -		ret = -EBUSY;
> -		goto err_request_region;
> -	}
> -
> -	mxs_dma->base = ioremap(iores->start, resource_size(iores));
> -	if (!mxs_dma->base) {
> -		ret = -ENOMEM;
> +	mxs_dma->base = devm_ioremap_resource(&pdev->dev, iores);
> +	if (IS_ERR(mxs_dma->base)) {
> +		ret = PTR_ERR(mxs_dma->base);
>  		goto err_ioremap;
>  	}
>  
> @@ -761,10 +754,7 @@ static int __init mxs_dma_probe(struct platform_device *pdev)
>  err_init:
>  	clk_put(mxs_dma->clk);
>  err_clk:
> -	iounmap(mxs_dma->base);
> -err_ioremap:
> -	release_mem_region(iores->start, resource_size(iores));
> -err_request_region:
> +err_ioremap:
>  	kfree(mxs_dma);
>  	return ret;
>  }
> -- 
> 1.7.9.5
> 


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

* Re: [PATCH] dma: mxs-dma: Convert to devm_ioremap_resource()
  2013-03-12 12:04 ` Shawn Guo
@ 2013-03-12 12:14   ` Shawn Guo
  0 siblings, 0 replies; 3+ messages in thread
From: Shawn Guo @ 2013-03-12 12:14 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: vinod.koul, linux-kernel

On 12 March 2013 20:04, Shawn Guo <shawn.guo@linaro.org> wrote:
> On Mon, Mar 11, 2013 at 08:50:33PM -0300, Fabio Estevam wrote:
>> 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.
>
I even forgot to mention that I already had a patch [1] doing that.

Shawn

[1] http://thread.gmane.org/gmane.linux.alsa.devel/106027/focus=220812

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

end of thread, other threads:[~2013-03-12 12:14 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:50 [PATCH] dma: mxs-dma: Convert to devm_ioremap_resource() Fabio Estevam
2013-03-12 12:04 ` Shawn Guo
2013-03-12 12:14   ` Shawn Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox