diff options
author | Rakib Mullick <rakib.mullick@gmail.com> | 2011-07-25 20:12:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-25 23:57:13 -0400 |
commit | f35119d6681300ba6d76da53cb1ebc2eed62e77a (patch) | |
tree | 0dfd0d1bf9acf3e48791059b50bc68fff01c4db9 /drivers/gpu/drm/drm_scatter.c | |
parent | f1c93e4946ae1cc268729451de6335a7e7d2bea9 (diff) |
drivers: use kzalloc/kcalloc instead of 'kmalloc+memset', where possible
Signed-off-by: Rakib Mullick <rakib.mullick@gmail.com>
Cc: Jeff Garzik <jgarzik@pobox.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Tejun Heo <tj@kernel.org>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/gpu/drm/drm_scatter.c')
-rw-r--r-- | drivers/gpu/drm/drm_scatter.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c index d15e09b0ae0b..7525e0311e59 100644 --- a/drivers/gpu/drm/drm_scatter.c +++ b/drivers/gpu/drm/drm_scatter.c | |||
@@ -83,30 +83,26 @@ int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request) | |||
83 | if (dev->sg) | 83 | if (dev->sg) |
84 | return -EINVAL; | 84 | return -EINVAL; |
85 | 85 | ||
86 | entry = kmalloc(sizeof(*entry), GFP_KERNEL); | 86 | entry = kzalloc(sizeof(*entry), GFP_KERNEL); |
87 | if (!entry) | 87 | if (!entry) |
88 | return -ENOMEM; | 88 | return -ENOMEM; |
89 | 89 | ||
90 | memset(entry, 0, sizeof(*entry)); | ||
91 | pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE; | 90 | pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE; |
92 | DRM_DEBUG("size=%ld pages=%ld\n", request->size, pages); | 91 | DRM_DEBUG("size=%ld pages=%ld\n", request->size, pages); |
93 | 92 | ||
94 | entry->pages = pages; | 93 | entry->pages = pages; |
95 | entry->pagelist = kmalloc(pages * sizeof(*entry->pagelist), GFP_KERNEL); | 94 | entry->pagelist = kcalloc(pages, sizeof(*entry->pagelist), GFP_KERNEL); |
96 | if (!entry->pagelist) { | 95 | if (!entry->pagelist) { |
97 | kfree(entry); | 96 | kfree(entry); |
98 | return -ENOMEM; | 97 | return -ENOMEM; |
99 | } | 98 | } |
100 | 99 | ||
101 | memset(entry->pagelist, 0, pages * sizeof(*entry->pagelist)); | 100 | entry->busaddr = kcalloc(pages, sizeof(*entry->busaddr), GFP_KERNEL); |
102 | |||
103 | entry->busaddr = kmalloc(pages * sizeof(*entry->busaddr), GFP_KERNEL); | ||
104 | if (!entry->busaddr) { | 101 | if (!entry->busaddr) { |
105 | kfree(entry->pagelist); | 102 | kfree(entry->pagelist); |
106 | kfree(entry); | 103 | kfree(entry); |
107 | return -ENOMEM; | 104 | return -ENOMEM; |
108 | } | 105 | } |
109 | memset((void *)entry->busaddr, 0, pages * sizeof(*entry->busaddr)); | ||
110 | 106 | ||
111 | entry->virtual = drm_vmalloc_dma(pages << PAGE_SHIFT); | 107 | entry->virtual = drm_vmalloc_dma(pages << PAGE_SHIFT); |
112 | if (!entry->virtual) { | 108 | if (!entry->virtual) { |