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>
This commit is contained in:
committed by
Linus Torvalds
parent
f1c93e4946
commit
f35119d668
@@ -83,30 +83,26 @@ int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request)
|
||||
if (dev->sg)
|
||||
return -EINVAL;
|
||||
|
||||
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
|
||||
entry = kzalloc(sizeof(*entry), GFP_KERNEL);
|
||||
if (!entry)
|
||||
return -ENOMEM;
|
||||
|
||||
memset(entry, 0, sizeof(*entry));
|
||||
pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
|
||||
DRM_DEBUG("size=%ld pages=%ld\n", request->size, pages);
|
||||
|
||||
entry->pages = pages;
|
||||
entry->pagelist = kmalloc(pages * sizeof(*entry->pagelist), GFP_KERNEL);
|
||||
entry->pagelist = kcalloc(pages, sizeof(*entry->pagelist), GFP_KERNEL);
|
||||
if (!entry->pagelist) {
|
||||
kfree(entry);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memset(entry->pagelist, 0, pages * sizeof(*entry->pagelist));
|
||||
|
||||
entry->busaddr = kmalloc(pages * sizeof(*entry->busaddr), GFP_KERNEL);
|
||||
entry->busaddr = kcalloc(pages, sizeof(*entry->busaddr), GFP_KERNEL);
|
||||
if (!entry->busaddr) {
|
||||
kfree(entry->pagelist);
|
||||
kfree(entry);
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset((void *)entry->busaddr, 0, pages * sizeof(*entry->busaddr));
|
||||
|
||||
entry->virtual = drm_vmalloc_dma(pages << PAGE_SHIFT);
|
||||
if (!entry->virtual) {
|
||||
|
Reference in New Issue
Block a user