Commit 8da3daaa authored by Ankit Jain's avatar Ankit Jain Committed by Andy Gross

soc: qcom: rmtfs: Add support for mmap functionality

This change adds mmap functionality to rmtfs_mem driver.
Userspace application can map the address and use this
mapped address directly as buffer for read/write call to disk.
and avoid the read/write call to the shared path to copy the
buffer to userspace application.
Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: default avatarAnkit Jain <jankit@codeaurora.org>
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: default avatarAndy Gross <andy.gross@linaro.org>
parent 9e98c678
......@@ -137,6 +137,26 @@ static struct class rmtfs_class = {
.name = "rmtfs",
};
static int qcom_rmtfs_mem_mmap(struct file *filep, struct vm_area_struct *vma)
{
struct qcom_rmtfs_mem *rmtfs_mem = filep->private_data;
if (vma->vm_end - vma->vm_start > rmtfs_mem->size) {
dev_dbg(&rmtfs_mem->dev,
"vm_end[%lu] - vm_start[%lu] [%lu] > mem->size[%pa]\n",
vma->vm_end, vma->vm_start,
(vma->vm_end - vma->vm_start), &rmtfs_mem->size);
return -EINVAL;
}
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
return remap_pfn_range(vma,
vma->vm_start,
rmtfs_mem->addr >> PAGE_SHIFT,
vma->vm_end - vma->vm_start,
vma->vm_page_prot);
}
static const struct file_operations qcom_rmtfs_mem_fops = {
.owner = THIS_MODULE,
.open = qcom_rmtfs_mem_open,
......@@ -144,6 +164,7 @@ static const struct file_operations qcom_rmtfs_mem_fops = {
.write = qcom_rmtfs_mem_write,
.release = qcom_rmtfs_mem_release,
.llseek = default_llseek,
.mmap = qcom_rmtfs_mem_mmap,
};
static void qcom_rmtfs_mem_release_device(struct device *dev)
......
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