Commit 47f698a9 authored by Tomi Valkeinen's avatar Tomi Valkeinen

fbdev/controlfb: use vm_iomap_memory()

Use vm_iomap_memory() instead of [io_]remap_pfn_range().
vm_iomap_memory() gives us much simpler API to map memory to userspace,
and reduces possibilities for bugs.
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent 6d28c21f
...@@ -285,36 +285,26 @@ static int controlfb_pan_display(struct fb_var_screeninfo *var, ...@@ -285,36 +285,26 @@ static int controlfb_pan_display(struct fb_var_screeninfo *var,
static int controlfb_mmap(struct fb_info *info, static int controlfb_mmap(struct fb_info *info,
struct vm_area_struct *vma) struct vm_area_struct *vma)
{ {
unsigned long off, start; unsigned long mmio_pgoff;
unsigned long start;
u32 len; u32 len;
off = vma->vm_pgoff << PAGE_SHIFT;
/* frame buffer memory */
start = info->fix.smem_start; start = info->fix.smem_start;
len = PAGE_ALIGN((start & ~PAGE_MASK)+info->fix.smem_len); len = info->fix.smem_len;
if (off >= len) { mmio_pgoff = PAGE_ALIGN((start & ~PAGE_MASK) + len) >> PAGE_SHIFT;
/* memory mapped io */ if (vma->vm_pgoff >= mmio_pgoff) {
off -= len;
if (info->var.accel_flags) if (info->var.accel_flags)
return -EINVAL; return -EINVAL;
vma->vm_pgoff -= mmio_pgoff;
start = info->fix.mmio_start; start = info->fix.mmio_start;
len = PAGE_ALIGN((start & ~PAGE_MASK)+info->fix.mmio_len); len = info->fix.mmio_len;
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
} else { } else {
/* framebuffer */ /* framebuffer */
vma->vm_page_prot = pgprot_cached_wthru(vma->vm_page_prot); vma->vm_page_prot = pgprot_cached_wthru(vma->vm_page_prot);
} }
start &= PAGE_MASK;
if ((vma->vm_end - vma->vm_start + off) > len)
return -EINVAL;
off += start;
vma->vm_pgoff = off >> PAGE_SHIFT;
if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
vma->vm_end - vma->vm_start, vma->vm_page_prot))
return -EAGAIN;
return 0; return vm_iomap_memory(vma, start, len);
} }
static int controlfb_blank(int blank_mode, struct fb_info *info) static int controlfb_blank(int blank_mode, struct fb_info *info)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment