lkml.org 
[lkml]   [2011]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] drivers: Use kzalloc instead of 'kmalloc+memset', where possible.
From
Date
On Mon, 2011-05-23 at 23:40 +0600, Rakib Mullick wrote:
> Following patch removes the uses of 'kmalloc+memset' from various
> drivers subsystems, which is replaced by kzalloc. kzalloc take care of
> setting allocated memory with null, so it helps to get rid from using
> memset.
> diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
[]
> - entry->pagelist = kmalloc(pages * sizeof(*entry->pagelist), GFP_KERNEL);
> + entry->pagelist = kzalloc(pages * sizeof(*entry->pagelist), GFP_KERNEL);

Perhaps it's better to use:

entry->pagelist = kcalloc(pages, sizeof(*entry->pagelist), GFP_KERNEL);

> - entry->busaddr = kmalloc(pages * sizeof(*entry->busaddr), GFP_KERNEL);
> + entry->busaddr = kzalloc(pages * sizeof(*entry->busaddr), GFP_KERNEL);

here too.



\
 
 \ /
  Last update: 2011-05-23 19:53    [W:0.047 / U:5.472 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site