diff options
author | Timur Tabi <timur@freescale.com> | 2011-12-19 17:26:18 -0500 |
---|---|---|
committer | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2012-01-03 10:59:09 -0500 |
commit | 05342c0bdfd519873462e04ad81be07c9cd3c1e1 (patch) | |
tree | f16833fe4a4bee45d74f6383b623411c00cb6024 /drivers/video/fsl-diu-fb.c | |
parent | e09a8c3a42f4c90d300678b198410e6fcc8eddb6 (diff) |
drivers/video: fsl-diu-fb: merge fsl_diu_alloc() into map_video_memory()
Functions fsl_diu_alloc() and fsl_diu_free() were only being called by
map_video_memory() and unmap_video_memory(), respectively.
Signed-off-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Diffstat (limited to 'drivers/video/fsl-diu-fb.c')
-rw-r--r-- | drivers/video/fsl-diu-fb.c | 47 |
1 files changed, 11 insertions, 36 deletions
diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c index e2f4f32692a1..acf292bfba02 100644 --- a/drivers/video/fsl-diu-fb.c +++ b/drivers/video/fsl-diu-fb.c | |||
@@ -461,37 +461,6 @@ static enum fsl_diu_monitor_port fsl_diu_name_to_port(const char *s) | |||
461 | return diu_ops.valid_monitor_port(port); | 461 | return diu_ops.valid_monitor_port(port); |
462 | } | 462 | } |
463 | 463 | ||
464 | /** | ||
465 | * fsl_diu_alloc - allocate memory for the DIU | ||
466 | * @size: number of bytes to allocate | ||
467 | * @param: returned physical address of memory | ||
468 | * | ||
469 | * This function allocates a physically-contiguous block of memory. | ||
470 | */ | ||
471 | static void *fsl_diu_alloc(size_t size, phys_addr_t *phys) | ||
472 | { | ||
473 | void *virt; | ||
474 | |||
475 | virt = alloc_pages_exact(size, GFP_DMA | __GFP_ZERO); | ||
476 | if (virt) | ||
477 | *phys = virt_to_phys(virt); | ||
478 | |||
479 | return virt; | ||
480 | } | ||
481 | |||
482 | /** | ||
483 | * fsl_diu_free - release DIU memory | ||
484 | * @virt: pointer returned by fsl_diu_alloc() | ||
485 | * @size: number of bytes allocated by fsl_diu_alloc() | ||
486 | * | ||
487 | * This function releases memory allocated by fsl_diu_alloc(). | ||
488 | */ | ||
489 | static void fsl_diu_free(void *virt, size_t size) | ||
490 | { | ||
491 | if (virt && size) | ||
492 | free_pages_exact(virt, size); | ||
493 | } | ||
494 | |||
495 | /* | 464 | /* |
496 | * Workaround for failed writing desc register of planes. | 465 | * Workaround for failed writing desc register of planes. |
497 | * Needed with MPC5121 DIU rev 2.0 silicon. | 466 | * Needed with MPC5121 DIU rev 2.0 silicon. |
@@ -875,16 +844,17 @@ static void update_lcdc(struct fb_info *info) | |||
875 | 844 | ||
876 | static int map_video_memory(struct fb_info *info) | 845 | static int map_video_memory(struct fb_info *info) |
877 | { | 846 | { |
878 | phys_addr_t phys; | ||
879 | u32 smem_len = info->fix.line_length * info->var.yres_virtual; | 847 | u32 smem_len = info->fix.line_length * info->var.yres_virtual; |
848 | void *p; | ||
880 | 849 | ||
881 | info->screen_base = fsl_diu_alloc(smem_len, &phys); | 850 | p = alloc_pages_exact(smem_len, GFP_DMA | __GFP_ZERO); |
882 | if (info->screen_base == NULL) { | 851 | if (!p) { |
883 | dev_err(info->dev, "unable to allocate fb memory\n"); | 852 | dev_err(info->dev, "unable to allocate fb memory\n"); |
884 | return -ENOMEM; | 853 | return -ENOMEM; |
885 | } | 854 | } |
886 | mutex_lock(&info->mm_lock); | 855 | mutex_lock(&info->mm_lock); |
887 | info->fix.smem_start = (unsigned long) phys; | 856 | info->screen_base = p; |
857 | info->fix.smem_start = virt_to_phys(info->screen_base); | ||
888 | info->fix.smem_len = smem_len; | 858 | info->fix.smem_len = smem_len; |
889 | mutex_unlock(&info->mm_lock); | 859 | mutex_unlock(&info->mm_lock); |
890 | info->screen_size = info->fix.smem_len; | 860 | info->screen_size = info->fix.smem_len; |
@@ -894,12 +864,17 @@ static int map_video_memory(struct fb_info *info) | |||
894 | 864 | ||
895 | static void unmap_video_memory(struct fb_info *info) | 865 | static void unmap_video_memory(struct fb_info *info) |
896 | { | 866 | { |
897 | fsl_diu_free(info->screen_base, info->fix.smem_len); | 867 | void *p = info->screen_base; |
868 | size_t l = info->fix.smem_len; | ||
869 | |||
898 | mutex_lock(&info->mm_lock); | 870 | mutex_lock(&info->mm_lock); |
899 | info->screen_base = NULL; | 871 | info->screen_base = NULL; |
900 | info->fix.smem_start = 0; | 872 | info->fix.smem_start = 0; |
901 | info->fix.smem_len = 0; | 873 | info->fix.smem_len = 0; |
902 | mutex_unlock(&info->mm_lock); | 874 | mutex_unlock(&info->mm_lock); |
875 | |||
876 | if (p) | ||
877 | free_pages_exact(p, l); | ||
903 | } | 878 | } |
904 | 879 | ||
905 | /* | 880 | /* |