aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2006-01-08 04:04:10 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-08 23:14:02 -0500
commit44ac8413901167589226abf824d994aa57e4fd28 (patch)
treee84b213b960a5b309e426860701e60d98fbb05a5
parenta1365647022eb05a5993f270a78e9bef3bf554eb (diff)
[PATCH] /dev/mem __HAVE_PHYS_MEM_ACCESS_PROT tidy-up
Tidy up __HAVE_PHYS_MEM_ACCESS_PROT usage to make mmap_mem() easier to read. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/char/mem.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index a85f3a361442..ce3ff8641191 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -228,20 +228,25 @@ static ssize_t write_mem(struct file * file, const char __user * buf,
228 return written; 228 return written;
229} 229}
230 230
231#ifndef __HAVE_PHYS_MEM_ACCESS_PROT
232static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
233 unsigned long size, pgprot_t vma_prot)
234{
235#ifdef pgprot_noncached
236 unsigned long offset = pfn << PAGE_SHIFT;
237
238 if (uncached_access(file, offset))
239 return pgprot_noncached(vma_prot);
240#endif
241 return vma_prot;
242}
243#endif
244
231static int mmap_mem(struct file * file, struct vm_area_struct * vma) 245static int mmap_mem(struct file * file, struct vm_area_struct * vma)
232{ 246{
233#if defined(__HAVE_PHYS_MEM_ACCESS_PROT)
234 vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff, 247 vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff,
235 vma->vm_end - vma->vm_start, 248 vma->vm_end - vma->vm_start,
236 vma->vm_page_prot); 249 vma->vm_page_prot);
237#elif defined(pgprot_noncached)
238 unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
239 int uncached;
240
241 uncached = uncached_access(file, offset);
242 if (uncached)
243 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
244#endif
245 250
246 /* Remap-pfn-range will mark the range VM_IO and VM_RESERVED */ 251 /* Remap-pfn-range will mark the range VM_IO and VM_RESERVED */
247 if (remap_pfn_range(vma, 252 if (remap_pfn_range(vma,