aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394/dma.c
diff options
context:
space:
mode:
authorNick Piggin <npiggin@suse.de>2007-12-05 02:15:53 -0500
committerStefan Richter <stefanr@s5r6.in-berlin.de>2008-01-30 16:22:19 -0500
commit61db81214bcef33a41325bdc436fb515b697fcdb (patch)
tree2fe5ccd927df30c1d9253a2ee2db159e943bb621 /drivers/ieee1394/dma.c
parenta5c52df8bce65971b8db95149ebc1c5f1026af45 (diff)
ieee1394: nopage
Convert ieee1394 from nopage to fault. Remove redundant vma range checks (correct resource range check is retained). Signed-off-by: Nick Piggin <npiggin@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/ieee1394/dma.c')
-rw-r--r--drivers/ieee1394/dma.c41
1 files changed, 18 insertions, 23 deletions
diff --git a/drivers/ieee1394/dma.c b/drivers/ieee1394/dma.c
index 7c4eb39b7024..ec024b5d5e5e 100644
--- a/drivers/ieee1394/dma.c
+++ b/drivers/ieee1394/dma.c
@@ -231,37 +231,32 @@ void dma_region_sync_for_device(struct dma_region *dma, unsigned long offset,
231 231
232#ifdef CONFIG_MMU 232#ifdef CONFIG_MMU
233 233
234/* nopage() handler for mmap access */ 234/* fault() handler for mmap access */
235 235
236static struct page *dma_region_pagefault(struct vm_area_struct *area, 236static int dma_region_pagefault(struct vm_area_struct *vma,
237 unsigned long address, int *type) 237 struct vm_fault *vmf)
238{ 238{
239 unsigned long offset;
240 unsigned long kernel_virt_addr; 239 unsigned long kernel_virt_addr;
241 struct page *ret = NOPAGE_SIGBUS;
242 240
243 struct dma_region *dma = (struct dma_region *)area->vm_private_data; 241 struct dma_region *dma = (struct dma_region *)vma->vm_private_data;
244 242
245 if (!dma->kvirt) 243 if (!dma->kvirt)
246 goto out; 244 goto error;
247 245
248 if ((address < (unsigned long)area->vm_start) || 246 if (vmf->pgoff >= dma->n_pages)
249 (address > 247 goto error;
250 (unsigned long)area->vm_start + (dma->n_pages << PAGE_SHIFT))) 248
251 goto out; 249 kernel_virt_addr = (unsigned long)dma->kvirt + (vmf->pgoff << PAGE_SHIFT);
252 250 vmf->page = vmalloc_to_page((void *)kernel_virt_addr);
253 if (type) 251 get_page(vmf->page);
254 *type = VM_FAULT_MINOR; 252 return 0;
255 offset = address - area->vm_start; 253
256 kernel_virt_addr = (unsigned long)dma->kvirt + offset; 254 error:
257 ret = vmalloc_to_page((void *)kernel_virt_addr); 255 return VM_FAULT_SIGBUS;
258 get_page(ret);
259 out:
260 return ret;
261} 256}
262 257
263static struct vm_operations_struct dma_region_vm_ops = { 258static struct vm_operations_struct dma_region_vm_ops = {
264 .nopage = dma_region_pagefault, 259 .fault = dma_region_pagefault,
265}; 260};
266 261
267/** 262/**
@@ -275,7 +270,7 @@ int dma_region_mmap(struct dma_region *dma, struct file *file,
275 if (!dma->kvirt) 270 if (!dma->kvirt)
276 return -EINVAL; 271 return -EINVAL;
277 272
278 /* must be page-aligned */ 273 /* must be page-aligned (XXX: comment is wrong, we could allow pgoff) */
279 if (vma->vm_pgoff != 0) 274 if (vma->vm_pgoff != 0)
280 return -EINVAL; 275 return -EINVAL;
281 276