Blackfin: fix cache Kconfig typo
[safe/jmp/linux-2.6] / drivers / video / fsl-diu-fb.c
index fb51197..72d68b3 100644 (file)
@@ -750,24 +750,26 @@ static void update_lcdc(struct fb_info *info)
 static int map_video_memory(struct fb_info *info)
 {
        phys_addr_t phys;
+       u32 smem_len = info->fix.line_length * info->var.yres_virtual;
 
        pr_debug("info->var.xres_virtual = %d\n", info->var.xres_virtual);
        pr_debug("info->var.yres_virtual = %d\n", info->var.yres_virtual);
        pr_debug("info->fix.line_length  = %d\n", info->fix.line_length);
+       pr_debug("MAP_VIDEO_MEMORY: smem_len = %u\n", smem_len);
 
-       info->fix.smem_len = info->fix.line_length * info->var.yres_virtual;
-       pr_debug("MAP_VIDEO_MEMORY: smem_len = %d\n", info->fix.smem_len);
-       info->screen_base = fsl_diu_alloc(info->fix.smem_len, &phys);
+       info->screen_base = fsl_diu_alloc(smem_len, &phys);
        if (info->screen_base == NULL) {
                printk(KERN_ERR "Unable to allocate fb memory\n");
                return -ENOMEM;
        }
+       mutex_lock(&info->mm_lock);
        info->fix.smem_start = (unsigned long) phys;
+       info->fix.smem_len = smem_len;
+       mutex_unlock(&info->mm_lock);
        info->screen_size = info->fix.smem_len;
 
        pr_debug("Allocated fb @ paddr=0x%08lx, size=%d.\n",
-                               info->fix.smem_start,
-               info->fix.smem_len);
+                info->fix.smem_start, info->fix.smem_len);
        pr_debug("screen base %p\n", info->screen_base);
 
        return 0;
@@ -776,9 +778,11 @@ static int map_video_memory(struct fb_info *info)
 static void unmap_video_memory(struct fb_info *info)
 {
        fsl_diu_free(info->screen_base, info->fix.smem_len);
+       mutex_lock(&info->mm_lock);
        info->screen_base = NULL;
        info->fix.smem_start = 0;
        info->fix.smem_len = 0;
+       mutex_unlock(&info->mm_lock);
 }
 
 /*
@@ -1219,12 +1223,6 @@ static int __devinit install_fb(struct fb_info *info)
                return -EINVAL;
        }
 
-       if (fsl_diu_set_par(info)) {
-               printk(KERN_ERR "fb_set_par failed");
-               fb_dealloc_cmap(&info->cmap);
-               return -EINVAL;
-       }
-
        if (register_framebuffer(info) < 0) {
                printk(KERN_ERR "register_framebuffer failed");
                unmap_video_memory(info);
@@ -1352,14 +1350,15 @@ static int fsl_diu_resume(struct of_device *ofdev)
 #endif                         /* CONFIG_PM */
 
 /* Align to 64-bit(8-byte), 32-byte, etc. */
-static int allocate_buf(struct diu_addr *buf, u32 size, u32 bytes_align)
+static int allocate_buf(struct device *dev, struct diu_addr *buf, u32 size,
+                       u32 bytes_align)
 {
        u32 offset, ssize;
        u32 mask;
        dma_addr_t paddr = 0;
 
        ssize = size + bytes_align;
-       buf->vaddr = dma_alloc_coherent(NULL, ssize, &paddr, GFP_DMA |
+       buf->vaddr = dma_alloc_coherent(dev, ssize, &paddr, GFP_DMA |
                                                             __GFP_ZERO);
        if (!buf->vaddr)
                return -ENOMEM;
@@ -1376,9 +1375,10 @@ static int allocate_buf(struct diu_addr *buf, u32 size, u32 bytes_align)
        return 0;
 }
 
-static void free_buf(struct diu_addr *buf, u32 size, u32 bytes_align)
+static void free_buf(struct device *dev, struct diu_addr *buf, u32 size,
+                    u32 bytes_align)
 {
-       dma_free_coherent(NULL, size + bytes_align,
+       dma_free_coherent(dev, size + bytes_align,
                                buf->vaddr, (buf->paddr - buf->offset));
        return;
 }
@@ -1476,17 +1476,19 @@ static int __devinit fsl_diu_probe(struct of_device *ofdev,
        machine_data->monitor_port = monitor_port;
 
        /* Area descriptor memory pool aligns to 64-bit boundary */
-       if (allocate_buf(&pool.ad, sizeof(struct diu_ad) * FSL_AOI_NUM, 8))
+       if (allocate_buf(&ofdev->dev, &pool.ad,
+                        sizeof(struct diu_ad) * FSL_AOI_NUM, 8))
                return -ENOMEM;
 
        /* Get memory for Gamma Table  - 32-byte aligned memory */
-       if (allocate_buf(&pool.gamma, 768, 32)) {
+       if (allocate_buf(&ofdev->dev, &pool.gamma, 768, 32)) {
                ret = -ENOMEM;
                goto error;
        }
 
        /* For performance, cursor bitmap buffer aligns to 32-byte boundary */
-       if (allocate_buf(&pool.cursor, MAX_CURS * MAX_CURS * 2, 32)) {
+       if (allocate_buf(&ofdev->dev, &pool.cursor, MAX_CURS * MAX_CURS * 2,
+                        32)) {
                ret = -ENOMEM;
                goto error;
        }
@@ -1554,11 +1556,13 @@ error:
                i > 0; i--)
                uninstall_fb(machine_data->fsl_diu_info[i - 1]);
        if (pool.ad.vaddr)
-               free_buf(&pool.ad, sizeof(struct diu_ad) * FSL_AOI_NUM, 8);
+               free_buf(&ofdev->dev, &pool.ad,
+                        sizeof(struct diu_ad) * FSL_AOI_NUM, 8);
        if (pool.gamma.vaddr)
-               free_buf(&pool.gamma, 768, 32);
+               free_buf(&ofdev->dev, &pool.gamma, 768, 32);
        if (pool.cursor.vaddr)
-               free_buf(&pool.cursor, MAX_CURS * MAX_CURS * 2, 32);
+               free_buf(&ofdev->dev, &pool.cursor, MAX_CURS * MAX_CURS * 2,
+                        32);
        if (machine_data->dummy_aoi_virt)
                fsl_diu_free(machine_data->dummy_aoi_virt, 64);
        iounmap(dr.diu_reg);
@@ -1584,11 +1588,13 @@ static int fsl_diu_remove(struct of_device *ofdev)
        for (i = ARRAY_SIZE(machine_data->fsl_diu_info); i > 0; i--)
                uninstall_fb(machine_data->fsl_diu_info[i - 1]);
        if (pool.ad.vaddr)
-               free_buf(&pool.ad, sizeof(struct diu_ad) * FSL_AOI_NUM, 8);
+               free_buf(&ofdev->dev, &pool.ad,
+                        sizeof(struct diu_ad) * FSL_AOI_NUM, 8);
        if (pool.gamma.vaddr)
-               free_buf(&pool.gamma, 768, 32);
+               free_buf(&ofdev->dev, &pool.gamma, 768, 32);
        if (pool.cursor.vaddr)
-               free_buf(&pool.cursor, MAX_CURS * MAX_CURS * 2, 32);
+               free_buf(&ofdev->dev, &pool.cursor, MAX_CURS * MAX_CURS * 2,
+                        32);
        if (machine_data->dummy_aoi_virt)
                fsl_diu_free(machine_data->dummy_aoi_virt, 64);
        iounmap(dr.diu_reg);