diff options
Diffstat (limited to 'include/drm/drmP.h')
| -rw-r--r-- | include/drm/drmP.h | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 4a3c4e441027..2f3b3a00b7a3 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
| @@ -55,6 +55,7 @@ | |||
| 55 | #include <linux/mm.h> | 55 | #include <linux/mm.h> |
| 56 | #include <linux/cdev.h> | 56 | #include <linux/cdev.h> |
| 57 | #include <linux/mutex.h> | 57 | #include <linux/mutex.h> |
| 58 | #include <linux/slab.h> | ||
| 58 | #if defined(__alpha__) || defined(__powerpc__) | 59 | #if defined(__alpha__) || defined(__powerpc__) |
| 59 | #include <asm/pgtable.h> /* For pte_wrprotect */ | 60 | #include <asm/pgtable.h> /* For pte_wrprotect */ |
| 60 | #endif | 61 | #endif |
| @@ -1545,39 +1546,7 @@ static __inline__ void drm_core_dropmap(struct drm_local_map *map) | |||
| 1545 | { | 1546 | { |
| 1546 | } | 1547 | } |
| 1547 | 1548 | ||
| 1548 | 1549 | #include "drm_mem_util.h" | |
| 1549 | static __inline__ void *drm_calloc_large(size_t nmemb, size_t size) | ||
| 1550 | { | ||
| 1551 | if (size != 0 && nmemb > ULONG_MAX / size) | ||
| 1552 | return NULL; | ||
| 1553 | |||
| 1554 | if (size * nmemb <= PAGE_SIZE) | ||
| 1555 | return kcalloc(nmemb, size, GFP_KERNEL); | ||
| 1556 | |||
| 1557 | return __vmalloc(size * nmemb, | ||
| 1558 | GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL); | ||
| 1559 | } | ||
| 1560 | |||
| 1561 | /* Modeled after cairo's malloc_ab, it's like calloc but without the zeroing. */ | ||
| 1562 | static __inline__ void *drm_malloc_ab(size_t nmemb, size_t size) | ||
| 1563 | { | ||
| 1564 | if (size != 0 && nmemb > ULONG_MAX / size) | ||
| 1565 | return NULL; | ||
| 1566 | |||
| 1567 | if (size * nmemb <= PAGE_SIZE) | ||
| 1568 | return kmalloc(nmemb * size, GFP_KERNEL); | ||
| 1569 | |||
| 1570 | return __vmalloc(size * nmemb, | ||
| 1571 | GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL); | ||
| 1572 | } | ||
| 1573 | |||
| 1574 | static __inline void drm_free_large(void *ptr) | ||
| 1575 | { | ||
| 1576 | if (!is_vmalloc_addr(ptr)) | ||
| 1577 | return kfree(ptr); | ||
| 1578 | |||
| 1579 | vfree(ptr); | ||
| 1580 | } | ||
| 1581 | /*@}*/ | 1550 | /*@}*/ |
| 1582 | 1551 | ||
| 1583 | #endif /* __KERNEL__ */ | 1552 | #endif /* __KERNEL__ */ |
