/* Most drivers don't need their own mmap function  */
static int vfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
/* Most drivers don't need their own mmap function  */
static int vfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
{
	unsigned long start = vma->vm_start;
	unsigned long size = vma->vm_end - vma->vm_start;
	unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
	unsigned long page, pos;
	if (offset + size > info->fix.smem_len) {
		return -EINVAL;
	}
	pos = (unsigned long)info->fix.smem_start + offset;
	while (size > 0) {
		page = vmalloc_to_pfn((void *)pos);
		if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
			return -EAGAIN;
		}
		start += PAGE_SIZE;
		pos += PAGE_SIZE;
		if (size > PAGE_SIZE)
			size -= PAGE_SIZE;
		else
			size = 0;
	}
	vma->vm_flags |= VM_RESERVED;
	return 0;
}