]> err.no Git - linux-2.6/commitdiff
drm: move protection stuff into separate function
authorDave Airlie <airlied@linux.ie>
Sat, 10 Feb 2007 00:53:13 +0000 (11:53 +1100)
committerDave Airlie <airlied@linux.ie>
Sun, 11 Mar 2007 01:07:17 +0000 (12:07 +1100)
Signed-off-by: Dave Airlie <airlied@linux.ie>
drivers/char/drm/drm_vm.c

index 54a632848955143df4bf30d1e49868366782375d..7ed77e16488c81a857e4e4f20cf228421acb4fb4 100644 (file)
 static void drm_vm_open(struct vm_area_struct *vma);
 static void drm_vm_close(struct vm_area_struct *vma);
 
+pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma)
+{
+       pgprot_t tmp = vm_get_page_prot(vma->vm_flags);
+
+#if defined(__i386__) || defined(__x86_64__)
+       if (boot_cpu_data.x86 > 3 && map_type != _DRM_AGP) {
+               pgprot_val(tmp) |= _PAGE_PCD;
+               pgprot_val(tmp) &= ~_PAGE_PWT;
+       }
+#elif defined(__powerpc__)
+       pgprot_val(tmp) |= _PAGE_NO_CACHE;
+       if (map_type == _DRM_REGISTERS)
+               pgprot_val(tmp) |= _PAGE_GUARDED;
+#endif
+#if defined(__ia64__)
+       if (efi_range_is_wc(vma->vm_start, vma->vm_end -
+                                   vma->vm_start))
+               tmp = pgprot_writecombine(tmp);
+       else
+               tmp = pgprot_noncached(tmp);
+#endif
+       return tmp;
+}
+
 /**
  * \c nopage method for AGP virtual memory.
  *
@@ -600,25 +624,9 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
                /* fall through to _DRM_FRAME_BUFFER... */
        case _DRM_FRAME_BUFFER:
        case _DRM_REGISTERS:
-#if defined(__i386__) || defined(__x86_64__)
-               if (boot_cpu_data.x86 > 3 && map->type != _DRM_AGP) {
-                       pgprot_val(vma->vm_page_prot) |= _PAGE_PCD;
-                       pgprot_val(vma->vm_page_prot) &= ~_PAGE_PWT;
-               }
-#elif defined(__powerpc__)
-               pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
-               if (map->type == _DRM_REGISTERS)
-                       pgprot_val(vma->vm_page_prot) |= _PAGE_GUARDED;
-#endif
-               vma->vm_flags |= VM_IO; /* not in core dump */
-#if defined(__ia64__)
-               if (efi_range_is_wc(vma->vm_start, vma->vm_end - vma->vm_start))
-                       vma->vm_page_prot =
-                           pgprot_writecombine(vma->vm_page_prot);
-               else
-                       vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-#endif
                offset = dev->driver->get_reg_ofs(dev);
+               vma->vm_flags |= VM_IO; /* not in core dump */
+               vma->vm_page_prot = drm_io_prot(map->type, vma);
 #ifdef __sparc__
                vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
                if (io_remap_pfn_range(vma, vma->vm_start,