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 | |
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')
-rw-r--r-- | drivers/gpu/drm/drm_scatter.c | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_mem.c | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 8 | ||||
-rw-r--r-- | drivers/gpu/vga/vgaarb.c | 3 |
5 files changed, 9 insertions, 18 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) { |
diff --git a/drivers/gpu/drm/radeon/radeon_mem.c b/drivers/gpu/drm/radeon/radeon_mem.c index ed95155c4b1d..988548efea92 100644 --- a/drivers/gpu/drm/radeon/radeon_mem.c +++ b/drivers/gpu/drm/radeon/radeon_mem.c | |||
@@ -139,7 +139,7 @@ static int init_heap(struct mem_block **heap, int start, int size) | |||
139 | if (!blocks) | 139 | if (!blocks) |
140 | return -ENOMEM; | 140 | return -ENOMEM; |
141 | 141 | ||
142 | *heap = kmalloc(sizeof(**heap), GFP_KERNEL); | 142 | *heap = kzalloc(sizeof(**heap), GFP_KERNEL); |
143 | if (!*heap) { | 143 | if (!*heap) { |
144 | kfree(blocks); | 144 | kfree(blocks); |
145 | return -ENOMEM; | 145 | return -ENOMEM; |
@@ -150,7 +150,6 @@ static int init_heap(struct mem_block **heap, int start, int size) | |||
150 | blocks->file_priv = NULL; | 150 | blocks->file_priv = NULL; |
151 | blocks->next = blocks->prev = *heap; | 151 | blocks->next = blocks->prev = *heap; |
152 | 152 | ||
153 | memset(*heap, 0, sizeof(**heap)); | ||
154 | (*heap)->file_priv = (struct drm_file *) - 1; | 153 | (*heap)->file_priv = (struct drm_file *) - 1; |
155 | (*heap)->next = (*heap)->prev = blocks; | 154 | (*heap)->next = (*heap)->prev = blocks; |
156 | return 0; | 155 | return 0; |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c b/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c index f1a52f9e7298..07ce02da78a4 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c | |||
@@ -585,11 +585,10 @@ int vmw_overlay_init(struct vmw_private *dev_priv) | |||
585 | return -ENOSYS; | 585 | return -ENOSYS; |
586 | } | 586 | } |
587 | 587 | ||
588 | overlay = kmalloc(sizeof(*overlay), GFP_KERNEL); | 588 | overlay = kzalloc(sizeof(*overlay), GFP_KERNEL); |
589 | if (!overlay) | 589 | if (!overlay) |
590 | return -ENOMEM; | 590 | return -ENOMEM; |
591 | 591 | ||
592 | memset(overlay, 0, sizeof(*overlay)); | ||
593 | mutex_init(&overlay->mutex); | 592 | mutex_init(&overlay->mutex); |
594 | for (i = 0; i < VMW_MAX_NUM_STREAMS; i++) { | 593 | for (i = 0; i < VMW_MAX_NUM_STREAMS; i++) { |
595 | overlay->stream[i].buf = NULL; | 594 | overlay->stream[i].buf = NULL; |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c index 5408b1b7996f..bfe1bcce7f8a 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | |||
@@ -612,11 +612,9 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, | |||
612 | srf->sizes[0].height == 64 && | 612 | srf->sizes[0].height == 64 && |
613 | srf->format == SVGA3D_A8R8G8B8) { | 613 | srf->format == SVGA3D_A8R8G8B8) { |
614 | 614 | ||
615 | srf->snooper.image = kmalloc(64 * 64 * 4, GFP_KERNEL); | 615 | /* allocate image area and clear it */ |
616 | /* clear the image */ | 616 | srf->snooper.image = kzalloc(64 * 64 * 4, GFP_KERNEL); |
617 | if (srf->snooper.image) { | 617 | if (!srf->snooper.image) { |
618 | memset(srf->snooper.image, 0x00, 64 * 64 * 4); | ||
619 | } else { | ||
620 | DRM_ERROR("Failed to allocate cursor_image\n"); | 618 | DRM_ERROR("Failed to allocate cursor_image\n"); |
621 | ret = -ENOMEM; | 619 | ret = -ENOMEM; |
622 | goto out_err1; | 620 | goto out_err1; |
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c index 8a1021f2e319..c72f1c0b5e63 100644 --- a/drivers/gpu/vga/vgaarb.c +++ b/drivers/gpu/vga/vgaarb.c | |||
@@ -1171,10 +1171,9 @@ static int vga_arb_open(struct inode *inode, struct file *file) | |||
1171 | 1171 | ||
1172 | pr_debug("%s\n", __func__); | 1172 | pr_debug("%s\n", __func__); |
1173 | 1173 | ||
1174 | priv = kmalloc(sizeof(struct vga_arb_private), GFP_KERNEL); | 1174 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
1175 | if (priv == NULL) | 1175 | if (priv == NULL) |
1176 | return -ENOMEM; | 1176 | return -ENOMEM; |
1177 | memset(priv, 0, sizeof(*priv)); | ||
1178 | spin_lock_init(&priv->lock); | 1177 | spin_lock_init(&priv->lock); |
1179 | file->private_data = priv; | 1178 | file->private_data = priv; |
1180 | 1179 | ||