Commit 61db8121 authored by Nick Piggin's avatar Nick Piggin Committed by Stefan Richter

ieee1394: nopage

Convert ieee1394 from nopage to fault.
Remove redundant vma range checks (correct resource range check is retained).
Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
parent a5c52df8
...@@ -231,37 +231,32 @@ void dma_region_sync_for_device(struct dma_region *dma, unsigned long offset, ...@@ -231,37 +231,32 @@ void dma_region_sync_for_device(struct dma_region *dma, unsigned long offset,
#ifdef CONFIG_MMU #ifdef CONFIG_MMU
/* nopage() handler for mmap access */ /* fault() handler for mmap access */
static struct page *dma_region_pagefault(struct vm_area_struct *area, static int dma_region_pagefault(struct vm_area_struct *vma,
unsigned long address, int *type) struct vm_fault *vmf)
{ {
unsigned long offset;
unsigned long kernel_virt_addr; unsigned long kernel_virt_addr;
struct page *ret = NOPAGE_SIGBUS;
struct dma_region *dma = (struct dma_region *)area->vm_private_data; struct dma_region *dma = (struct dma_region *)vma->vm_private_data;
if (!dma->kvirt) if (!dma->kvirt)
goto out; goto error;
if ((address < (unsigned long)area->vm_start) || if (vmf->pgoff >= dma->n_pages)
(address > goto error;
(unsigned long)area->vm_start + (dma->n_pages << PAGE_SHIFT)))
goto out; kernel_virt_addr = (unsigned long)dma->kvirt + (vmf->pgoff << PAGE_SHIFT);
vmf->page = vmalloc_to_page((void *)kernel_virt_addr);
if (type) get_page(vmf->page);
*type = VM_FAULT_MINOR; return 0;
offset = address - area->vm_start;
kernel_virt_addr = (unsigned long)dma->kvirt + offset; error:
ret = vmalloc_to_page((void *)kernel_virt_addr); return VM_FAULT_SIGBUS;
get_page(ret);
out:
return ret;
} }
static struct vm_operations_struct dma_region_vm_ops = { static struct vm_operations_struct dma_region_vm_ops = {
.nopage = dma_region_pagefault, .fault = dma_region_pagefault,
}; };
/** /**
...@@ -275,7 +270,7 @@ int dma_region_mmap(struct dma_region *dma, struct file *file, ...@@ -275,7 +270,7 @@ int dma_region_mmap(struct dma_region *dma, struct file *file,
if (!dma->kvirt) if (!dma->kvirt)
return -EINVAL; return -EINVAL;
/* must be page-aligned */ /* must be page-aligned (XXX: comment is wrong, we could allow pgoff) */
if (vma->vm_pgoff != 0) if (vma->vm_pgoff != 0)
return -EINVAL; return -EINVAL;
......
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