Re: [PATCH] drivers: Conversions from kmalloc+memset to k(z|c)alloc.

From: Antonino A. Daplas
Date: Wed Jul 19 2006 - 08:36:39 EST


Panagiotis Issaris wrote:
> From: Panagiotis Issaris <takis@xxxxxxxxxxx>
>
> drivers: Conversions from kmalloc+memset to k(z|c)alloc.
>
> Signed-off-by: Panagiotis Issaris <takis@xxxxxxxxxxx>
> ---

> diff --git a/drivers/video/au1100fb.c b/drivers/video/au1100fb.c
> index a92a91f..11f8372 100644
> --- a/drivers/video/au1100fb.c
> +++ b/drivers/video/au1100fb.c
> @@ -453,11 +453,10 @@ int au1100fb_drv_probe(struct device *de
> return -EINVAL;
>
> /* Allocate new device private */
> - if (!(fbdev = kmalloc(sizeof(struct au1100fb_device), GFP_KERNEL))) {
> + if (!(fbdev = kzalloc(sizeof(struct au1100fb_device), GFP_KERNEL))) {
> print_err("fail to allocate device private record");
> return -ENOMEM;
> }
> - memset((void*)fbdev, 0, sizeof(struct au1100fb_device));
>
> fbdev->panel = &known_lcd_panels[drv_info.panel_idx];
>
> @@ -534,10 +533,9 @@ #endif
> fbdev->info.fbops = &au1100fb_ops;
> fbdev->info.fix = au1100fb_fix;
>
> - if (!(fbdev->info.pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL))) {
> + if (!(fbdev->info.pseudo_palette = kzalloc(16, sizeof(u32), GFP_KERNEL))) {

typo? kcalloc?

> return -ENOMEM;
> }
> - memset(fbdev->info.pseudo_palette, 0, sizeof(u32) * 16);
>
> if (fb_alloc_cmap(&fbdev->info.cmap, AU1100_LCD_NBR_PALETTE_ENTRIES, 0) < 0) {
> print_err("Fail to allocate colormap (%d entries)",
> diff --git a/drivers/video/au1200fb.c b/drivers/video/au1200fb.c
> index c6a5f0c..7d0375a 100644
> --- a/drivers/video/au1200fb.c
> +++ b/drivers/video/au1200fb.c
> @@ -1589,11 +1589,10 @@ static int au1200fb_init_fbinfo(struct a
> return -EFAULT;
> }
>
> - fbi->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL);
> + fbi->pseudo_palette = kzalloc(16, sizeof(u32), GFP_KERNEL);

here also

The rest of drivers/video looks fine.

Tony
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/