diff options
author | Muhammad Falak R Wani <falakreyaz@gmail.com> | 2016-05-23 07:38:42 -0400 |
---|---|---|
committer | Sumit Semwal <sumit.semwal@linaro.org> | 2016-05-31 12:47:05 -0400 |
commit | b02da6f8236148009c22167cd7013d5ce04a2d37 (patch) | |
tree | e0408c4075dd0004740b1f011fae28d7a6533367 | |
parent | 4320c2a22df12f954edd4997f71ca3a4216312b2 (diff) |
dma-buf: use vma_pages()
Replace explicit computation of vma page count by a call to
vma_pages().
Also, include <linux/mm.h>
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
-rw-r--r-- | drivers/dma-buf/dma-buf.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 4a2c07ee6677..6355ab38d630 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/seq_file.h> | 33 | #include <linux/seq_file.h> |
34 | #include <linux/poll.h> | 34 | #include <linux/poll.h> |
35 | #include <linux/reservation.h> | 35 | #include <linux/reservation.h> |
36 | #include <linux/mm.h> | ||
36 | 37 | ||
37 | #include <uapi/linux/dma-buf.h> | 38 | #include <uapi/linux/dma-buf.h> |
38 | 39 | ||
@@ -90,7 +91,7 @@ static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma) | |||
90 | dmabuf = file->private_data; | 91 | dmabuf = file->private_data; |
91 | 92 | ||
92 | /* check for overflowing the buffer's size */ | 93 | /* check for overflowing the buffer's size */ |
93 | if (vma->vm_pgoff + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) > | 94 | if (vma->vm_pgoff + vma_pages(vma) > |
94 | dmabuf->size >> PAGE_SHIFT) | 95 | dmabuf->size >> PAGE_SHIFT) |
95 | return -EINVAL; | 96 | return -EINVAL; |
96 | 97 | ||
@@ -723,11 +724,11 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma, | |||
723 | return -EINVAL; | 724 | return -EINVAL; |
724 | 725 | ||
725 | /* check for offset overflow */ | 726 | /* check for offset overflow */ |
726 | if (pgoff + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) < pgoff) | 727 | if (pgoff + vma_pages(vma) < pgoff) |
727 | return -EOVERFLOW; | 728 | return -EOVERFLOW; |
728 | 729 | ||
729 | /* check for overflowing the buffer's size */ | 730 | /* check for overflowing the buffer's size */ |
730 | if (pgoff + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) > | 731 | if (pgoff + vma_pages(vma) > |
731 | dmabuf->size >> PAGE_SHIFT) | 732 | dmabuf->size >> PAGE_SHIFT) |
732 | return -EINVAL; | 733 | return -EINVAL; |
733 | 734 | ||