some kmalloc/memset ->kzalloc (tree wide)

Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc).

Here is a short excerpt of the semantic patch performing
this transformation:

@@
type T2;
expression x;
identifier f,fld;
expression E;
expression E1,E2;
expression e1,e2,e3,y;
statement S;
@@

 x =
- kmalloc
+ kzalloc
  (E1,E2)
  ...  when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
- memset((T2)x,0,E1);

@@
expression E1,E2,E3;
@@

- kzalloc(E1 * E2,E3)
+ kcalloc(E1,E2,E3)

[[email protected]: get kcalloc args the right way around]
Signed-off-by: Yoann Padioleau <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Ivan Kokshaysky <[email protected]>
Acked-by: Russell King <[email protected]>
Cc: Bryan Wu <[email protected]>
Acked-by: Jiri Slaby <[email protected]>
Cc: Dave Airlie <[email protected]>
Acked-by: Roland Dreier <[email protected]>
Cc: Jiri Kosina <[email protected]>
Acked-by: Dmitry Torokhov <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Acked-by: Mauro Carvalho Chehab <[email protected]>
Acked-by: Pierre Ossman <[email protected]>
Cc: Jeff Garzik <[email protected]>
Cc: "David S. Miller" <[email protected]>
Acked-by: Greg KH <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: "Antonino A. Daplas" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Yoann Padioleau 2007-07-19 01:49:03 -07:00 • committed by Linus Torvalds
commit dd00cc486a
136 changed files with 157 additions and 330 deletions

View file

@ -447,13 +447,12 @@ static int clcdfb_probe(struct amba_device *dev, void *id)
goto out;
}
fb = kmalloc(sizeof(struct clcd_fb), GFP_KERNEL);
fb = kzalloc(sizeof(struct clcd_fb), GFP_KERNEL);
if (!fb) {
printk(KERN_INFO "CLCD: could not allocate new clcd_fb struct\n");
ret = -ENOMEM;
goto free_region;
}
memset(fb, 0, sizeof(struct clcd_fb));
fb->dev = dev;
fb->board = board;

View file

@ -2937,12 +2937,11 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev,
/* nothing */ ;
j = i + 4;
par->mmap_map = kmalloc(j * sizeof(*par->mmap_map), GFP_ATOMIC);
par->mmap_map = kcalloc(j, sizeof(*par->mmap_map), GFP_ATOMIC);
if (!par->mmap_map) {
PRINTKE("atyfb_setup_sparc() can't alloc mmap_map\n");
return -ENOMEM;
}
memset(par->mmap_map, 0, j * sizeof(*par->mmap_map));
for (i = 0, j = 2; i < 6 && pdev->resource[i].start; i++) {
struct resource *rp = &pdev->resource[i];

View file

@ -1589,11 +1589,10 @@ static int au1200fb_init_fbinfo(struct au1200fb_device *fbdev)
return -EFAULT;
}
fbi->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL);
fbi->pseudo_palette = kcalloc(16, sizeof(u32), GFP_KERNEL);
if (!fbi->pseudo_palette) {
return -ENOMEM;
}
memset(fbi->pseudo_palette, 0, sizeof(u32) * 16);
if (fb_alloc_cmap(&fbi->cmap, AU1200_LCD_NBR_PALETTE_ENTRIES, 0) < 0) {
print_err("Fail to allocate colormap (%d entries)",

View file

@ -366,11 +366,10 @@ int __init clps711xfb_init(void)
if (fb_get_options("clps711xfb", NULL))
return -ENODEV;
cfb = kmalloc(sizeof(*cfb), GFP_KERNEL);
cfb = kzalloc(sizeof(*cfb), GFP_KERNEL);
if (!cfb)
goto out;
memset(cfb, 0, sizeof(*cfb));
strcpy(cfb->fix.id, "clps711x");
cfb->fbops = &clps7111fb_ops;

View file

@ -1221,11 +1221,10 @@ cyberpro_alloc_fb_info(unsigned int id, char *name)
{
struct cfb_info *cfb;
cfb = kmalloc(sizeof(struct cfb_info), GFP_KERNEL);
cfb = kzalloc(sizeof(struct cfb_info), GFP_KERNEL);
if (!cfb)
return NULL;
memset(cfb, 0, sizeof(struct cfb_info));
cfb->id = id;

View file

@ -1082,13 +1082,12 @@ static int __init pvr2fb_init(void)
#endif
size = sizeof(struct fb_info) + sizeof(struct pvr2fb_par) + 16 * sizeof(u32);
fb_info = kmalloc(size, GFP_KERNEL);
fb_info = kzalloc(size, GFP_KERNEL);
if (!fb_info) {
printk(KERN_ERR "Failed to allocate memory for fb_info\n");
return -ENOMEM;
}
memset(fb_info, 0, size);
currentpar = (struct pvr2fb_par *)(fb_info + 1);

View file

@ -2174,11 +2174,10 @@ static int __devinit savage_init_fb_info(struct fb_info *info,
#if defined(CONFIG_FB_SAVAGE_ACCEL)
/* FIFO size + padding for commands */
info->pixmap.addr = kmalloc(8*1024, GFP_KERNEL);
info->pixmap.addr = kcalloc(8, 1024, GFP_KERNEL);
err = -ENOMEM;
if (info->pixmap.addr) {
memset(info->pixmap.addr, 0, 8*1024);
info->pixmap.size = 8*1024;
info->pixmap.scan_align = 4;
info->pixmap.buf_align = 4;

View file

@ -356,10 +356,9 @@ int __init valkyriefb_init(void)
}
#endif /* ppc (!CONFIG_MAC) */
p = kmalloc(sizeof(*p), GFP_ATOMIC);
p = kzalloc(sizeof(*p), GFP_ATOMIC);
if (p == 0)
return -ENOMEM;
memset(p, 0, sizeof(*p));
/* Map in frame buffer and registers */
if (!request_mem_region(frame_buffer_phys, 0x100000, "valkyriefb")) {