drivers: use kzalloc/kcalloc instead of 'kmalloc+memset', where possible
[linux-2.6.git] / drivers / gpu / drm / drm_scatter.c
index d15e09b..7525e03 100644 (file)
@@ -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) {