diff options
author | Dmitry Kalinkin <dmitry.kalinkin@gmail.com> | 2015-02-26 18:53:10 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-03-06 17:03:22 -0800 |
commit | c74a804f115bdedcac72ea52ca33f46cfae3b74f (patch) | |
tree | 0e2c88fa7c1c0ba49147594f70d99688e9345c10 /drivers/vme | |
parent | 0cd189a42da07c89c809debc1f6a75f5ec0f5c43 (diff) | |
download | op-kernel-dev-c74a804f115bdedcac72ea52ca33f46cfae3b74f.zip op-kernel-dev-c74a804f115bdedcac72ea52ca33f46cfae3b74f.tar.gz |
staging: vme: mmap() support for vme_user
We also make sure that user won't be able to reconfigure the window while it is
mmap'ed.
Signed-off-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Cc: Martyn Welch <martyn.welch@ge.com>
Cc: Igor Alekseev <igor.alekseev@itep.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/vme')
-rw-r--r-- | drivers/vme/vme.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c index d95fb84..6bab2c4ed 100644 --- a/drivers/vme/vme.c +++ b/drivers/vme/vme.c @@ -609,6 +609,32 @@ unsigned int vme_master_rmw(struct vme_resource *resource, unsigned int mask, } EXPORT_SYMBOL(vme_master_rmw); +int vme_master_mmap(struct vme_resource *resource, struct vm_area_struct *vma) +{ + struct vme_master_resource *image; + phys_addr_t phys_addr; + unsigned long vma_size; + + if (resource->type != VME_MASTER) { + pr_err("Not a master resource\n"); + return -EINVAL; + } + + image = list_entry(resource->entry, struct vme_master_resource, list); + phys_addr = image->bus_resource.start + (vma->vm_pgoff << PAGE_SHIFT); + vma_size = vma->vm_end - vma->vm_start; + + if (phys_addr + vma_size > image->bus_resource.end + 1) { + pr_err("Map size cannot exceed the window size\n"); + return -EFAULT; + } + + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + + return vm_iomap_memory(vma, phys_addr, vma->vm_end - vma->vm_start); +} +EXPORT_SYMBOL(vme_master_mmap); + void vme_master_free(struct vme_resource *resource) { struct vme_master_resource *master_image; |