Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
[deliverable/linux.git] / include / drm / drm_mem_util.h
index e42495ad813632002d5d313da5351e615240f274..70d4e221a3adb485ff7927c33737db23a127b577 100644 (file)
@@ -54,6 +54,25 @@ static __inline__ void *drm_malloc_ab(size_t nmemb, size_t size)
                         GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL);
 }
 
+static __inline__ void *drm_malloc_gfp(size_t nmemb, size_t size, gfp_t gfp)
+{
+       if (size != 0 && nmemb > SIZE_MAX / size)
+               return NULL;
+
+       if (size * nmemb <= PAGE_SIZE)
+               return kmalloc(nmemb * size, gfp);
+
+       if (gfp & __GFP_RECLAIMABLE) {
+               void *ptr = kmalloc(nmemb * size,
+                                   gfp | __GFP_NOWARN | __GFP_NORETRY);
+               if (ptr)
+                       return ptr;
+       }
+
+       return __vmalloc(size * nmemb,
+                        gfp | __GFP_HIGHMEM, PAGE_KERNEL);
+}
+
 static __inline void drm_free_large(void *ptr)
 {
        kvfree(ptr);
This page took 0.029393 seconds and 5 git commands to generate.