All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
To: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: kernel-janitors@vger.kernel.org, linux-fbdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers/video/pxa168fb.c: use devm_ functions
Date: Tue, 28 Feb 2012 15:54:59 +0000	[thread overview]
Message-ID: <4F4CF8D3.2090007@gmx.de> (raw)
In-Reply-To: <1329589169-18235-1-git-send-email-Julia.Lawall@lip6.fr>

On 02/18/2012 06:19 PM, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> The various devm_ functions allocate memory that is released when a driver
> detaches.  This patch uses these functions for data that is allocated in
> the probe function of a platform device and is only freed in the remove
> function.
> 
> By using devm_ioremap, it also removes a potential memory leak, because
> there was no call to iounmap in the probe function.
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Applied.


Thanks,

Florian Tobias Schandinat

> 
> ---
>  drivers/video/pxa168fb.c |   15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
> index 8384b94..f146089 100644
> --- a/drivers/video/pxa168fb.c
> +++ b/drivers/video/pxa168fb.c
> @@ -21,6 +21,7 @@
>  #include <linux/fb.h>
>  #include <linux/delay.h>
>  #include <linux/init.h>
> +#include <linux/io.h>
>  #include <linux/ioport.h>
>  #include <linux/platform_device.h>
>  #include <linux/dma-mapping.h>
> @@ -670,7 +671,8 @@ static int __devinit pxa168fb_probe(struct platform_device *pdev)
>  	/*
>  	 * Map LCD controller registers.
>  	 */
> -	fbi->reg_base = ioremap_nocache(res->start, resource_size(res));
> +	fbi->reg_base = devm_ioremap_nocache(&pdev->dev, res->start,
> +					     resource_size(res));
>  	if (fbi->reg_base = NULL) {
>  		ret = -ENOMEM;
>  		goto failed_free_info;
> @@ -739,8 +741,8 @@ static int __devinit pxa168fb_probe(struct platform_device *pdev)
>  	/*
>  	 * Register irq handler.
>  	 */
> -	ret = request_irq(irq, pxa168fb_handle_irq, IRQF_SHARED,
> -					info->fix.id, fbi);
> +	ret = devm_request_irq(&pdev->dev, irq, pxa168fb_handle_irq,
> +			       IRQF_SHARED, info->fix.id, fbi);
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "unable to request IRQ\n");
>  		ret = -ENXIO;
> @@ -759,14 +761,12 @@ static int __devinit pxa168fb_probe(struct platform_device *pdev)
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "Failed to register pxa168-fb: %d\n", ret);
>  		ret = -ENXIO;
> -		goto failed_free_irq;
> +		goto failed_free_cmap;
>  	}
>  
>  	platform_set_drvdata(pdev, fbi);
>  	return 0;
>  
> -failed_free_irq:
> -	free_irq(irq, fbi);
>  failed_free_cmap:
>  	fb_dealloc_cmap(&info->cmap);
>  failed_free_clk:
> @@ -808,13 +808,10 @@ static int __devexit pxa168fb_remove(struct platform_device *pdev)
>  		fb_dealloc_cmap(&info->cmap);
>  
>  	irq = platform_get_irq(pdev, 0);
> -	free_irq(irq, fbi);
>  
>  	dma_free_writecombine(fbi->dev, PAGE_ALIGN(info->fix.smem_len),
>  				info->screen_base, info->fix.smem_start);
>  
> -	iounmap(fbi->reg_base);
> -
>  	clk_disable(fbi->clk);
>  	clk_put(fbi->clk);
>  
> 
> 


WARNING: multiple messages have this Message-ID (diff)
From: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
To: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: kernel-janitors@vger.kernel.org, linux-fbdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers/video/pxa168fb.c: use devm_ functions
Date: Tue, 28 Feb 2012 15:54:59 +0000	[thread overview]
Message-ID: <4F4CF8D3.2090007@gmx.de> (raw)
In-Reply-To: <1329589169-18235-1-git-send-email-Julia.Lawall@lip6.fr>

On 02/18/2012 06:19 PM, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> The various devm_ functions allocate memory that is released when a driver
> detaches.  This patch uses these functions for data that is allocated in
> the probe function of a platform device and is only freed in the remove
> function.
> 
> By using devm_ioremap, it also removes a potential memory leak, because
> there was no call to iounmap in the probe function.
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Applied.


Thanks,

Florian Tobias Schandinat

> 
> ---
>  drivers/video/pxa168fb.c |   15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
> index 8384b94..f146089 100644
> --- a/drivers/video/pxa168fb.c
> +++ b/drivers/video/pxa168fb.c
> @@ -21,6 +21,7 @@
>  #include <linux/fb.h>
>  #include <linux/delay.h>
>  #include <linux/init.h>
> +#include <linux/io.h>
>  #include <linux/ioport.h>
>  #include <linux/platform_device.h>
>  #include <linux/dma-mapping.h>
> @@ -670,7 +671,8 @@ static int __devinit pxa168fb_probe(struct platform_device *pdev)
>  	/*
>  	 * Map LCD controller registers.
>  	 */
> -	fbi->reg_base = ioremap_nocache(res->start, resource_size(res));
> +	fbi->reg_base = devm_ioremap_nocache(&pdev->dev, res->start,
> +					     resource_size(res));
>  	if (fbi->reg_base == NULL) {
>  		ret = -ENOMEM;
>  		goto failed_free_info;
> @@ -739,8 +741,8 @@ static int __devinit pxa168fb_probe(struct platform_device *pdev)
>  	/*
>  	 * Register irq handler.
>  	 */
> -	ret = request_irq(irq, pxa168fb_handle_irq, IRQF_SHARED,
> -					info->fix.id, fbi);
> +	ret = devm_request_irq(&pdev->dev, irq, pxa168fb_handle_irq,
> +			       IRQF_SHARED, info->fix.id, fbi);
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "unable to request IRQ\n");
>  		ret = -ENXIO;
> @@ -759,14 +761,12 @@ static int __devinit pxa168fb_probe(struct platform_device *pdev)
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "Failed to register pxa168-fb: %d\n", ret);
>  		ret = -ENXIO;
> -		goto failed_free_irq;
> +		goto failed_free_cmap;
>  	}
>  
>  	platform_set_drvdata(pdev, fbi);
>  	return 0;
>  
> -failed_free_irq:
> -	free_irq(irq, fbi);
>  failed_free_cmap:
>  	fb_dealloc_cmap(&info->cmap);
>  failed_free_clk:
> @@ -808,13 +808,10 @@ static int __devexit pxa168fb_remove(struct platform_device *pdev)
>  		fb_dealloc_cmap(&info->cmap);
>  
>  	irq = platform_get_irq(pdev, 0);
> -	free_irq(irq, fbi);
>  
>  	dma_free_writecombine(fbi->dev, PAGE_ALIGN(info->fix.smem_len),
>  				info->screen_base, info->fix.smem_start);
>  
> -	iounmap(fbi->reg_base);
> -
>  	clk_disable(fbi->clk);
>  	clk_put(fbi->clk);
>  
> 
> 


  reply	other threads:[~2012-02-28 15:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-18 18:19 [PATCH] drivers/video/pxa168fb.c: use devm_ functions Julia Lawall
2012-02-18 18:19 ` Julia Lawall
2012-02-28 15:54 ` Florian Tobias Schandinat [this message]
2012-02-28 15:54   ` Florian Tobias Schandinat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F4CF8D3.2090007@gmx.de \
    --to=florianschandinat@gmx.de \
    --cc=Julia.Lawall@lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.