From: Damien Cassou <damien.cas...@lifl.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.

Signed-off-by: Damien Cassou <damien.cas...@lifl.fr>

---
 drivers/video/bfin-t350mcqb-fb.c |   28 +++++++++-------------------
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/drivers/video/bfin-t350mcqb-fb.c b/drivers/video/bfin-t350mcqb-fb.c
index 7a0c05f..43e0d1b 100644
--- a/drivers/video/bfin-t350mcqb-fb.c
+++ b/drivers/video/bfin-t350mcqb-fb.c
@@ -490,9 +490,10 @@ static int __devinit bfin_t350mcqb_probe(struct 
platform_device *pdev)
        fbinfo->fbops = &bfin_t350mcqb_fb_ops;
        fbinfo->flags = FBINFO_FLAG_DEFAULT;
 
-       info->fb_buffer = dma_alloc_coherent(NULL, fbinfo->fix.smem_len +
-                               ACTIVE_VIDEO_MEM_OFFSET,
-                               &info->dma_handle, GFP_KERNEL);
+       info->fb_buffer = dmam_alloc_coherent(&pdev->dev, NULL,
+                                             fbinfo->fix.smem_len +
+                                             ACTIVE_VIDEO_MEM_OFFSET,
+                                             &info->dma_handle, GFP_KERNEL);
 
        if (NULL == info->fb_buffer) {
                printk(KERN_ERR DRIVER_NAME
@@ -514,7 +515,7 @@ static int __devinit bfin_t350mcqb_probe(struct 
platform_device *pdev)
                       "Fail to allocate colormap (%d entries)\n",
                       BFIN_LCD_NBR_PALETTE_ENTRIES);
                ret = -EFAULT;
-               goto out4;
+               goto out3;
        }
 
        if (bfin_t350mcqb_request_ports(1)) {
@@ -529,8 +530,8 @@ static int __devinit bfin_t350mcqb_probe(struct 
platform_device *pdev)
                goto out7;
        }
 
-       ret = request_irq(info->irq, bfin_t350mcqb_irq_error, 0,
-                       "PPI ERROR", info);
+       ret = devm_request_irq(&pdev->dev, info->irq, bfin_t350mcqb_irq_error,
+                              0, "PPI ERROR", info);
        if (ret < 0) {
                printk(KERN_ERR DRIVER_NAME
                       ": unable to request PPI ERROR IRQ\n");
@@ -541,7 +542,7 @@ static int __devinit bfin_t350mcqb_probe(struct 
platform_device *pdev)
                printk(KERN_ERR DRIVER_NAME
                       ": unable to register framebuffer.\n");
                ret = -EINVAL;
-               goto out8;
+               goto out7;
        }
 #ifndef NO_BL_SUPPORT
        memset(&props, 0, sizeof(struct backlight_properties));
@@ -554,7 +555,7 @@ static int __devinit bfin_t350mcqb_probe(struct 
platform_device *pdev)
                        ": unable to register backlight.\n");
                ret = -EINVAL;
                unregister_framebuffer(fbinfo);
-               goto out8;
+               goto out7;
        }
 
        lcd_dev = lcd_device_register(DRIVER_NAME, NULL, &bfin_lcd_ops);
@@ -563,15 +564,10 @@ static int __devinit bfin_t350mcqb_probe(struct 
platform_device *pdev)
 
        return 0;
 
-out8:
-       free_irq(info->irq, info);
 out7:
        bfin_t350mcqb_request_ports(0);
 out6:
        fb_dealloc_cmap(&fbinfo->cmap);
-out4:
-       dma_free_coherent(NULL, fbinfo->fix.smem_len + ACTIVE_VIDEO_MEM_OFFSET,
-                        info->fb_buffer, info->dma_handle);
 out3:
        framebuffer_release(fbinfo);
 out2:
@@ -591,12 +587,6 @@ static int __devexit bfin_t350mcqb_remove(struct 
platform_device *pdev)
        unregister_framebuffer(fbinfo);
 
        free_dma(CH_PPI);
-       free_irq(info->irq, info);
-
-       if (info->fb_buffer != NULL)
-               dma_free_coherent(NULL, fbinfo->fix.smem_len +
-                       ACTIVE_VIDEO_MEM_OFFSET, info->fb_buffer,
-                       info->dma_handle);
 
        fb_dealloc_cmap(&fbinfo->cmap);
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to