diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2012-02-18 13:19:29 -0500 |
---|---|---|
committer | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2012-02-23 19:49:59 -0500 |
commit | 640ba2444fa95261f23a2b86e69aabe723332bed (patch) | |
tree | cf82680aca06941eaa2ec121879becfd278b722b /drivers/video/pxa168fb.c | |
parent | 8aaaaf3cbfb96a9f74c5775c71067a9290244ec7 (diff) |
drivers/video/pxa168fb.c: use devm_ functions
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>
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Diffstat (limited to 'drivers/video/pxa168fb.c')
-rw-r--r-- | drivers/video/pxa168fb.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c index 8384b941f6ba..f146089261f4 100644 --- a/drivers/video/pxa168fb.c +++ b/drivers/video/pxa168fb.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/fb.h> | 21 | #include <linux/fb.h> |
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/io.h> | ||
24 | #include <linux/ioport.h> | 25 | #include <linux/ioport.h> |
25 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
26 | #include <linux/dma-mapping.h> | 27 | #include <linux/dma-mapping.h> |
@@ -670,7 +671,8 @@ static int __devinit pxa168fb_probe(struct platform_device *pdev) | |||
670 | /* | 671 | /* |
671 | * Map LCD controller registers. | 672 | * Map LCD controller registers. |
672 | */ | 673 | */ |
673 | fbi->reg_base = ioremap_nocache(res->start, resource_size(res)); | 674 | fbi->reg_base = devm_ioremap_nocache(&pdev->dev, res->start, |
675 | resource_size(res)); | ||
674 | if (fbi->reg_base == NULL) { | 676 | if (fbi->reg_base == NULL) { |
675 | ret = -ENOMEM; | 677 | ret = -ENOMEM; |
676 | goto failed_free_info; | 678 | goto failed_free_info; |
@@ -739,8 +741,8 @@ static int __devinit pxa168fb_probe(struct platform_device *pdev) | |||
739 | /* | 741 | /* |
740 | * Register irq handler. | 742 | * Register irq handler. |
741 | */ | 743 | */ |
742 | ret = request_irq(irq, pxa168fb_handle_irq, IRQF_SHARED, | 744 | ret = devm_request_irq(&pdev->dev, irq, pxa168fb_handle_irq, |
743 | info->fix.id, fbi); | 745 | IRQF_SHARED, info->fix.id, fbi); |
744 | if (ret < 0) { | 746 | if (ret < 0) { |
745 | dev_err(&pdev->dev, "unable to request IRQ\n"); | 747 | dev_err(&pdev->dev, "unable to request IRQ\n"); |
746 | ret = -ENXIO; | 748 | ret = -ENXIO; |
@@ -759,14 +761,12 @@ static int __devinit pxa168fb_probe(struct platform_device *pdev) | |||
759 | if (ret < 0) { | 761 | if (ret < 0) { |
760 | dev_err(&pdev->dev, "Failed to register pxa168-fb: %d\n", ret); | 762 | dev_err(&pdev->dev, "Failed to register pxa168-fb: %d\n", ret); |
761 | ret = -ENXIO; | 763 | ret = -ENXIO; |
762 | goto failed_free_irq; | 764 | goto failed_free_cmap; |
763 | } | 765 | } |
764 | 766 | ||
765 | platform_set_drvdata(pdev, fbi); | 767 | platform_set_drvdata(pdev, fbi); |
766 | return 0; | 768 | return 0; |
767 | 769 | ||
768 | failed_free_irq: | ||
769 | free_irq(irq, fbi); | ||
770 | failed_free_cmap: | 770 | failed_free_cmap: |
771 | fb_dealloc_cmap(&info->cmap); | 771 | fb_dealloc_cmap(&info->cmap); |
772 | failed_free_clk: | 772 | failed_free_clk: |
@@ -808,13 +808,10 @@ static int __devexit pxa168fb_remove(struct platform_device *pdev) | |||
808 | fb_dealloc_cmap(&info->cmap); | 808 | fb_dealloc_cmap(&info->cmap); |
809 | 809 | ||
810 | irq = platform_get_irq(pdev, 0); | 810 | irq = platform_get_irq(pdev, 0); |
811 | free_irq(irq, fbi); | ||
812 | 811 | ||
813 | dma_free_writecombine(fbi->dev, PAGE_ALIGN(info->fix.smem_len), | 812 | dma_free_writecombine(fbi->dev, PAGE_ALIGN(info->fix.smem_len), |
814 | info->screen_base, info->fix.smem_start); | 813 | info->screen_base, info->fix.smem_start); |
815 | 814 | ||
816 | iounmap(fbi->reg_base); | ||
817 | |||
818 | clk_disable(fbi->clk); | 815 | clk_disable(fbi->clk); |
819 | clk_put(fbi->clk); | 816 | clk_put(fbi->clk); |
820 | 817 | ||