All of lore.kernel.org
 help / color / mirror / Atom feed
* [KJ] [Patch] kzalloc() conversion in drivers/video
@ 2006-02-24 21:17 Eric Sesterhenn
  2006-02-27  9:22 ` [KJ] [Patch] kzalloc() conversion in drivers/atm Eric Sesterhenn
                   ` (31 more replies)
  0 siblings, 32 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-02-24 21:17 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 15595 bytes --]

hi,

this patch converts drivers/video to kzalloc usage.
Compile tested with allyes config. It also contains a formating change
in video/matrox/matroxfb_maven.c, i am not sure if it is ok to
remove the cast, to keep it on a single line to make it more readable.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc4/drivers/video/au1100fb.c.orig	2006-02-24 21:50:38.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/au1100fb.c	2006-02-24 21:52:45.000000000 +0100
@@ -444,11 +444,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];
 
@@ -525,10 +524,8 @@ int au1100fb_drv_probe(struct device *de
 	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 = kcalloc(16, sizeof(u32), GFP_KERNEL)))
 		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)",
--- linux-2.6.16-rc4/drivers/video/matrox/matroxfb_crtc2.c.orig	2006-02-24 21:53:00.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/matrox/matroxfb_crtc2.c	2006-02-24 21:53:26.000000000 +0100
@@ -694,12 +694,11 @@ static void* matroxfb_crtc2_probe(struct
 	/* hardware is CRTC2 incapable... */
 	if (!ACCESS_FBINFO(devflags.crtc2))
 		return NULL;
-	m2info = (struct matroxfb_dh_fb_info*)kmalloc(sizeof(*m2info), GFP_KERNEL);
+	m2info = (struct matroxfb_dh_fb_info*)kzalloc(sizeof(*m2info), GFP_KERNEL);
 	if (!m2info) {
 		printk(KERN_ERR "matroxfb_crtc2: Not enough memory for CRTC2 control structs\n");
 		return NULL;
 	}
-	memset(m2info, 0, sizeof(*m2info));
 	m2info->primary_dev = MINFO;
 	if (matroxfb_dh_registerfb(m2info)) {
 		kfree(m2info);
--- linux-2.6.16-rc4/drivers/video/matrox/matroxfb_maven.c.orig	2006-02-24 21:53:35.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/matrox/matroxfb_maven.c	2006-02-24 21:56:22.000000000 +0100
@@ -1243,12 +1243,13 @@ static int maven_detect_client(struct i2
 					      I2C_FUNC_SMBUS_BYTE_DATA |
 					      I2C_FUNC_PROTOCOL_MANGLING))
 		goto ERROR0;
-	if (!(new_client = (struct i2c_client*)kmalloc(sizeof(*new_client) + sizeof(*data),
-			GFP_KERNEL))) {
+
+	new_client = (struct i2c_client*)kzalloc(sizeof(*new_client) + sizeof(*data),
+			GFP_KERNEL);
+	if (!new_client) {
 		err = -ENOMEM;
 		goto ERROR0;
 	}
-	memset(new_client, 0, sizeof(*new_client) + sizeof(*data));
 	data = (struct maven_data*)(new_client + 1);
 	i2c_set_clientdata(new_client, data);
 	new_client->addr = address;
--- linux-2.6.16-rc4/drivers/video/cg14.c.orig	2006-02-24 21:56:33.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/cg14.c	2006-02-24 21:56:52.000000000 +0100
@@ -480,12 +480,11 @@ static void cg14_init_one(struct sbus_de
 		}
 	}
 
-	all = kmalloc(sizeof(*all), GFP_KERNEL);
+	all = kzalloc(sizeof(*all), GFP_KERNEL);
 	if (!all) {
 		printk(KERN_ERR "cg14: Cannot allocate memory.\n");
 		return;
 	}
-	memset(all, 0, sizeof(*all));
 
 	INIT_LIST_HEAD(&all->list);
 
--- linux-2.6.16-rc4/drivers/video/valkyriefb.c.orig	2006-02-24 21:57:03.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/valkyriefb.c	2006-02-24 21:57:14.000000000 +0100
@@ -359,10 +359,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")) {
--- linux-2.6.16-rc4/drivers/video/cg3.c.orig	2006-02-24 21:58:47.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/cg3.c	2006-02-24 21:58:58.000000000 +0100
@@ -369,12 +369,11 @@ static void cg3_init_one(struct sbus_dev
 	struct all_info *all;
 	int linebytes;
 
-	all = kmalloc(sizeof(*all), GFP_KERNEL);
+	all = kzalloc(sizeof(*all), GFP_KERNEL);
 	if (!all) {
 		printk(KERN_ERR "cg3: Cannot allocate memory.\n");
 		return;
 	}
-	memset(all, 0, sizeof(*all));
 
 	INIT_LIST_HEAD(&all->list);
 
--- linux-2.6.16-rc4/drivers/video/aty/atyfb_base.c.orig	2006-02-24 21:59:19.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/aty/atyfb_base.c	2006-02-24 21:59:47.000000000 +0100
@@ -2853,12 +2853,11 @@ static int __devinit atyfb_setup_sparc(s
 		/* nothing */ ;
 	j = i + 4;
 
-	par->mmap_map = kmalloc(j * sizeof(*par->mmap_map), GFP_ATOMIC);
+	par->mmap_map = kzalloc(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];
--- linux-2.6.16-rc4/drivers/video/leo.c.orig	2006-02-24 21:59:55.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/leo.c	2006-02-24 22:00:05.000000000 +0100
@@ -541,12 +541,11 @@ static void leo_init_one(struct sbus_dev
 	struct all_info *all;
 	int linebytes;
 
-	all = kmalloc(sizeof(*all), GFP_KERNEL);
+	all = kzalloc(sizeof(*all), GFP_KERNEL);
 	if (!all) {
 		printk(KERN_ERR "leo: Cannot allocate memory.\n");
 		return;
 	}
-	memset(all, 0, sizeof(*all));
 
 	INIT_LIST_HEAD(&all->list);
 
--- linux-2.6.16-rc4/drivers/video/igafb.c.orig	2006-02-24 22:00:16.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/igafb.c	2006-02-24 22:00:48.000000000 +0100
@@ -404,12 +404,11 @@ int __init igafb_init(void)
 	
 	size = sizeof(struct fb_info) + sizeof(struct iga_par) + sizeof(u32)*16;
 
-        info = kmalloc(size, GFP_ATOMIC);
+        info = kzalloc(size, GFP_ATOMIC);
         if (!info) {
                 printk("igafb_init: can't alloc fb_info\n");
                 return -ENOMEM;
         }
-        memset(info, 0, size);
 
 	par = (struct iga_par *) (info + 1);
 	
@@ -468,7 +467,7 @@ int __init igafb_init(void)
 	 * one additional region with size == 0. 
 	 */
 
-	par->mmap_map = kmalloc(4 * sizeof(*par->mmap_map), GFP_ATOMIC);
+	par->mmap_map = kzalloc(4 * sizeof(*par->mmap_map), GFP_ATOMIC);
 	if (!par->mmap_map) {
 		printk("igafb_init: can't alloc mmap_map\n");
 		iounmap((void *)par->io_base);
@@ -477,8 +476,6 @@ int __init igafb_init(void)
 		return -ENOMEM;
 	}
 
-	memset(par->mmap_map, 0, 4 * sizeof(*par->mmap_map));
-
 	/*
 	 * Set default vmode and cmode from PROM properties.
 	 */
--- linux-2.6.16-rc4/drivers/video/bw2.c.orig	2006-02-24 22:00:58.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/bw2.c	2006-02-24 22:01:05.000000000 +0100
@@ -301,12 +301,11 @@ static void bw2_init_one(struct sbus_dev
 #endif
 	int linebytes;
 
-	all = kmalloc(sizeof(*all), GFP_KERNEL);
+	all = kzalloc(sizeof(*all), GFP_KERNEL);
 	if (!all) {
 		printk(KERN_ERR "bw2: Cannot allocate memory.\n");
 		return;
 	}
-	memset(all, 0, sizeof(*all));
 
 	INIT_LIST_HEAD(&all->list);
 
--- linux-2.6.16-rc4/drivers/video/nvidia/nvidia.c.orig	2006-02-24 22:01:15.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/nvidia/nvidia.c	2006-02-24 22:02:05.000000000 +0100
@@ -1566,13 +1566,11 @@ static int __devinit nvidiafb_probe(stru
 	par = info->par;
 	par->pci_dev = pd;
 
-	info->pixmap.addr = kmalloc(8 * 1024, GFP_KERNEL);
+	info->pixmap.addr = kzalloc(8 * 1024, GFP_KERNEL);
 
 	if (info->pixmap.addr == NULL)
 		goto err_out_kfree;
 
-	memset(info->pixmap.addr, 0, 8 * 1024);
-
 	if (pci_enable_device(pd)) {
 		printk(KERN_ERR PFX "cannot enable PCI device\n");
 		goto err_out_enable;
--- linux-2.6.16-rc4/drivers/video/retz3fb.c.orig	2006-02-24 22:02:16.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/retz3fb.c	2006-02-24 22:02:34.000000000 +0100
@@ -1370,10 +1370,9 @@ int __init retz3fb_init(void)
 			release_mem_region(board_addr, 0x00c00000);
 			continue;
 		}
-		if (!(zinfo = kmalloc(sizeof(struct retz3_fb_info),
+		if (!(zinfo = kzalloc(sizeof(struct retz3_fb_info),
 				      GFP_KERNEL)))
 			return -ENOMEM;
-		memset(zinfo, 0, sizeof(struct retz3_fb_info));
 
 		zinfo->base = ioremap(board_addr, board_size);
 		zinfo->regs = zinfo->base;
--- linux-2.6.16-rc4/drivers/video/tgafb.c.orig	2006-02-24 22:02:42.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/tgafb.c	2006-02-24 22:02:51.000000000 +0100
@@ -1396,12 +1396,11 @@ tgafb_pci_register(struct pci_dev *pdev,
 	}
 
 	/* Allocate the fb and par structures.  */
-	all = kmalloc(sizeof(*all), GFP_KERNEL);
+	all = kzalloc(sizeof(*all), GFP_KERNEL);
 	if (!all) {
 		printk(KERN_ERR "tgafb: Cannot allocate memory\n");
 		return -ENOMEM;
 	}
-	memset(all, 0, sizeof(*all));
 	pci_set_drvdata(pdev, all);
 
 	/* Request the mem regions.  */
--- linux-2.6.16-rc4/drivers/video/i810/i810_main.c.orig	2006-02-24 22:03:12.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/i810/i810_main.c	2006-02-24 22:03:31.000000000 +0100
@@ -2012,11 +2012,10 @@ static int __devinit i810fb_init_pci (st
 	par = info->par;
 	par->dev = dev;
 
-	if (!(info->pixmap.addr = kmalloc(8*1024, GFP_KERNEL))) {
+	if (!(info->pixmap.addr = kzalloc(8*1024, GFP_KERNEL))) {
 		i810fb_release_resource(info, par);
 		return -ENOMEM;
 	}
-	memset(info->pixmap.addr, 0, 8*1024);
 	info->pixmap.size = 8*1024;
 	info->pixmap.buf_align = 8;
 	info->pixmap.access_align = 32;
--- linux-2.6.16-rc4/drivers/video/clps711xfb.c.orig	2006-02-24 22:03:44.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/clps711xfb.c	2006-02-24 22:03:55.000000000 +0100
@@ -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;
--- linux-2.6.16-rc4/drivers/video/controlfb.c.orig	2006-02-24 22:04:05.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/controlfb.c	2006-02-24 22:04:19.000000000 +0100
@@ -694,11 +694,10 @@ static int __init control_of_init(struct
 		printk(KERN_ERR "can't get 2 addresses for control\n");
 		return -ENXIO;
 	}
-	p = kmalloc(sizeof(*p), GFP_KERNEL);
+	p = kzalloc(sizeof(*p), GFP_KERNEL);
 	if (p == 0)
 		return -ENXIO;
 	control_fb = p;	/* save it for cleanups */
-	memset(p, 0, sizeof(*p));
 
 	/* Map in frame buffer and registers */
 	p->fb_orig_base = fb_res.start;
--- linux-2.6.16-rc4/drivers/video/cyber2000fb.c.orig	2006-02-24 22:04:33.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/cyber2000fb.c	2006-02-24 22:04:44.000000000 +0100
@@ -1223,12 +1223,10 @@ cyberpro_alloc_fb_info(unsigned int id, 
 {
 	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;
 
 	if (id == ID_CYBERPRO_5000)
--- linux-2.6.16-rc4/drivers/video/tcx.c.orig	2006-02-24 22:04:54.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/tcx.c	2006-02-24 22:05:03.000000000 +0100
@@ -359,12 +359,11 @@ static void tcx_init_one(struct sbus_dev
 	struct all_info *all;
 	int linebytes, i;
 
-	all = kmalloc(sizeof(*all), GFP_KERNEL);
+	all = kzalloc(sizeof(*all), GFP_KERNEL);
 	if (!all) {
 		printk(KERN_ERR "tcx: Cannot allocate memory.\n");
 		return;
 	}
-	memset(all, 0, sizeof(*all));
 
 	INIT_LIST_HEAD(&all->list);
 
--- linux-2.6.16-rc4/drivers/video/ffb.c.orig	2006-02-24 22:05:11.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/ffb.c	2006-02-24 22:05:17.000000000 +0100
@@ -940,12 +940,11 @@ static void ffb_init_one(int node, int p
 		return;
 	}
 
-	all = kmalloc(sizeof(*all), GFP_KERNEL);
+	all = kzalloc(sizeof(*all), GFP_KERNEL);
 	if (!all) {
 		printk(KERN_ERR "ffb: Cannot allocate memory.\n");
 		return;
 	}
-	memset(all, 0, sizeof(*all));
 
 	INIT_LIST_HEAD(&all->list);	
 
--- linux-2.6.16-rc4/drivers/video/sun3fb.c.orig	2006-02-24 22:05:24.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/sun3fb.c	2006-02-24 22:06:14.000000000 +0100
@@ -526,11 +526,10 @@ static int __init sun3fb_init_fb(int fbt
 	int linebytes, w, h, depth;
 	char *p = NULL;
 	
-	fb = kmalloc(sizeof(struct fb_info_sbusfb), GFP_ATOMIC);
+	fb = kzalloc(sizeof(struct fb_info_sbusfb), GFP_ATOMIC);
 	if (!fb)
 		return -ENOMEM;
 	
-	memset(fb, 0, sizeof(struct fb_info_sbusfb));
 	fix = &fb->fix;
 	var = &fb->var;
 	disp = &fb->disp;
--- linux-2.6.16-rc4/drivers/video/savage/savagefb_driver.c.orig	2006-02-24 22:06:27.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/savage/savagefb_driver.c	2006-02-24 22:06:44.000000000 +0100
@@ -1950,11 +1950,10 @@ static int __devinit savage_init_fb_info
 
 #if defined(CONFIG_FB_SAVAGE_ACCEL)
 	/* FIFO size + padding for commands */
-	info->pixmap.addr = kmalloc(8*1024, GFP_KERNEL);
+	info->pixmap.addr = kzalloc(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;
--- linux-2.6.16-rc4/drivers/video/riva/fbdev.c.orig	2006-02-24 22:08:25.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/riva/fbdev.c	2006-02-24 22:08:44.000000000 +0100
@@ -1888,12 +1888,11 @@ static int __devinit rivafb_probe(struct
 	default_par = info->par;
 	default_par->pdev = pd;
 
-	info->pixmap.addr = kmalloc(8 * 1024, GFP_KERNEL);
+	info->pixmap.addr = kzalloc(8 * 1024, GFP_KERNEL);
 	if (info->pixmap.addr == NULL) {
 	    	ret = -ENOMEM;
 		goto err_framebuffer_release;
 	}
-	memset(info->pixmap.addr, 0, 8 * 1024);
 
 	ret = pci_enable_device(pd);
 	if (ret < 0) {
--- linux-2.6.16-rc4/drivers/video/cg6.c.orig	2006-02-24 22:08:54.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/cg6.c	2006-02-24 22:09:03.000000000 +0100
@@ -667,12 +667,11 @@ static void cg6_init_one(struct sbus_dev
 	struct all_info *all;
 	int linebytes;
 
-	all = kmalloc(sizeof(*all), GFP_KERNEL);
+	all = kzalloc(sizeof(*all), GFP_KERNEL);
 	if (!all) {
 		printk(KERN_ERR "cg6: Cannot allocate memory.\n");
 		return;
 	}
-	memset(all, 0, sizeof(*all));
 
 	INIT_LIST_HEAD(&all->list);
 
--- linux-2.6.16-rc4/drivers/video/p9100.c.orig	2006-02-24 22:09:11.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/p9100.c	2006-02-24 22:09:18.000000000 +0100
@@ -272,12 +272,11 @@ static void p9100_init_one(struct sbus_d
 	struct all_info *all;
 	int linebytes;
 
-	all = kmalloc(sizeof(*all), GFP_KERNEL);
+	all = kzalloc(sizeof(*all), GFP_KERNEL);
 	if (!all) {
 		printk(KERN_ERR "p9100: Cannot allocate memory.\n");
 		return;
 	}
-	memset(all, 0, sizeof(*all));
 
 	INIT_LIST_HEAD(&all->list);
 
--- linux-2.6.16-rc4/drivers/video/intelfb/intelfbdrv.c.orig	2006-02-24 22:09:32.000000000 +0100
+++ linux-2.6.16-rc4/drivers/video/intelfb/intelfbdrv.c	2006-02-24 22:09:43.000000000 +0100
@@ -526,12 +526,11 @@ intelfb_pci_register(struct pci_dev *pde
 	dinfo->pdev  = pdev;
 
 	/* Reserve pixmap space. */
-	info->pixmap.addr = kmalloc(64 * 1024, GFP_KERNEL);
+	info->pixmap.addr = kzalloc(64 * 1024, GFP_KERNEL);
 	if (info->pixmap.addr == NULL) {
 		ERR_MSG("Cannot reserve pixmap memory.\n");
 		goto err_out_pixmap;
 	}
-	memset(info->pixmap.addr, 0, 64 * 1024);
 
 	/* set early this option because it could be changed by tv encoder
 	   driver */



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/atm
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
@ 2006-02-27  9:22 ` Eric Sesterhenn
  2006-02-27  9:43 ` Tobias Klauser
                   ` (30 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-02-27  9:22 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 8306 bytes --]

hi,

this patch converts drivers/video to kzalloc usage.
Compile tested with allyes config.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc4/drivers/atm/adummy.c.orig	2006-02-27 09:02:51.000000000 +0100
+++ linux-2.6.16-rc4/drivers/atm/adummy.c	2006-02-27 09:03:09.000000000 +0100
@@ -114,14 +114,13 @@ static int __init adummy_init(void)
 
 	printk(KERN_ERR "adummy: version %s\n", DRV_VERSION);
 
-	adummy_dev = (struct adummy_dev *) kmalloc(sizeof(struct adummy_dev),
+	adummy_dev = (struct adummy_dev *) kzalloc(sizeof(struct adummy_dev),
 						   GFP_KERNEL);
 	if (!adummy_dev) {
-		printk(KERN_ERR DEV_LABEL ": kmalloc() failed\n");
+		printk(KERN_ERR DEV_LABEL ": kzalloc() failed\n");
 		err = -ENOMEM;
 		goto out;
 	}
-	memset(adummy_dev, 0, sizeof(struct adummy_dev));
 
 	atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, NULL);
 	if (!atm_dev) {
--- linux-2.6.16-rc4/drivers/atm/he.c.orig	2006-02-27 09:03:20.000000000 +0100
+++ linux-2.6.16-rc4/drivers/atm/he.c	2006-02-27 09:12:51.000000000 +0100
@@ -384,13 +384,12 @@ he_init_one(struct pci_dev *pci_dev, con
 	}
 	pci_set_drvdata(pci_dev, atm_dev);
 
-	he_dev = (struct he_dev *) kmalloc(sizeof(struct he_dev),
+	he_dev = (struct he_dev *) kzalloc(sizeof(struct he_dev),
 							GFP_KERNEL);
 	if (!he_dev) {
 		err = -ENOMEM;
 		goto init_one_failure;
 	}
-	memset(he_dev, 0, sizeof(struct he_dev));
 
 	he_dev->pci_dev = pci_dev;
 	he_dev->atm_dev = atm_dev;
--- linux-2.6.16-rc4/drivers/atm/idt77252.c.orig	2006-02-27 09:13:10.000000000 +0100
+++ linux-2.6.16-rc4/drivers/atm/idt77252.c	2006-02-27 09:14:29.000000000 +0100
@@ -642,10 +642,9 @@ alloc_scq(struct idt77252_dev *card, int
 {
 	struct scq_info *scq;
 
-	scq = (struct scq_info *) kmalloc(sizeof(struct scq_info), GFP_KERNEL);
+	scq = (struct scq_info *) kzalloc(sizeof(struct scq_info), GFP_KERNEL);
 	if (!scq)
 		return NULL;
-	memset(scq, 0, sizeof(struct scq_info));
 
 	scq->base = pci_alloc_consistent(card->pcidev, SCQ_SIZE,
 					 &scq->paddr);
@@ -2142,10 +2141,9 @@ idt77252_init_est(struct vc_map *vc, int
 {
 	struct rate_estimator *est;
 
-	est = kmalloc(sizeof(struct rate_estimator), GFP_KERNEL);
+	est = kzalloc(sizeof(struct rate_estimator), GFP_KERNEL);
 	if (!est)
 		return NULL;
-	memset(est, 0, sizeof(*est));
 
 	est->maxcps = pcr < 0 ? -pcr : pcr;
 	est->cps = est->maxcps;
@@ -2451,13 +2449,12 @@ idt77252_open(struct atm_vcc *vcc)
 
 	index = VPCI2VC(card, vpi, vci);
 	if (!card->vcs[index]) {
-		card->vcs[index] = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+		card->vcs[index] = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
 		if (!card->vcs[index]) {
 			printk("%s: can't alloc vc in open()\n", card->name);
 			up(&card->mutex);
 			return -ENOMEM;
 		}
-		memset(card->vcs[index], 0, sizeof(struct vc_map));
 
 		card->vcs[index]->card = card;
 		card->vcs[index]->index = index;
@@ -2926,12 +2923,11 @@ open_card_oam(struct idt77252_dev *card)
 		for (vci = 3; vci < 5; vci++) {
 			index = VPCI2VC(card, vpi, vci);
 
-			vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+			vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
 			if (!vc) {
 				printk("%s: can't alloc vc\n", card->name);
 				return -ENOMEM;
 			}
-			memset(vc, 0, sizeof(struct vc_map));
 
 			vc->index = index;
 			card->vcs[index] = vc;
@@ -2995,12 +2991,11 @@ open_card_ubr0(struct idt77252_dev *card
 {
 	struct vc_map *vc;
 
-	vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+	vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
 	if (!vc) {
 		printk("%s: can't alloc vc\n", card->name);
 		return -ENOMEM;
 	}
-	memset(vc, 0, sizeof(struct vc_map));
 	card->vcs[0] = vc;
 	vc->class = SCHED_UBR0;
 
@@ -3695,13 +3690,12 @@ idt77252_init_one(struct pci_dev *pcidev
 		goto err_out_disable_pdev;
 	}
 
-	card = kmalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
+	card = kzalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
 	if (!card) {
 		printk("idt77252-%d: can't allocate private data\n", index);
 		err = -ENOMEM;
 		goto err_out_disable_pdev;
 	}
-	memset(card, 0, sizeof(struct idt77252_dev));
 
 	card->revision = revision;
 	card->index = index;
--- linux-2.6.16-rc4/drivers/atm/iphase.c.orig	2006-02-27 09:14:41.000000000 +0100
+++ linux-2.6.16-rc4/drivers/atm/iphase.c	2006-02-27 09:16:20.000000000 +0100
@@ -1601,14 +1601,13 @@ static int rx_init(struct atm_dev *dev) 
   
 	skb_queue_head_init(&iadev->rx_dma_q);  
 	iadev->rx_free_desc_qhead = NULL;   
-	iadev->rx_open = kmalloc(4*iadev->num_vc,GFP_KERNEL);
+	iadev->rx_open = kzalloc(4*iadev->num_vc,GFP_KERNEL);
 	if (!iadev->rx_open)  
 	{  
 		printk(KERN_ERR DEV_LABEL "itf %d couldn't get free page\n",
 		dev->number);  
 		goto err_free_dle;
 	}  
-	memset(iadev->rx_open, 0, 4*iadev->num_vc);  
         iadev->rxing = 1;
         iadev->rx_pkt_cnt = 0;
 	/* Mode Register */  
@@ -3174,12 +3173,11 @@ static int __devinit ia_init_one(struct 
         unsigned long flags;
 	int ret;
 
-	iadev = kmalloc(sizeof(*iadev), GFP_KERNEL); 
+	iadev = kzalloc(sizeof(*iadev), GFP_KERNEL); 
 	if (!iadev) {
 		ret = -ENOMEM;
 		goto err_out;
 	}
-	memset(iadev, 0, sizeof(*iadev));
 	iadev->pci = pdev;
 
 	IF_INIT(printk("ia detected at bus:%d dev: %d function:%d\n",
--- linux-2.6.16-rc4/drivers/atm/firestream.c.orig	2006-02-27 09:16:29.000000000 +0100
+++ linux-2.6.16-rc4/drivers/atm/firestream.c	2006-02-27 09:17:37.000000000 +0100
@@ -1782,7 +1782,7 @@ static int __devinit fs_init (struct fs_
 		write_fs (dev, RAM, (1 << (28 - FS155_VPI_BITS - FS155_VCI_BITS)) - 1);
 		dev->nchannels = FS155_NR_CHANNELS;
 	}
-	dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *), 
+	dev->atm_vccs = kcalloc(dev->nchannels, sizeof (struct atm_vcc *), 
 				 GFP_KERNEL);
 	fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n",
 		    dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *));
@@ -1792,9 +1792,8 @@ static int __devinit fs_init (struct fs_
 		/* XXX Clean up..... */
 		return 1;
 	}
-	memset (dev->atm_vccs, 0, dev->nchannels * sizeof (struct atm_vcc *));
 
-	dev->tx_inuse = kmalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
+	dev->tx_inuse = kzalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
 	fs_dprintk (FS_DEBUG_ALLOC, "Alloc tx_inuse: %p(%d)\n", 
 		    dev->atm_vccs, dev->nchannels / 8);
 
@@ -1803,7 +1802,6 @@ static int __devinit fs_init (struct fs_
 		/* XXX Clean up..... */
 		return 1;
 	}
-	memset (dev->tx_inuse, 0, dev->nchannels / 8);
 
 	/* -- RAS1 : FS155 and 50 differ. Default (0) should be OK for both */
 	/* -- RAS2 : FS50 only: Default is OK. */
@@ -1891,14 +1889,12 @@ static int __devinit firestream_init_one
 	if (pci_enable_device(pci_dev)) 
 		goto err_out;
 
-	fs_dev = kmalloc (sizeof (struct fs_dev), GFP_KERNEL);
+	fs_dev = kzalloc (sizeof (struct fs_dev), GFP_KERNEL);
 	fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%Zd)\n",
 		    fs_dev, sizeof (struct fs_dev));
 	if (!fs_dev)
 		goto err_out;
 
-	memset (fs_dev, 0, sizeof (struct fs_dev));
-  
 	atm_dev = atm_dev_register("fs", &ops, -1, NULL);
 	if (!atm_dev)
 		goto err_out_free_fs_dev;
--- linux-2.6.16-rc4/drivers/atm/zatm.c.orig	2006-02-27 09:17:47.000000000 +0100
+++ linux-2.6.16-rc4/drivers/atm/zatm.c	2006-02-27 09:18:24.000000000 +0100
@@ -604,9 +604,9 @@ static int start_rx(struct atm_dev *dev)
 DPRINTK("start_rx\n");
 	zatm_dev = ZATM_DEV(dev);
 	size = sizeof(struct atm_vcc *)*zatm_dev->chans;
-	zatm_dev->rx_map = (struct atm_vcc **) kmalloc(size,GFP_KERNEL);
-	if (!zatm_dev->rx_map) return -ENOMEM;
-	memset(zatm_dev->rx_map,0,size);
+	zatm_dev->rx_map = (struct atm_vcc **) kzalloc(size, GFP_KERNEL);
+	if (!zatm_dev->rx_map)
+		return -ENOMEM;
 	/* set VPI/VCI split (use all VCIs and give what's left to VPIs) */
 	zpokel(zatm_dev,(1 << dev->ci_range.vci_bits)-1,uPD98401_VRR);
 	/* prepare free buffer pools */
@@ -952,9 +952,9 @@ static int open_tx_first(struct atm_vcc 
 	skb_queue_head_init(&zatm_vcc->tx_queue);
 	init_waitqueue_head(&zatm_vcc->tx_wait);
 	/* initialize ring */
-	zatm_vcc->ring = kmalloc(RING_SIZE,GFP_KERNEL);
-	if (!zatm_vcc->ring) return -ENOMEM;
-	memset(zatm_vcc->ring,0,RING_SIZE);
+	zatm_vcc->ring = kzalloc(RING_SIZE, GFP_KERNEL);
+	if (!zatm_vcc->ring)
+		return -ENOMEM;
 	loop = zatm_vcc->ring+RING_ENTRIES*RING_WORDS;
 	loop[0] = uPD98401_TXPD_V;
 	loop[1] = loop[2] = 0;



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [KJ] [Patch] kzalloc() conversion in drivers/atm
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
  2006-02-27  9:22 ` [KJ] [Patch] kzalloc() conversion in drivers/atm Eric Sesterhenn
@ 2006-02-27  9:43 ` Tobias Klauser
  2006-02-27 11:16 ` Eric Sesterhenn
                   ` (29 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Tobias Klauser @ 2006-02-27  9:43 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 2053 bytes --]

On 2006-02-27 at 10:22:36 +0100, Eric Sesterhenn <snakebyte@gmx.de> wrote:
> --- linux-2.6.16-rc4/drivers/atm/adummy.c.orig	2006-02-27 09:02:51.000000000 +0100
> +++ linux-2.6.16-rc4/drivers/atm/adummy.c	2006-02-27 09:03:09.000000000 +0100
> @@ -114,14 +114,13 @@ static int __init adummy_init(void)
>  
>  	printk(KERN_ERR "adummy: version %s\n", DRV_VERSION);
>  
> -	adummy_dev = (struct adummy_dev *) kmalloc(sizeof(struct adummy_dev),
> +	adummy_dev = (struct adummy_dev *) kzalloc(sizeof(struct adummy_dev),
>  						   GFP_KERNEL);

Casting kmalloc/kzalloc return values is not necessary.

[...]
> --- linux-2.6.16-rc4/drivers/atm/he.c.orig	2006-02-27 09:03:20.000000000 +0100
> +++ linux-2.6.16-rc4/drivers/atm/he.c	2006-02-27 09:12:51.000000000 +0100
> @@ -384,13 +384,12 @@ he_init_one(struct pci_dev *pci_dev, con
>  	}
>  	pci_set_drvdata(pci_dev, atm_dev);
>  
> -	he_dev = (struct he_dev *) kmalloc(sizeof(struct he_dev),
> +	he_dev = (struct he_dev *) kzalloc(sizeof(struct he_dev),
>  							GFP_KERNEL);

Same here.

[...]
> --- linux-2.6.16-rc4/drivers/atm/idt77252.c.orig	2006-02-27 09:13:10.000000000 +0100
> +++ linux-2.6.16-rc4/drivers/atm/idt77252.c	2006-02-27 09:14:29.000000000 +0100
> @@ -642,10 +642,9 @@ alloc_scq(struct idt77252_dev *card, int
>  {
>  	struct scq_info *scq;
>  
> -	scq = (struct scq_info *) kmalloc(sizeof(struct scq_info), GFP_KERNEL);
> +	scq = (struct scq_info *) kzalloc(sizeof(struct scq_info), GFP_KERNEL);

Ditto

[...]
> --- linux-2.6.16-rc4/drivers/atm/zatm.c.orig	2006-02-27 09:17:47.000000000 +0100
> +++ linux-2.6.16-rc4/drivers/atm/zatm.c	2006-02-27 09:18:24.000000000 +0100
> @@ -604,9 +604,9 @@ static int start_rx(struct atm_dev *dev)
>  DPRINTK("start_rx\n");
>  	zatm_dev = ZATM_DEV(dev);
>  	size = sizeof(struct atm_vcc *)*zatm_dev->chans;
> -	zatm_dev->rx_map = (struct atm_vcc **) kmalloc(size,GFP_KERNEL);
> -	if (!zatm_dev->rx_map) return -ENOMEM;
> -	memset(zatm_dev->rx_map,0,size);
> +	zatm_dev->rx_map = (struct atm_vcc **) kzalloc(size, GFP_KERNEL);

Same here

Cheers, Tobias

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [KJ] [Patch] kzalloc() conversion in drivers/atm
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
  2006-02-27  9:22 ` [KJ] [Patch] kzalloc() conversion in drivers/atm Eric Sesterhenn
  2006-02-27  9:43 ` Tobias Klauser
@ 2006-02-27 11:16 ` Eric Sesterhenn
  2006-02-27 16:22 ` [KJ] [Patch] kzalloc() conversion in drivers/usb Eric Sesterhenn
                   ` (28 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-02-27 11:16 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 8922 bytes --]

On Mon, 2006-02-27 at 10:43 +0100, Tobias Klauser wrote:
> On 2006-02-27 at 10:22:36 +0100, Eric Sesterhenn <snakebyte@gmx.de> wrote:
> > --- linux-2.6.16-rc4/drivers/atm/adummy.c.orig	2006-02-27 09:02:51.000000000 +0100
> > +++ linux-2.6.16-rc4/drivers/atm/adummy.c	2006-02-27 09:03:09.000000000 +0100
> > @@ -114,14 +114,13 @@ static int __init adummy_init(void)
> >  
> >  	printk(KERN_ERR "adummy: version %s\n", DRV_VERSION);
> >  
> > -	adummy_dev = (struct adummy_dev *) kmalloc(sizeof(struct adummy_dev),
> > +	adummy_dev = (struct adummy_dev *) kzalloc(sizeof(struct adummy_dev),
> >  						   GFP_KERNEL);
> 
> Casting kmalloc/kzalloc return values is not necessary.

here is an updated patch. Also compile tested with allyesconfig

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc4/drivers/atm/adummy.c.orig	2006-02-27 09:02:51.000000000 +0100
+++ linux-2.6.16-rc4/drivers/atm/adummy.c	2006-02-27 11:33:33.000000000 +0100
@@ -114,14 +114,12 @@ static int __init adummy_init(void)
 
 	printk(KERN_ERR "adummy: version %s\n", DRV_VERSION);
 
-	adummy_dev = (struct adummy_dev *) kmalloc(sizeof(struct adummy_dev),
-						   GFP_KERNEL);
+	adummy_dev = kzalloc(sizeof(struct adummy_dev), GFP_KERNEL);
 	if (!adummy_dev) {
-		printk(KERN_ERR DEV_LABEL ": kmalloc() failed\n");
+		printk(KERN_ERR DEV_LABEL ": kzalloc() failed\n");
 		err = -ENOMEM;
 		goto out;
 	}
-	memset(adummy_dev, 0, sizeof(struct adummy_dev));
 
 	atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, NULL);
 	if (!atm_dev) {
--- linux-2.6.16-rc4/drivers/atm/he.c.orig	2006-02-27 09:03:20.000000000 +0100
+++ linux-2.6.16-rc4/drivers/atm/he.c	2006-02-27 11:34:34.000000000 +0100
@@ -384,13 +384,11 @@ he_init_one(struct pci_dev *pci_dev, con
 	}
 	pci_set_drvdata(pci_dev, atm_dev);
 
-	he_dev = (struct he_dev *) kmalloc(sizeof(struct he_dev),
-							GFP_KERNEL);
+	he_dev = kzalloc(sizeof(struct he_dev), GFP_KERNEL);
 	if (!he_dev) {
 		err = -ENOMEM;
 		goto init_one_failure;
 	}
-	memset(he_dev, 0, sizeof(struct he_dev));
 
 	he_dev->pci_dev = pci_dev;
 	he_dev->atm_dev = atm_dev;
--- linux-2.6.16-rc4/drivers/atm/idt77252.c.orig	2006-02-27 09:13:10.000000000 +0100
+++ linux-2.6.16-rc4/drivers/atm/idt77252.c	2006-02-27 11:35:35.000000000 +0100
@@ -642,10 +642,9 @@ alloc_scq(struct idt77252_dev *card, int
 {
 	struct scq_info *scq;
 
-	scq = (struct scq_info *) kmalloc(sizeof(struct scq_info), GFP_KERNEL);
+	scq = kzalloc(sizeof(struct scq_info), GFP_KERNEL);
 	if (!scq)
 		return NULL;
-	memset(scq, 0, sizeof(struct scq_info));
 
 	scq->base = pci_alloc_consistent(card->pcidev, SCQ_SIZE,
 					 &scq->paddr);
@@ -2142,10 +2141,9 @@ idt77252_init_est(struct vc_map *vc, int
 {
 	struct rate_estimator *est;
 
-	est = kmalloc(sizeof(struct rate_estimator), GFP_KERNEL);
+	est = kzalloc(sizeof(struct rate_estimator), GFP_KERNEL);
 	if (!est)
 		return NULL;
-	memset(est, 0, sizeof(*est));
 
 	est->maxcps = pcr < 0 ? -pcr : pcr;
 	est->cps = est->maxcps;
@@ -2451,13 +2449,12 @@ idt77252_open(struct atm_vcc *vcc)
 
 	index = VPCI2VC(card, vpi, vci);
 	if (!card->vcs[index]) {
-		card->vcs[index] = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+		card->vcs[index] = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
 		if (!card->vcs[index]) {
 			printk("%s: can't alloc vc in open()\n", card->name);
 			up(&card->mutex);
 			return -ENOMEM;
 		}
-		memset(card->vcs[index], 0, sizeof(struct vc_map));
 
 		card->vcs[index]->card = card;
 		card->vcs[index]->index = index;
@@ -2926,12 +2923,11 @@ open_card_oam(struct idt77252_dev *card)
 		for (vci = 3; vci < 5; vci++) {
 			index = VPCI2VC(card, vpi, vci);
 
-			vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+			vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
 			if (!vc) {
 				printk("%s: can't alloc vc\n", card->name);
 				return -ENOMEM;
 			}
-			memset(vc, 0, sizeof(struct vc_map));
 
 			vc->index = index;
 			card->vcs[index] = vc;
@@ -2995,12 +2991,11 @@ open_card_ubr0(struct idt77252_dev *card
 {
 	struct vc_map *vc;
 
-	vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL);
+	vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
 	if (!vc) {
 		printk("%s: can't alloc vc\n", card->name);
 		return -ENOMEM;
 	}
-	memset(vc, 0, sizeof(struct vc_map));
 	card->vcs[0] = vc;
 	vc->class = SCHED_UBR0;
 
@@ -3695,13 +3690,12 @@ idt77252_init_one(struct pci_dev *pcidev
 		goto err_out_disable_pdev;
 	}
 
-	card = kmalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
+	card = kzalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
 	if (!card) {
 		printk("idt77252-%d: can't allocate private data\n", index);
 		err = -ENOMEM;
 		goto err_out_disable_pdev;
 	}
-	memset(card, 0, sizeof(struct idt77252_dev));
 
 	card->revision = revision;
 	card->index = index;
--- linux-2.6.16-rc4/drivers/atm/iphase.c.orig	2006-02-27 09:14:41.000000000 +0100
+++ linux-2.6.16-rc4/drivers/atm/iphase.c	2006-02-27 09:16:20.000000000 +0100
@@ -1601,14 +1601,13 @@ static int rx_init(struct atm_dev *dev) 
   
 	skb_queue_head_init(&iadev->rx_dma_q);  
 	iadev->rx_free_desc_qhead = NULL;   
-	iadev->rx_open = kmalloc(4*iadev->num_vc,GFP_KERNEL);
+	iadev->rx_open = kzalloc(4*iadev->num_vc,GFP_KERNEL);
 	if (!iadev->rx_open)  
 	{  
 		printk(KERN_ERR DEV_LABEL "itf %d couldn't get free page\n",
 		dev->number);  
 		goto err_free_dle;
 	}  
-	memset(iadev->rx_open, 0, 4*iadev->num_vc);  
         iadev->rxing = 1;
         iadev->rx_pkt_cnt = 0;
 	/* Mode Register */  
@@ -3174,12 +3173,11 @@ static int __devinit ia_init_one(struct 
         unsigned long flags;
 	int ret;
 
-	iadev = kmalloc(sizeof(*iadev), GFP_KERNEL); 
+	iadev = kzalloc(sizeof(*iadev), GFP_KERNEL); 
 	if (!iadev) {
 		ret = -ENOMEM;
 		goto err_out;
 	}
-	memset(iadev, 0, sizeof(*iadev));
 	iadev->pci = pdev;
 
 	IF_INIT(printk("ia detected at bus:%d dev: %d function:%d\n",
--- linux-2.6.16-rc4/drivers/atm/firestream.c.orig	2006-02-27 09:16:29.000000000 +0100
+++ linux-2.6.16-rc4/drivers/atm/firestream.c	2006-02-27 09:17:37.000000000 +0100
@@ -1782,7 +1782,7 @@ static int __devinit fs_init (struct fs_
 		write_fs (dev, RAM, (1 << (28 - FS155_VPI_BITS - FS155_VCI_BITS)) - 1);
 		dev->nchannels = FS155_NR_CHANNELS;
 	}
-	dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *), 
+	dev->atm_vccs = kcalloc(dev->nchannels, sizeof (struct atm_vcc *), 
 				 GFP_KERNEL);
 	fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n",
 		    dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *));
@@ -1792,9 +1792,8 @@ static int __devinit fs_init (struct fs_
 		/* XXX Clean up..... */
 		return 1;
 	}
-	memset (dev->atm_vccs, 0, dev->nchannels * sizeof (struct atm_vcc *));
 
-	dev->tx_inuse = kmalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
+	dev->tx_inuse = kzalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
 	fs_dprintk (FS_DEBUG_ALLOC, "Alloc tx_inuse: %p(%d)\n", 
 		    dev->atm_vccs, dev->nchannels / 8);
 
@@ -1803,7 +1802,6 @@ static int __devinit fs_init (struct fs_
 		/* XXX Clean up..... */
 		return 1;
 	}
-	memset (dev->tx_inuse, 0, dev->nchannels / 8);
 
 	/* -- RAS1 : FS155 and 50 differ. Default (0) should be OK for both */
 	/* -- RAS2 : FS50 only: Default is OK. */
@@ -1891,14 +1889,12 @@ static int __devinit firestream_init_one
 	if (pci_enable_device(pci_dev)) 
 		goto err_out;
 
-	fs_dev = kmalloc (sizeof (struct fs_dev), GFP_KERNEL);
+	fs_dev = kzalloc (sizeof (struct fs_dev), GFP_KERNEL);
 	fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%Zd)\n",
 		    fs_dev, sizeof (struct fs_dev));
 	if (!fs_dev)
 		goto err_out;
 
-	memset (fs_dev, 0, sizeof (struct fs_dev));
-  
 	atm_dev = atm_dev_register("fs", &ops, -1, NULL);
 	if (!atm_dev)
 		goto err_out_free_fs_dev;
--- linux-2.6.16-rc4/drivers/atm/zatm.c.orig	2006-02-27 09:17:47.000000000 +0100
+++ linux-2.6.16-rc4/drivers/atm/zatm.c	2006-02-27 09:18:24.000000000 +0100
@@ -604,9 +604,9 @@ static int start_rx(struct atm_dev *dev)
 DPRINTK("start_rx\n");
 	zatm_dev = ZATM_DEV(dev);
 	size = sizeof(struct atm_vcc *)*zatm_dev->chans;
-	zatm_dev->rx_map = (struct atm_vcc **) kmalloc(size,GFP_KERNEL);
-	if (!zatm_dev->rx_map) return -ENOMEM;
-	memset(zatm_dev->rx_map,0,size);
+	zatm_dev->rx_map = (struct atm_vcc **) kzalloc(size, GFP_KERNEL);
+	if (!zatm_dev->rx_map)
+		return -ENOMEM;
 	/* set VPI/VCI split (use all VCIs and give what's left to VPIs) */
 	zpokel(zatm_dev,(1 << dev->ci_range.vci_bits)-1,uPD98401_VRR);
 	/* prepare free buffer pools */
@@ -952,9 +952,9 @@ static int open_tx_first(struct atm_vcc 
 	skb_queue_head_init(&zatm_vcc->tx_queue);
 	init_waitqueue_head(&zatm_vcc->tx_wait);
 	/* initialize ring */
-	zatm_vcc->ring = kmalloc(RING_SIZE,GFP_KERNEL);
-	if (!zatm_vcc->ring) return -ENOMEM;
-	memset(zatm_vcc->ring,0,RING_SIZE);
+	zatm_vcc->ring = kzalloc(RING_SIZE, GFP_KERNEL);
+	if (!zatm_vcc->ring)
+		return -ENOMEM;
 	loop = zatm_vcc->ring+RING_ENTRIES*RING_WORDS;
 	loop[0] = uPD98401_TXPD_V;
 	loop[1] = loop[2] = 0;



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/usb
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (2 preceding siblings ...)
  2006-02-27 11:16 ` Eric Sesterhenn
@ 2006-02-27 16:22 ` Eric Sesterhenn
  2006-02-27 20:36 ` [KJ] [Patch] kzalloc() conversion in drivers/usb/gadget Eric Sesterhenn
                   ` (27 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-02-27 16:22 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 46927 bytes --]

hi,

this patch converts drivers/usb to kzalloc usage.
Compile tested with allyes config.

This also fixes a bug in drivers/usb/serial/cp2101.c
where memset() was used before checking if kmalloc() returns NULL.

I think there also was a bug in drivers/usb/gadget/inode.c because
it used sizeof(*data) for the kmalloc() and sizeof(data) for
the memset(), since sizeof(data) just returns the size for a pointer.

I assume there is also a bug in drivers/usb/gadget/omap_udc.c
in omap_alloc_request(), req gets allocated via kmalloc() and
the function returns &req->req, no matter if req is NULL, which
looks like a NULL dereference to me, maybe someone who is more familar
with this code might have a look at it.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc4/drivers/usb/net/zd1201.c.orig	2006-02-27 16:26:16.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/net/zd1201.c	2006-02-27 16:26:47.000000000 +0100
@@ -621,10 +621,9 @@ static int zd1201_drvr_start(struct zd12
 	__le16 zdmax;
 	unsigned char *buffer;
 	
-	buffer = kmalloc(ZD1201_RXSIZE, GFP_KERNEL);
+	buffer = kzalloc(ZD1201_RXSIZE, GFP_KERNEL);
 	if (!buffer)
 		return -ENOMEM;
-	memset(buffer, 0, ZD1201_RXSIZE);
 
 	usb_fill_bulk_urb(zd->rx_urb, zd->usb, 
 	    usb_rcvbulkpipe(zd->usb, zd->endp_in), buffer, ZD1201_RXSIZE,
@@ -1750,11 +1749,9 @@ static int zd1201_probe(struct usb_inter
 
 	usb = interface_to_usbdev(interface);
 
-	zd = kmalloc(sizeof(struct zd1201), GFP_KERNEL);
-	if (!zd) {
+	zd = kzalloc(sizeof(struct zd1201), GFP_KERNEL);
+	if (!zd)
 		return -ENOMEM;
-	}
-	memset(zd, 0, sizeof(struct zd1201));
 	zd->ap = ap;
 	zd->usb = usb;
 	zd->removed = 0;
--- linux-2.6.16-rc4/drivers/usb/class/usb-midi.c.orig	2006-02-27 16:27:26.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/class/usb-midi.c	2006-02-27 16:28:15.000000000 +0100
@@ -995,12 +995,11 @@ static struct midi_in_endpoint *alloc_mi
 	bufSize = usb_maxpacket( d, pipe, 0 );
 	/* usb_pipein() = ! usb_pipeout() = true for an in Endpoint */
 
-	ep = (struct midi_in_endpoint *)kmalloc(sizeof(struct midi_in_endpoint), GFP_KERNEL);
+	ep = kzalloc(sizeof(struct midi_in_endpoint), GFP_KERNEL);
 	if ( !ep ) {
 		printk(KERN_ERR "usbmidi: no memory for midi in-endpoint\n");
 		return NULL;
 	}
-	memset( ep, 0, sizeof(struct midi_in_endpoint) );
 //      this sets cables[] and readers to 0, too.
 //      for (i=0; i<16; i++) ep->cables[i] = 0; // discard cable
 //      ep->readers = 0;
@@ -1065,12 +1064,11 @@ static struct midi_out_endpoint *alloc_m
 	pipe =  usb_sndbulkpipe( d, endPoint );
 	bufSize = usb_maxpacket( d, pipe, 1 );
 
-	ep = (struct midi_out_endpoint *)kmalloc(sizeof(struct midi_out_endpoint), GFP_KERNEL);
+	ep = kzalloc(sizeof(struct midi_out_endpoint), GFP_KERNEL);
 	if ( !ep ) {
 		printk(KERN_ERR "usbmidi: no memory for midi out-endpoint\n");
 		return NULL;
 	}
-	memset( ep, 0, sizeof(struct midi_out_endpoint) );
 
 	ep->endpoint = endPoint;
 	ep->buf = (unsigned char *)kmalloc(sizeof(unsigned char)*bufSize, GFP_KERNEL);
@@ -1958,11 +1956,10 @@ static int usb_midi_probe(struct usb_int
 	struct usb_device *dev = interface_to_usbdev(intf);
 	int ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
 
-	s = (struct usb_midi_state *)kmalloc(sizeof(struct usb_midi_state), GFP_KERNEL);
+	s = kzalloc(sizeof(struct usb_midi_state), GFP_KERNEL);
 	if ( !s )
 		return -ENOMEM;
 
-	memset( s, 0, sizeof(struct usb_midi_state) );
 	INIT_LIST_HEAD(&s->midiDevList);
 	INIT_LIST_HEAD(&s->inEndpointList);
 	INIT_LIST_HEAD(&s->outEndpointList);
--- linux-2.6.16-rc4/drivers/usb/class/audio.c.orig	2006-02-27 16:28:41.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/class/audio.c	2006-02-27 16:29:24.000000000 +0100
@@ -2804,9 +2804,8 @@ static void usb_audio_parsestreaming(str
 	unsigned char *fmt, *csep;
 	unsigned int i, j, k, format, idx;
 
-	if (!(as = kmalloc(sizeof(struct usb_audiodev), GFP_KERNEL)))
+	if (!(as = kzalloc(sizeof(struct usb_audiodev), GFP_KERNEL)))
 		return;
-	memset(as, 0, sizeof(struct usb_audiodev));
 	init_waitqueue_head(&as->usbin.dma.wait);
 	init_waitqueue_head(&as->usbout.dma.wait);
 	spin_lock_init(&as->lock);
@@ -3646,9 +3645,8 @@ static struct usb_audio_state *usb_audio
 	unsigned char *p1;
 	unsigned int i, j, k, numifin = 0, numifout = 0;
 	
-	if (!(s = kmalloc(sizeof(struct usb_audio_state), GFP_KERNEL)))
+	if (!(s = kzalloc(sizeof(struct usb_audio_state), GFP_KERNEL)))
 		return NULL;
-	memset(s, 0, sizeof(struct usb_audio_state));
 	INIT_LIST_HEAD(&s->audiolist);
 	INIT_LIST_HEAD(&s->mixerlist);
 	s->usbdev = dev;
--- linux-2.6.16-rc4/drivers/usb/media/pwc/pwc-if.c.orig	2006-02-27 16:29:40.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/media/pwc/pwc-if.c	2006-02-27 16:29:52.000000000 +0100
@@ -1871,12 +1871,11 @@ static int usb_pwc_probe(struct usb_inte
 		Info("Warning: more than 1 configuration available.\n");
 
 	/* Allocate structure, initialize pointers, mutexes, etc. and link it to the usb_device */
-	pdev = kmalloc(sizeof(struct pwc_device), GFP_KERNEL);
+	pdev = kzalloc(sizeof(struct pwc_device), GFP_KERNEL);
 	if (pdev == NULL) {
 		Err("Oops, could not allocate memory for pwc_device.\n");
 		return -ENOMEM;
 	}
-	memset(pdev, 0, sizeof(struct pwc_device));
 	pdev->type = type_id;
 	pdev->vsize = default_size;
 	pdev->vframes = default_fps;
--- linux-2.6.16-rc4/drivers/usb/media/w9968cf.c.orig	2006-02-27 16:30:29.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/media/w9968cf.c	2006-02-27 16:31:03.000000000 +0100
@@ -3532,21 +3532,19 @@ w9968cf_usb_probe(struct usb_interface* 
 

 	/* Allocate 2 bytes of memory for camera control USB transfers */
-	if (!(cam->control_buffer = kmalloc(2, GFP_KERNEL))) {
+	if (!(cam->control_buffer = kzalloc(2, GFP_KERNEL))) {
 		DBG(1,"Couldn't allocate memory for camera control transfers")
 		err = -ENOMEM;
 		goto fail;
 	}
-	memset(cam->control_buffer, 0, 2);
 
 	/* Allocate 8 bytes of memory for USB data transfers to the FSB */
-	if (!(cam->data_buffer = kmalloc(8, GFP_KERNEL))) {
+	if (!(cam->data_buffer = kzalloc(8, GFP_KERNEL))) {
 		DBG(1, "Couldn't allocate memory for data "
 		       "transfers to the FSB")
 		err = -ENOMEM;
 		goto fail;
 	}
-	memset(cam->data_buffer, 0, 8);
 
 	/* Register the V4L device */
 	cam->v4ldev = video_device_alloc();
--- linux-2.6.16-rc4/drivers/usb/media/dabusb.c.orig	2006-02-27 16:31:11.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/media/dabusb.c	2006-02-27 16:31:33.000000000 +0100
@@ -217,12 +217,11 @@ static int dabusb_alloc_buffers (pdabusb
 		 pipesize, packets, transfer_buffer_length);
 
 	while (buffers < (s->total_buffer_size << 10)) {
-		b = (pbuff_t) kmalloc (sizeof (buff_t), GFP_KERNEL);
+		b = kzalloc(sizeof (buff_t), GFP_KERNEL);
 		if (!b) {
 			err("kmalloc(sizeof(buff_t))==NULL");
 			goto err;
 		}
-		memset (b, 0, sizeof (buff_t));
 		b->s = s;
 		b->purb = usb_alloc_urb(packets, GFP_KERNEL);
 		if (!b->purb) {
--- linux-2.6.16-rc4/drivers/usb/media/se401.c.orig	2006-02-27 16:31:40.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/media/se401.c	2006-02-27 16:31:57.000000000 +0100
@@ -1345,13 +1345,11 @@ static int se401_probe(struct usb_interf
         /* We found one */
         info("SE401 camera found: %s", camera_name);
 
-        if ((se401 = kmalloc(sizeof(*se401), GFP_KERNEL)) == NULL) {
+        if ((se401 = kzalloc(sizeof(*se401), GFP_KERNEL)) == NULL) {
                 err("couldn't kmalloc se401 struct");
 		return -ENOMEM;
         }
 
-        memset(se401, 0, sizeof(*se401));
-
         se401->dev = dev;
         se401->iface = interface->bInterfaceNumber;
         se401->camera_name = camera_name;
--- linux-2.6.16-rc4/drivers/usb/media/ov511.c.orig	2006-02-27 16:32:05.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/media/ov511.c	2006-02-27 16:32:57.000000000 +0100
@@ -5686,13 +5686,11 @@ ov51x_probe(struct usb_interface *intf, 
 	if (idesc->bInterfaceSubClass != 0x00)
 		return -ENODEV;
 
-	if ((ov = kmalloc(sizeof(*ov), GFP_KERNEL)) == NULL) {
+	if ((ov = kzalloc(sizeof(*ov), GFP_KERNEL)) == NULL) {
 		err("couldn't kmalloc ov struct");
 		goto error_out;
 	}
 
-	memset(ov, 0, sizeof(*ov));
-
 	ov->dev = dev;
 	ov->iface = idesc->bInterfaceNumber;
 	ov->led_policy = led;
--- linux-2.6.16-rc4/drivers/usb/media/stv680.c.orig	2006-02-27 16:33:05.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/media/stv680.c	2006-02-27 16:33:34.000000000 +0100
@@ -317,12 +317,11 @@ static int stv_init (struct usb_stv *stv
 	unsigned char *buffer;
 	unsigned long int bufsize;
 
-	buffer = kmalloc (40, GFP_KERNEL);
+	buffer = kzalloc (40, GFP_KERNEL);
 	if (buffer == NULL) {
 		PDEBUG (0, "STV(e): Out of (small buf) memory");
 		return -1;
 	}
-	memset (buffer, 0, 40);
 	udelay (100);
 
 	/* set config 1, interface 0, alternate 0 */
@@ -1387,14 +1386,12 @@ static int stv680_probe (struct usb_inte
 		goto error;
 	}
 	/* We found one */
-	if ((stv680 = kmalloc (sizeof (*stv680), GFP_KERNEL)) == NULL) {
+	if ((stv680 = kzalloc (sizeof (*stv680), GFP_KERNEL)) == NULL) {
 		PDEBUG (0, "STV(e): couldn't kmalloc stv680 struct.");
 		retval = -ENOMEM;
 		goto error;
 	}
 
-	memset (stv680, 0, sizeof (*stv680));
-
 	stv680->udev = dev;
 	stv680->camera_name = camera_name;
 
--- linux-2.6.16-rc4/drivers/usb/image/mdc800.c.orig	2006-02-27 16:33:50.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/image/mdc800.c	2006-02-27 16:34:13.000000000 +0100
@@ -978,11 +978,10 @@ static int __init usb_mdc800_init (void)
 {
 	int retval = -ENODEV;
 	/* Allocate Memory */
-	mdc800=kmalloc (sizeof (struct mdc800_data), GFP_KERNEL);
+	mdc800 = kzalloc(sizeof(struct mdc800_data), GFP_KERNEL);
 	if (!mdc800)
 		goto cleanup_on_fail;
 
-	memset(mdc800, 0, sizeof(struct mdc800_data));
 	mdc800->dev = NULL;
 	mdc800->open=0;
 	mdc800->state=NOT_CONNECTED;
--- linux-2.6.16-rc4/drivers/usb/serial/visor.c.orig	2006-02-27 16:34:21.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/serial/visor.c	2006-02-27 16:34:30.000000000 +0100
@@ -760,10 +760,9 @@ static int generic_startup(struct usb_se
 	int i;
 
 	for (i = 0; i < serial->num_ports; ++i) {
-		priv = kmalloc (sizeof(*priv), GFP_KERNEL);
+		priv = kzalloc (sizeof(*priv), GFP_KERNEL);
 		if (!priv)
 			return -ENOMEM;
-		memset (priv, 0x00, sizeof(*priv));
 		spin_lock_init(&priv->lock);
 		usb_set_serial_port_data(serial->port[i], priv);
 	}
--- linux-2.6.16-rc4/drivers/usb/serial/io_ti.c.orig	2006-02-27 16:34:38.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/serial/io_ti.c	2006-02-27 16:35:24.000000000 +0100
@@ -2727,12 +2727,11 @@ static int edge_startup (struct usb_seri
 	dev = serial->dev;
 
 	/* create our private serial structure */
-	edge_serial = kmalloc (sizeof(struct edgeport_serial), GFP_KERNEL);
+	edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
 	if (edge_serial == NULL) {
 		dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__);
 		return -ENOMEM;
 	}
-	memset (edge_serial, 0, sizeof(struct edgeport_serial));
 	sema_init(&edge_serial->es_sem, 1);
 	edge_serial->serial = serial;
 	usb_set_serial_data(serial, edge_serial);
@@ -2745,12 +2744,11 @@ static int edge_startup (struct usb_seri
 
 	/* set up our port private structures */
 	for (i = 0; i < serial->num_ports; ++i) {
-		edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL);
+		edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL);
 		if (edge_port == NULL) {
 			dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__);
 			goto cleanup;
 		}
-		memset (edge_port, 0, sizeof(struct edgeport_port));
 		spin_lock_init(&edge_port->ep_lock);
 		edge_port->ep_out_buf = edge_buf_alloc(EDGE_OUT_BUF_SIZE);
 		if (edge_port->ep_out_buf == NULL) {
--- linux-2.6.16-rc4/drivers/usb/serial/option.c.orig	2006-02-27 16:35:30.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/serial/option.c	2006-02-27 16:35:51.000000000 +0100
@@ -631,13 +631,12 @@ static int option_startup(struct usb_ser
 	/* Now setup per port private data */
 	for (i = 0; i < serial->num_ports; i++) {
 		port = serial->port[i];
-		portdata = kmalloc(sizeof(*portdata), GFP_KERNEL);
+		portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
 		if (!portdata) {
 			dbg("%s: kmalloc for option_port_private (%d) failed!.",
 					__FUNCTION__, i);
 			return (1);
 		}
-		memset(portdata, 0, sizeof(struct option_port_private));
 
 		usb_set_serial_port_data(port, portdata);
 
--- linux-2.6.16-rc4/drivers/usb/serial/cp2101.c.orig	2006-02-27 16:36:00.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/serial/cp2101.c	2006-02-27 16:36:31.000000000 +0100
@@ -169,9 +169,7 @@ static int cp2101_get_config(struct usb_
 	/* Number of integers required to contain the array */
 	length = (((size - 1) | 3) + 1)/4;
 
-	buf = kmalloc (length * sizeof(u32), GFP_KERNEL);
-	memset(buf, 0, length * sizeof(u32));
-
+	buf = kcalloc(length, sizeof(u32), GFP_KERNEL);
 	if (!buf) {
 		dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__);
 		return -ENOMEM;
--- linux-2.6.16-rc4/drivers/usb/serial/ti_usb_3410_5052.c.orig	2006-02-27 16:36:59.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/serial/ti_usb_3410_5052.c	2006-02-27 16:37:08.000000000 +0100
@@ -416,12 +416,11 @@ static int ti_startup(struct usb_serial 
 	    dev->actconfig->desc.bConfigurationValue);
 
 	/* create device structure */
-	tdev = kmalloc(sizeof(struct ti_device), GFP_KERNEL);
+	tdev = kzalloc(sizeof(struct ti_device), GFP_KERNEL);
 	if (tdev == NULL) {
 		dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__);
 		return -ENOMEM;
 	}
-	memset(tdev, 0, sizeof(struct ti_device));
 	sema_init(&tdev->td_open_close_sem, 1);
 	tdev->td_serial = serial;
 	usb_set_serial_data(serial, tdev);
--- linux-2.6.16-rc4/drivers/usb/serial/kobil_sct.c.orig	2006-02-27 16:37:16.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/serial/kobil_sct.c	2006-02-27 16:38:43.000000000 +0100
@@ -255,11 +255,9 @@ static int kobil_open (struct usb_serial
 	}
 	
 	// allocate memory for transfer buffer
-	transfer_buffer = (unsigned char *) kmalloc(transfer_buffer_length, GFP_KERNEL);  
+	transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);  
 	if (! transfer_buffer) {
 		return -ENOMEM;
-	} else {
-		memset(transfer_buffer, 0, transfer_buffer_length);
 	}
 	
 	// allocate write_urb
@@ -383,11 +381,10 @@ static void kobil_read_int_callback( str
 		
 		// BEGIN DEBUG
 		/*
-		  dbg_data = (unsigned char *) kmalloc((3 *  purb->actual_length + 10) * sizeof(char), GFP_KERNEL);
+		  dbg_data = kzalloc((3 *  purb->actual_length + 10) * sizeof(char), GFP_KERNEL);
 		  if (! dbg_data) {
 		  return;
 		  }
-		  memset(dbg_data, 0, (3 *  purb->actual_length + 10));
 		  for (i = 0; i < purb->actual_length; i++) { 
 		  sprintf(dbg_data +3*i, "%02X ", data[i]); 
 		  }
@@ -518,11 +515,10 @@ static int kobil_tiocmget(struct usb_ser
 	}
 
 	// allocate memory for transfer buffer
-	transfer_buffer = (unsigned char *) kmalloc(transfer_buffer_length, GFP_KERNEL);  
+	transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);  
 	if (!transfer_buffer) {
 		return -ENOMEM;
 	}
-	memset(transfer_buffer, 0, transfer_buffer_length);
 
 	result = usb_control_msg( port->serial->dev, 
 				  usb_rcvctrlpipe(port->serial->dev, 0 ), 
@@ -564,11 +560,10 @@ static int  kobil_tiocmset(struct usb_se
 	}
 
 	// allocate memory for transfer buffer
-	transfer_buffer = (unsigned char *) kmalloc(transfer_buffer_length, GFP_KERNEL);
+	transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);
 	if (! transfer_buffer) {
 		return -ENOMEM;
 	}
-	memset(transfer_buffer, 0, transfer_buffer_length);
 
 	if (set & TIOCM_RTS)
 		rts = 1;
@@ -655,11 +650,10 @@ static int  kobil_ioctl(struct usb_seria
 						   (struct termios __user *)arg))
 			return -EFAULT;
 		
-		settings = (unsigned char *) kmalloc(50, GFP_KERNEL);  
+		settings = kzalloc(50, GFP_KERNEL);  
 		if (! settings) {
 			return -ENOBUFS;
 		}
-		memset(settings, 0, 50);
 
 		switch (priv->internal_termios.c_cflag & CBAUD) {
 		case B1200:
--- linux-2.6.16-rc4/drivers/usb/serial/pl2303.c.orig	2006-02-27 16:38:53.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/serial/pl2303.c	2006-02-27 16:39:21.000000000 +0100
@@ -218,10 +218,9 @@ static int pl2303_startup (struct usb_se
 	dbg("device type: %d", type);
 
 	for (i = 0; i < serial->num_ports; ++i) {
-		priv = kmalloc (sizeof (struct pl2303_private), GFP_KERNEL);
+		priv = kzalloc(sizeof(struct pl2303_private), GFP_KERNEL);
 		if (!priv)
 			goto cleanup;
-		memset (priv, 0x00, sizeof (struct pl2303_private));
 		spin_lock_init(&priv->lock);
 		priv->buf = pl2303_buf_alloc(PL2303_BUF_SIZE);
 		if (priv->buf == NULL) {
@@ -383,12 +382,11 @@ static void pl2303_set_termios (struct u
 		}
 	}
 
-	buf = kmalloc (7, GFP_KERNEL);
+	buf = kzalloc (7, GFP_KERNEL);
 	if (!buf) {
 		dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__);
 		return;
 	}
-	memset (buf, 0x00, 0x07);
 	
 	i = usb_control_msg (serial->dev, usb_rcvctrlpipe (serial->dev, 0),
 			     GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE,
--- linux-2.6.16-rc4/drivers/usb/serial/keyspan.c.orig	2006-02-27 16:39:28.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/serial/keyspan.c	2006-02-27 16:40:19.000000000 +0100
@@ -2250,12 +2250,11 @@ static int keyspan_startup (struct usb_s
 	}
 
 	/* Setup private data for serial driver */
-	s_priv = kmalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL);
+	s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL);
 	if (!s_priv) {
 		dbg("%s - kmalloc for keyspan_serial_private failed.", __FUNCTION__);
 		return -ENOMEM;
 	}
-	memset(s_priv, 0, sizeof(struct keyspan_serial_private));
 
 	s_priv->device_details = d_details;
 	usb_set_serial_data(serial, s_priv);
@@ -2263,12 +2262,11 @@ static int keyspan_startup (struct usb_s
 	/* Now setup per port private data */
 	for (i = 0; i < serial->num_ports; i++) {
 		port = serial->port[i];
-		p_priv = kmalloc(sizeof(struct keyspan_port_private), GFP_KERNEL);
+		p_priv = kzalloc(sizeof(struct keyspan_port_private), GFP_KERNEL);
 		if (!p_priv) {
 			dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __FUNCTION__, i);
 			return (1);
 		}
-		memset(p_priv, 0, sizeof(struct keyspan_port_private));
 		p_priv->device_details = d_details;
 		usb_set_serial_port_data(port, p_priv);
 	}
--- linux-2.6.16-rc4/drivers/usb/serial/io_edgeport.c.orig	2006-02-27 16:40:33.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/serial/io_edgeport.c	2006-02-27 16:40:49.000000000 +0100
@@ -2725,12 +2725,11 @@ static int edge_startup (struct usb_seri
 	dev = serial->dev;
 
 	/* create our private serial structure */
-	edge_serial = kmalloc (sizeof(struct edgeport_serial), GFP_KERNEL);
+	edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
 	if (edge_serial == NULL) {
 		dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__);
 		return -ENOMEM;
 	}
-	memset (edge_serial, 0, sizeof(struct edgeport_serial));
 	spin_lock_init(&edge_serial->es_lock);
 	edge_serial->serial = serial;
 	usb_set_serial_data(serial, edge_serial);
--- linux-2.6.16-rc4/drivers/usb/serial/usb-serial.c.orig	2006-02-27 16:41:00.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/serial/usb-serial.c	2006-02-27 16:41:25.000000000 +0100
@@ -564,12 +564,11 @@ static struct usb_serial * create_serial
 {
 	struct usb_serial *serial;
 
-	serial = kmalloc (sizeof (*serial), GFP_KERNEL);
+	serial = kzalloc(sizeof(*serial), GFP_KERNEL);
 	if (!serial) {
 		dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__);
 		return NULL;
 	}
-	memset (serial, 0, sizeof(*serial));
 	serial->dev = usb_get_dev(dev);
 	serial->type = driver;
 	serial->interface = interface;
@@ -778,10 +777,9 @@ int usb_serial_probe(struct usb_interfac
 	serial->num_port_pointers = max_endpoints;
 	dbg("%s - setting up %d port structures for this device", __FUNCTION__, max_endpoints);
 	for (i = 0; i < max_endpoints; ++i) {
-		port = kmalloc(sizeof(struct usb_serial_port), GFP_KERNEL);
+		port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL);
 		if (!port)
 			goto probe_error;
-		memset(port, 0x00, sizeof(struct usb_serial_port));
 		port->number = i + serial->minor;
 		port->serial = serial;
 		spin_lock_init(&port->lock);
--- linux-2.6.16-rc4/drivers/usb/serial/cypress_m8.c.orig	2006-02-27 16:41:33.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/serial/cypress_m8.c	2006-02-27 16:41:44.000000000 +0100
@@ -435,11 +435,10 @@ static int generic_startup (struct usb_s
 
 	dbg("%s - port %d", __FUNCTION__, serial->port[0]->number);
 
-	priv = kmalloc(sizeof (struct cypress_private), GFP_KERNEL);
+	priv = kzalloc(sizeof (struct cypress_private), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
-	memset(priv, 0x00, sizeof (struct cypress_private));
 	spin_lock_init(&priv->lock);
 	priv->buf = cypress_buf_alloc(CYPRESS_BUF_SIZE);
 	if (priv->buf == NULL) {
--- linux-2.6.16-rc4/drivers/usb/serial/ftdi_sio.c.orig	2006-02-27 16:41:56.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/serial/ftdi_sio.c	2006-02-27 16:42:10.000000000 +0100
@@ -1135,12 +1135,11 @@ static int ftdi_sio_attach (struct usb_s
 	
 	dbg("%s",__FUNCTION__);
 
-	priv = kmalloc(sizeof(struct ftdi_private), GFP_KERNEL);
+	priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL);
 	if (!priv){
 		err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct ftdi_private));
 		return -ENOMEM;
 	}
-	memset(priv, 0, sizeof(*priv));
 
 	spin_lock_init(&priv->rx_lock);
         init_waitqueue_head(&priv->delta_msr_wait);
--- linux-2.6.16-rc4/drivers/usb/serial/mct_u232.c.orig	2006-02-27 16:42:16.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/serial/mct_u232.c	2006-02-27 16:42:33.000000000 +0100
@@ -348,10 +348,9 @@ static int mct_u232_startup (struct usb_
 	struct mct_u232_private *priv;
 	struct usb_serial_port *port, *rport;
 
-	priv = kmalloc(sizeof(struct mct_u232_private), GFP_KERNEL);
+	priv = kzalloc(sizeof(struct mct_u232_private), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
-	memset(priv, 0, sizeof(struct mct_u232_private));
 	spin_lock_init(&priv->lock);
 	usb_set_serial_port_data(serial->port[0], priv);
 
--- linux-2.6.16-rc4/drivers/usb/serial/garmin_gps.c.orig	2006-02-27 16:42:40.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/serial/garmin_gps.c	2006-02-27 16:42:54.000000000 +0100
@@ -1422,12 +1422,11 @@ static int garmin_attach (struct usb_ser
 
 	dbg("%s", __FUNCTION__);
 
-	garmin_data_p = kmalloc (sizeof(struct garmin_data), GFP_KERNEL);
+	garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL);
 	if (garmin_data_p == NULL) {
 		dev_err(&port->dev, "%s - Out of memory\n", __FUNCTION__);
 		return -ENOMEM;
 	}
-	memset (garmin_data_p, 0, sizeof(struct garmin_data));
 	init_timer(&garmin_data_p->timer);
 	spin_lock_init(&garmin_data_p->lock);
 	INIT_LIST_HEAD(&garmin_data_p->pktlist);
--- linux-2.6.16-rc4/drivers/usb/serial/ir-usb.c.orig	2006-02-27 16:43:04.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/serial/ir-usb.c	2006-02-27 16:43:17.000000000 +0100
@@ -184,10 +184,9 @@ static struct irda_class_desc *irda_usb_
 	struct irda_class_desc *desc;
 	int ret;
 		
-	desc = kmalloc(sizeof (struct irda_class_desc), GFP_KERNEL);
+	desc = kzalloc(sizeof (struct irda_class_desc), GFP_KERNEL);
 	if (desc == NULL) 
 		return NULL;
-	memset(desc, 0, sizeof(struct irda_class_desc));
 	
 	ret = usb_control_msg(dev, usb_rcvctrlpipe(dev,0),
 			IU_REQ_GET_CLASS_DESC,
--- linux-2.6.16-rc4/drivers/usb/host/hc_crisv10.c.orig	2006-02-27 16:45:36.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/host/hc_crisv10.c	2006-02-27 16:46:30.000000000 +0100
@@ -2137,10 +2137,9 @@ static int etrax_usb_submit_bulk_urb(str
 	urb->status = -EINPROGRESS;
 
 	/* Setup the hcpriv data. */
-	urb_priv = kmalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
+	urb_priv = kzalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
 	assert(urb_priv != NULL);
 	/* This sets rx_offset to 0. */
-	memset(urb_priv, 0, sizeof(etrax_urb_priv_t));
 	urb_priv->urb_state = NOT_STARTED;
 	urb->hcpriv = urb_priv;
 
@@ -2475,10 +2474,9 @@ static int etrax_usb_submit_ctrl_urb(str
 	urb->status = -EINPROGRESS;
 
 	/* Setup the hcpriv data. */
-	urb_priv = kmalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
+	urb_priv = kzalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
 	assert(urb_priv != NULL);
 	/* This sets rx_offset to 0. */
-	memset(urb_priv, 0, sizeof(etrax_urb_priv_t));
 	urb_priv->urb_state = NOT_STARTED;
 	urb->hcpriv = urb_priv;
 
@@ -2767,9 +2765,8 @@ static void etrax_usb_add_to_intr_sb_lis
 	maxlen = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe));
 	interval = urb->interval;
 
-	urb_priv = kmalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
+	urb_priv = kzalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
 	assert(urb_priv != NULL);
-	memset(urb_priv, 0, sizeof(etrax_urb_priv_t));
 	urb->hcpriv = urb_priv;
 
 	first_ep = &TxIntrEPList[0];
@@ -2997,9 +2994,8 @@ static void etrax_usb_add_to_isoc_sb_lis
 
 	prev_sb_desc = next_sb_desc = temp_sb_desc = NULL;
 
-	urb_priv = kmalloc(sizeof(etrax_urb_priv_t), GFP_ATOMIC);
+	urb_priv = kzalloc(sizeof(etrax_urb_priv_t), GFP_ATOMIC);
 	assert(urb_priv != NULL);
-	memset(urb_priv, 0, sizeof(etrax_urb_priv_t));
 
 	urb->hcpriv = urb_priv;
 	urb_priv->epid = epid;
--- linux-2.6.16-rc4/drivers/usb/host/sl811_cs.c.orig	2006-02-27 16:46:40.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/host/sl811_cs.c	2006-02-27 16:46:50.000000000 +0100
@@ -330,10 +330,9 @@ static int sl811_cs_attach(struct pcmcia
 	local_info_t *local;
 	dev_link_t *link;
 
-	local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
+	local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
 	if (!local)
 		return -ENOMEM;
-	memset(local, 0, sizeof(local_info_t));
 	link = &local->link;
 	link->priv = local;
 
--- linux-2.6.16-rc4/drivers/usb/host/ehci-sched.c.orig	2006-02-27 16:46:59.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/host/ehci-sched.c	2006-02-27 16:47:17.000000000 +0100
@@ -863,9 +863,8 @@ iso_sched_alloc (unsigned packets, gfp_t
 	int			size = sizeof *iso_sched;
 
 	size += packets * sizeof (struct ehci_iso_packet);
-	iso_sched = kmalloc (size, mem_flags);
+	iso_sched = kzalloc(size, mem_flags);
 	if (likely (iso_sched != NULL)) {
-		memset(iso_sched, 0, size);
 		INIT_LIST_HEAD (&iso_sched->td_list);
 	}
 	return iso_sched;
--- linux-2.6.16-rc4/drivers/usb/host/ehci-mem.c.orig	2006-02-27 16:47:25.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/host/ehci-mem.c	2006-02-27 16:48:23.000000000 +0100
@@ -221,13 +221,9 @@ static int ehci_mem_init (struct ehci_hc
 		ehci->periodic [i] = EHCI_LIST_END;
 
 	/* software shadow of hardware table */
-	ehci->pshadow = kmalloc (ehci->periodic_size * sizeof (void *), flags);
-	if (ehci->pshadow == NULL) {
-		goto fail;
-	}
-	memset (ehci->pshadow, 0, ehci->periodic_size * sizeof (void *));
-
-	return 0;
+	ehci->pshadow = kcalloc(ehci->periodic_size, sizeof(void *), flags);
+	if (ehci->pshadow != NULL)
+		return 0;
 
 fail:
 	ehci_dbg (ehci, "couldn't init memory\n");
--- linux-2.6.16-rc4/drivers/usb/storage/jumpshot.c.orig	2006-02-27 16:48:59.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/storage/jumpshot.c	2006-02-27 16:49:16.000000000 +0100
@@ -441,12 +441,11 @@ int jumpshot_transport(struct scsi_cmnd 
 	};
 
 	if (!us->extra) {
-		us->extra = kmalloc(sizeof(struct jumpshot_info), GFP_NOIO);
+		us->extra = kzalloc(sizeof(struct jumpshot_info), GFP_NOIO);
 		if (!us->extra) {
 			US_DEBUGP("jumpshot_transport:  Gah! Can't allocate storage for jumpshot info struct!\n");
 			return USB_STOR_TRANSPORT_ERROR;
 		}
-		memset(us->extra, 0, sizeof(struct jumpshot_info));
 		us->extra_destructor = jumpshot_info_destructor;
 	}
 
--- linux-2.6.16-rc4/drivers/usb/storage/shuttle_usbat.c.orig	2006-02-27 16:49:22.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/storage/shuttle_usbat.c	2006-02-27 16:49:35.000000000 +0100
@@ -1318,12 +1318,11 @@ int init_usbat(struct us_data *us)
 	unsigned char subcountL = USBAT_ATA_LBA_ME;
 	unsigned char *status = us->iobuf;
 
-	us->extra = kmalloc(sizeof(struct usbat_info), GFP_NOIO);
+	us->extra = kzalloc(sizeof(struct usbat_info), GFP_NOIO);
 	if (!us->extra) {
 		US_DEBUGP("init_usbat: Gah! Can't allocate storage for usbat info struct!\n");
 		return 1;
 	}
-	memset(us->extra, 0, sizeof(struct usbat_info));
 	info = (struct usbat_info *) (us->extra);
 
 	/* Enable peripheral control signals */
--- linux-2.6.16-rc4/drivers/usb/storage/isd200.c.orig	2006-02-27 16:49:44.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/storage/isd200.c	2006-02-27 16:51:25.000000000 +0100
@@ -1360,22 +1360,18 @@ static int isd200_init_info(struct us_da
 	int retStatus = ISD200_GOOD;
 	struct isd200_info *info;
 
-	info = (struct isd200_info *)
-			kmalloc(sizeof(struct isd200_info), GFP_KERNEL);
+	info = kzalloc(sizeof(struct isd200_info), GFP_KERNEL);
+	
 	if (!info)
 		retStatus = ISD200_ERROR;
 	else {
-		memset(info, 0, sizeof(struct isd200_info));
-		info->id = (struct hd_driveid *)
-				kmalloc(sizeof(struct hd_driveid), GFP_KERNEL);
-		info->RegsBuf = (unsigned char *)
-				kmalloc(sizeof(info->ATARegs), GFP_KERNEL);
+		info->id = kzalloc(sizeof(struct hd_driveid), GFP_KERNEL);
+		info->RegsBuf = kmalloc(sizeof(info->ATARegs), GFP_KERNEL);
 		if (!info->id || !info->RegsBuf) {
 			isd200_free_info_ptrs(info);
 			kfree(info);
 			retStatus = ISD200_ERROR;
-		} else
-			memset(info->id, 0, sizeof(struct hd_driveid));
+		}
 	}
 
 	if (retStatus == ISD200_GOOD) {
@@ -1384,7 +1380,7 @@ static int isd200_init_info(struct us_da
 	} else
 		US_DEBUGP("ERROR - kmalloc failure\n");
 
-	return(retStatus);
+	return retStatus;
 }
 
 /**************************************************************************
--- linux-2.6.16-rc4/drivers/usb/storage/sddr55.c.orig	2006-02-27 16:51:35.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/storage/sddr55.c	2006-02-27 16:52:18.000000000 +0100
@@ -751,11 +751,10 @@ int sddr55_transport(struct scsi_cmnd *s
 	struct sddr55_card_info *info;
 
 	if (!us->extra) {
-		us->extra = kmalloc(
+		us->extra = kzalloc(
 			sizeof(struct sddr55_card_info), GFP_NOIO);
 		if (!us->extra)
 			return USB_STOR_TRANSPORT_ERROR;
-		memset(us->extra, 0, sizeof(struct sddr55_card_info));
 		us->extra_destructor = sddr55_card_info_destructor;
 	}
 
--- linux-2.6.16-rc4/drivers/usb/misc/idmouse.c.orig	2006-02-27 16:52:43.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/misc/idmouse.c	2006-02-27 16:52:51.000000000 +0100
@@ -340,10 +340,9 @@ static int idmouse_probe(struct usb_inte
 		return -ENODEV;
 
 	/* allocate memory for our device state and initialize it */
-	dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (dev == NULL)
 		return -ENOMEM;
-	memset(dev, 0x00, sizeof(*dev));
 
 	init_MUTEX(&dev->sem);
 	dev->udev = udev;
--- linux-2.6.16-rc4/drivers/usb/misc/usblcd.c.orig	2006-02-27 16:52:59.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/misc/usblcd.c	2006-02-27 16:53:12.000000000 +0100
@@ -270,12 +270,11 @@ static int lcd_probe(struct usb_interfac
 	int retval = -ENOMEM;
 
 	/* allocate memory for our device state and initialize it */
-	dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (dev == NULL) {
 		err("Out of memory");
 		goto error;
 	}
-	memset(dev, 0x00, sizeof(*dev));
 	kref_init(&dev->kref);
 
 	dev->udev = usb_get_dev(interface_to_usbdev(interface));
--- linux-2.6.16-rc4/drivers/usb/misc/usbtest.c.orig	2006-02-27 16:53:19.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/misc/usbtest.c	2006-02-27 16:54:22.000000000 +0100
@@ -382,12 +382,11 @@ alloc_sglist (int nents, int max, int va
 	for (i = 0; i < nents; i++) {
 		char		*buf;
 
-		buf = kmalloc (size, SLAB_KERNEL);
+		buf = kzalloc (size, SLAB_KERNEL);
 		if (!buf) {
 			free_sglist (sg, i);
 			return NULL;
 		}
-		memset (buf, 0, size);
 
 		/* kmalloc pages are always physically contiguous! */
 		sg_init_one(&sg[i], buf, size);
@@ -842,10 +841,9 @@ test_ctrl_queue (struct usbtest_dev *dev
 	 * as with bulk/intr sglists, sglen is the queue depth; it also
 	 * controls which subtests run (more tests than sglen) or rerun.
 	 */
-	urb = kmalloc (param->sglen * sizeof (struct urb *), SLAB_KERNEL);
+	urb = kcalloc(param->sglen, sizeof(struct urb *), SLAB_KERNEL);
 	if (!urb)
 		return -ENOMEM;
-	memset (urb, 0, param->sglen * sizeof (struct urb *));
 	for (i = 0; i < param->sglen; i++) {
 		int			pipe = usb_rcvctrlpipe (udev, 0);
 		unsigned		len;
@@ -1865,10 +1863,9 @@ usbtest_probe (struct usb_interface *int
 	}
 #endif
 
-	dev = kmalloc (sizeof *dev, SLAB_KERNEL);
+	dev = kzalloc(sizeof(*dev), SLAB_KERNEL);
 	if (!dev)
 		return -ENOMEM;
-	memset (dev, 0, sizeof *dev);
 	info = (struct usbtest_info *) id->driver_info;
 	dev->info = info;
 	init_MUTEX (&dev->sem);
--- linux-2.6.16-rc4/drivers/usb/misc/ldusb.c.orig	2006-02-27 16:54:30.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/misc/ldusb.c	2006-02-27 16:54:47.000000000 +0100
@@ -626,12 +626,11 @@ static int ld_usb_probe(struct usb_inter
 
 	/* allocate memory for our device state and intialize it */
 
-	dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (dev == NULL) {
 		dev_err(&intf->dev, "Out of memory\n");
 		goto exit;
 	}
-	memset(dev, 0x00, sizeof(*dev));
 	init_MUTEX(&dev->sem);
 	dev->intf = intf;
 	init_waitqueue_head(&dev->read_wait);
--- linux-2.6.16-rc4/drivers/usb/misc/phidgetservo.c.orig	2006-02-27 16:54:56.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/misc/phidgetservo.c	2006-02-27 16:55:16.000000000 +0100
@@ -252,12 +252,11 @@ servo_probe(struct usb_interface *interf
 	struct usb_device *udev = interface_to_usbdev(interface);
 	struct phidget_servo *dev;
 
-	dev = kmalloc(sizeof (struct phidget_servo), GFP_KERNEL);
+	dev = kzalloc(sizeof(struct phidget_servo), GFP_KERNEL);
 	if (dev == NULL) {
 		dev_err(&interface->dev, "%s - out of memory\n", __FUNCTION__);
 		return -ENOMEM;
 	}
-	memset(dev, 0x00, sizeof (*dev));
 
 	dev->udev = usb_get_dev(udev);
 	dev->type = id->driver_info;
--- linux-2.6.16-rc4/drivers/usb/misc/usbled.c.orig	2006-02-27 16:55:27.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/misc/usbled.c	2006-02-27 16:55:47.000000000 +0100
@@ -106,12 +106,11 @@ static int led_probe(struct usb_interfac
 	struct usb_led *dev = NULL;
 	int retval = -ENOMEM;
 
-	dev = kmalloc(sizeof(struct usb_led), GFP_KERNEL);
+	dev = kzalloc(sizeof(struct usb_led), GFP_KERNEL);
 	if (dev == NULL) {
 		dev_err(&interface->dev, "Out of memory\n");
 		goto error;
 	}
-	memset (dev, 0x00, sizeof (*dev));
 
 	dev->udev = usb_get_dev(udev);
 
--- linux-2.6.16-rc4/drivers/usb/misc/auerswald.c.orig	2006-02-27 16:55:54.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/misc/auerswald.c	2006-02-27 16:56:36.000000000 +0100
@@ -570,10 +570,9 @@ static int auerchain_setup (pauerchain_t
 
         /* fill the list of free elements */
         for (;numElements; numElements--) {
-                acep = (pauerchainelement_t) kmalloc (sizeof (auerchainelement_t), GFP_KERNEL);
+                acep = kzalloc(sizeof(auerchainelement_t), GFP_KERNEL);
                 if (!acep)
 			goto ac_fail;
-		memset (acep, 0, sizeof (auerchainelement_t));
                 INIT_LIST_HEAD (&acep->list);
                 list_add_tail (&acep->list, &acp->free_list);
         }
@@ -761,10 +760,9 @@ static int auerbuf_setup (pauerbufctl_t 
 
         /* fill the list of free elements */
         for (;numElements; numElements--) {
-                bep = (pauerbuf_t) kmalloc (sizeof (auerbuf_t), GFP_KERNEL);
+                bep = kzalloc(sizeof(auerbuf_t), GFP_KERNEL);
                 if (!bep)
 			goto bl_fail;
-	        memset (bep, 0, sizeof (auerbuf_t));
                 bep->list = bcp;
                 INIT_LIST_HEAD (&bep->buff_list);
                 bep->bufp = kmalloc (bufsize, GFP_KERNEL);
--- linux-2.6.16-rc4/drivers/usb/misc/cytherm.c.orig	2006-02-27 16:56:42.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/misc/cytherm.c	2006-02-27 16:57:00.000000000 +0100
@@ -351,12 +351,11 @@ static int cytherm_probe(struct usb_inte
 	struct usb_cytherm *dev = NULL;
 	int retval = -ENOMEM;
 
-	dev = kmalloc (sizeof(struct usb_cytherm), GFP_KERNEL);
+	dev = kzalloc(sizeof(struct usb_cytherm), GFP_KERNEL);
 	if (dev == NULL) {
 		dev_err (&interface->dev, "Out of memory\n");
 		goto error;
 	}
-	memset (dev, 0x00, sizeof (*dev));
 
 	dev->udev = usb_get_dev(udev);
 
--- linux-2.6.16-rc4/drivers/usb/misc/phidgetkit.c.orig	2006-02-27 16:58:02.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/misc/phidgetkit.c	2006-02-27 16:58:11.000000000 +0100
@@ -406,12 +406,11 @@ static int interfacekit_probe(struct usb
 	pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
 	maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
 	
-	kit = kmalloc(sizeof(*kit), GFP_KERNEL);
+	kit = kzalloc(sizeof(*kit), GFP_KERNEL);
 	if (kit  == NULL) {
 		dev_err(&intf->dev, "%s - out of memory\n", __FUNCTION__);
 		return -ENOMEM;
 	}
-	memset(kit, 0, sizeof(*kit));
 	kit->ifkit = ifkit;
 
 	kit->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &kit->data_dma);
--- linux-2.6.16-rc4/drivers/usb/mon/mon_text.c.orig	2006-02-27 16:58:21.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/mon/mon_text.c	2006-02-27 16:58:30.000000000 +0100
@@ -212,12 +212,11 @@ static int mon_text_open(struct inode *i
 	mbus = inode->u.generic_ip;
 	ubus = mbus->u_bus;
 
-	rp = kmalloc(sizeof(struct mon_reader_text), GFP_KERNEL);
+	rp = kzalloc(sizeof(struct mon_reader_text), GFP_KERNEL);
 	if (rp == NULL) {
 		rc = -ENOMEM;
 		goto err_alloc;
 	}
-	memset(rp, 0, sizeof(struct mon_reader_text));
 	INIT_LIST_HEAD(&rp->e_list);
 	init_waitqueue_head(&rp->wait);
 	init_MUTEX(&rp->printf_lock);
--- linux-2.6.16-rc4/drivers/usb/mon/mon_main.c.orig	2006-02-27 16:58:37.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/mon/mon_main.c	2006-02-27 16:58:47.000000000 +0100
@@ -276,9 +276,8 @@ static void mon_bus_init(struct dentry *
 	char name[NAMESZ];
 	int rc;
 
-	if ((mbus = kmalloc(sizeof(struct mon_bus), GFP_KERNEL)) == NULL)
+	if ((mbus = kzalloc(sizeof(struct mon_bus), GFP_KERNEL)) == NULL)
 		goto err_alloc;
-	memset(mbus, 0, sizeof(struct mon_bus));
 	kref_init(&mbus->ref);
 	spin_lock_init(&mbus->lock);
 	INIT_LIST_HEAD(&mbus->r_list);
--- linux-2.6.16-rc4/drivers/usb/gadget/lh7a40x_udc.c.orig	2006-02-27 16:59:07.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/gadget/lh7a40x_udc.c	2006-02-27 16:59:22.000000000 +0100
@@ -1114,11 +1114,10 @@ static struct usb_request *lh7a40x_alloc
 
 	DEBUG("%s, %p\n", __FUNCTION__, ep);
 
-	req = kmalloc(sizeof *req, gfp_flags);
+	req = kzalloc(sizeof(*req), gfp_flags);
 	if (!req)
 		return 0;
 
-	memset(req, 0, sizeof *req);
 	INIT_LIST_HEAD(&req->queue);
 
 	return &req->req;
--- linux-2.6.16-rc4/drivers/usb/gadget/inode.c.orig	2006-02-27 16:59:34.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/gadget/inode.c	2006-02-27 17:00:42.000000000 +0100
@@ -170,10 +170,9 @@ static struct dev_data *dev_new (void)
 {
 	struct dev_data		*dev;
 
-	dev = kmalloc (sizeof *dev, GFP_KERNEL);
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
 		return NULL;
-	memset (dev, 0, sizeof *dev);
 	dev->state = STATE_DEV_DISABLED;
 	atomic_set (&dev->count, 1);
 	spin_lock_init (&dev->lock);
@@ -1592,10 +1591,9 @@ static int activate_ep_files (struct dev
 	gadget_for_each_ep (ep, dev->gadget) {
 		struct ep_data	*data;
 
-		data = kmalloc (sizeof *data, GFP_KERNEL);
+		data = kzalloc(sizeof(*data), GFP_KERNEL);
 		if (!data)
 			goto enomem;
-		memset (data, 0, sizeof data);
 		data->state = STATE_EP_DISABLED;
 		init_MUTEX (&data->lock);
 		init_waitqueue_head (&data->wait);
--- linux-2.6.16-rc4/drivers/usb/gadget/goku_udc.c.orig	2006-02-27 17:00:51.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/gadget/goku_udc.c	2006-02-27 17:01:03.000000000 +0100
@@ -275,11 +275,10 @@ goku_alloc_request(struct usb_ep *_ep, g
 
 	if (!_ep)
 		return NULL;
-	req = kmalloc(sizeof *req, gfp_flags);
+	req = kzalloc(sizeof *req, gfp_flags);
 	if (!req)
 		return NULL;
 
-	memset(req, 0, sizeof *req);
 	req->req.dma = DMA_ADDR_INVALID;
 	INIT_LIST_HEAD(&req->queue);
 	return &req->req;
--- linux-2.6.16-rc4/drivers/usb/gadget/pxa2xx_udc.c.orig	2006-02-27 17:01:12.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/gadget/pxa2xx_udc.c	2006-02-27 17:01:27.000000000 +0100
@@ -335,11 +335,10 @@ pxa2xx_ep_alloc_request (struct usb_ep *
 {
 	struct pxa2xx_request *req;
 
-	req = kmalloc (sizeof *req, gfp_flags);
+	req = kzalloc(sizeof(*req), gfp_flags);
 	if (!req)
 		return NULL;
 
-	memset (req, 0, sizeof *req);
 	INIT_LIST_HEAD (&req->queue);
 	return &req->req;
 }
--- linux-2.6.16-rc4/drivers/usb/gadget/dummy_hcd.c.orig	2006-02-27 17:01:35.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/gadget/dummy_hcd.c	2006-02-27 17:01:52.000000000 +0100
@@ -478,10 +478,9 @@ dummy_alloc_request (struct usb_ep *_ep,
 		return NULL;
 	ep = usb_ep_to_dummy_ep (_ep);
 
-	req = kmalloc (sizeof *req, mem_flags);
+	req = kzalloc(sizeof(*req), mem_flags);
 	if (!req)
 		return NULL;
-	memset (req, 0, sizeof *req);
 	INIT_LIST_HEAD (&req->queue);
 	return &req->req;
 }
--- linux-2.6.16-rc4/drivers/usb/gadget/zero.c.orig	2006-02-27 17:02:00.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/gadget/zero.c	2006-02-27 17:02:17.000000000 +0100
@@ -1188,10 +1188,9 @@ autoconf_fail:
 

 	/* ok, we made sense of the hardware ... */
-	dev = kmalloc (sizeof *dev, SLAB_KERNEL);
+	dev = kzalloc(sizeof(*dev), SLAB_KERNEL);
 	if (!dev)
 		return -ENOMEM;
-	memset (dev, 0, sizeof *dev);
 	spin_lock_init (&dev->lock);
 	dev->gadget = gadget;
 	set_gadget_data (gadget, dev);
--- linux-2.6.16-rc4/drivers/usb/gadget/serial.c.orig	2006-02-27 17:02:22.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/gadget/serial.c	2006-02-27 17:02:51.000000000 +0100
@@ -2178,10 +2178,9 @@ static int gs_alloc_ports(struct gs_dev 
 		return -EIO;
 
 	for (i=0; i<GS_NUM_PORTS; i++) {
-		if ((port=(struct gs_port *)kmalloc(sizeof(struct gs_port), kmalloc_flags)) == NULL)
+		if ((port=(struct gs_port *)kzalloc(sizeof(struct gs_port), kmalloc_flags)) == NULL)
 			return -ENOMEM;
 
-		memset(port, 0, sizeof(struct gs_port));
 		port->port_dev = dev;
 		port->port_num = i;
 		port->port_line_coding.dwDTERate = cpu_to_le32(GS_DEFAULT_DTE_RATE);
--- linux-2.6.16-rc4/drivers/usb/gadget/net2280.c.orig	2006-02-27 17:03:01.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/gadget/net2280.c	2006-02-27 17:03:17.000000000 +0100
@@ -386,11 +386,10 @@ net2280_alloc_request (struct usb_ep *_e
 		return NULL;
 	ep = container_of (_ep, struct net2280_ep, ep);
 
-	req = kmalloc (sizeof *req, gfp_flags);
+	req = kzalloc(sizeof(*req), gfp_flags);
 	if (!req)
 		return NULL;
 
-	memset (req, 0, sizeof *req);
 	req->req.dma = DMA_ADDR_INVALID;
 	INIT_LIST_HEAD (&req->queue);
 
--- linux-2.6.16-rc4/drivers/usb/gadget/omap_udc.c.orig	2006-02-27 17:03:27.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/gadget/omap_udc.c	2006-02-27 17:04:54.000000000 +0100
@@ -273,9 +273,8 @@ omap_alloc_request(struct usb_ep *ep, gf
 {
 	struct omap_req	*req;
 
-	req = kmalloc(sizeof *req, gfp_flags);
+	req = kzalloc(sizeof(*req), gfp_flags);
 	if (req) {
-		memset (req, 0, sizeof *req);
 		req->req.dma = DMA_ADDR_INVALID;
 		INIT_LIST_HEAD (&req->queue);
 	}
@@ -2586,11 +2585,10 @@ omap_udc_setup(struct platform_device *o
 	/* UDC_PULLUP_EN gates the chip clock */
 	// OTG_SYSCON_1_REG |= DEV_IDLE_EN;
 
-	udc = kmalloc (sizeof *udc, SLAB_KERNEL);
+	udc = kzalloc(sizeof(*udc), SLAB_KERNEL);
 	if (!udc)
 		return -ENOMEM;
 
-	memset(udc, 0, sizeof *udc);
 	spin_lock_init (&udc->lock);
 
 	udc->gadget.ops = &omap_gadget_ops;
--- linux-2.6.16-rc4/drivers/usb/input/hiddev.c.orig	2006-02-27 17:05:06.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/input/hiddev.c	2006-02-27 17:05:26.000000000 +0100
@@ -257,9 +257,8 @@ static int hiddev_open(struct inode * in
 	if (i >= HIDDEV_MINORS || !hiddev_table[i])
 		return -ENODEV;
 
-	if (!(list = kmalloc(sizeof(struct hiddev_list), GFP_KERNEL)))
+	if (!(list = kzalloc(sizeof(struct hiddev_list), GFP_KERNEL)))
 		return -ENOMEM;
-	memset(list, 0, sizeof(struct hiddev_list));
 
 	list->hiddev = hiddev_table[i];
 	list->next = hiddev_table[i]->list;
@@ -754,9 +753,8 @@ int hiddev_connect(struct hid_device *hi
 	if (i == hid->maxcollection && (hid->quirks & HID_QUIRK_HIDDEV) == 0)
 		return -1;
 
-	if (!(hiddev = kmalloc(sizeof(struct hiddev), GFP_KERNEL)))
+	if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL)))
 		return -1;
-	memset(hiddev, 0, sizeof(struct hiddev));
 
 	retval = usb_register_dev(hid->intf, &hiddev_class);
 	if (retval) {
--- linux-2.6.16-rc4/drivers/usb/input/hid-core.c.orig	2006-02-27 17:05:33.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/input/hid-core.c	2006-02-27 17:06:42.000000000 +0100
@@ -66,9 +66,8 @@ static struct hid_report *hid_register_r
 	if (report_enum->report_id_hash[id])
 		return report_enum->report_id_hash[id];
 
-	if (!(report = kmalloc(sizeof(struct hid_report), GFP_KERNEL)))
+	if (!(report = kzalloc(sizeof(struct hid_report), GFP_KERNEL)))
 		return NULL;
-	memset(report, 0, sizeof(struct hid_report));
 
 	if (id != 0)
 		report_enum->numbered = 1;
@@ -651,17 +650,14 @@ static struct hid_device *hid_parse_repo
 		hid_parser_reserved
 	};
 
-	if (!(device = kmalloc(sizeof(struct hid_device), GFP_KERNEL)))
+	if (!(device = kzalloc(sizeof(struct hid_device), GFP_KERNEL)))
 		return NULL;
-	memset(device, 0, sizeof(struct hid_device));
 
-	if (!(device->collection = kmalloc(sizeof(struct hid_collection) *
+	if (!(device->collection = kzalloc(sizeof(struct hid_collection) *
 				   HID_DEFAULT_NUM_COLLECTIONS, GFP_KERNEL))) {
 		kfree(device);
 		return NULL;
 	}
-	memset(device->collection, 0, sizeof(struct hid_collection) *
-		HID_DEFAULT_NUM_COLLECTIONS);
 	device->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
 
 	for (i = 0; i < HID_REPORT_TYPES; i++)
--- linux-2.6.16-rc4/drivers/usb/input/hid-lgff.c.orig	2006-02-27 17:06:49.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/input/hid-lgff.c	2006-02-27 17:06:58.000000000 +0100
@@ -154,10 +154,9 @@ int hid_lgff_init(struct hid_device* hid
 		return -1;
 	}
 
-	private = kmalloc(sizeof(struct lgff_device), GFP_KERNEL);
+	private = kzalloc(sizeof(struct lgff_device), GFP_KERNEL);
 	if (!private)
 		return -1;
-	memset(private, 0, sizeof(struct lgff_device));
 	hid->ff_private = private;
 
 	/* Input init */
--- linux-2.6.16-rc4/drivers/usb/input/hid-tmff.c.orig	2006-02-27 17:07:04.000000000 +0100
+++ linux-2.6.16-rc4/drivers/usb/input/hid-tmff.c	2006-02-27 17:07:16.000000000 +0100
@@ -113,11 +113,10 @@ int hid_tmff_init(struct hid_device *hid
 	struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
 	struct input_dev *input_dev = hidinput->input;
 
-	private = kmalloc(sizeof(struct tmff_device), GFP_KERNEL);
+	private = kzalloc(sizeof(struct tmff_device), GFP_KERNEL);
 	if (!private)
 		return -ENOMEM;
 
-	memset(private, 0, sizeof(struct tmff_device));
 	hid->ff_private = private;
 
 	/* Find the report to use */



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/usb/gadget
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (3 preceding siblings ...)
  2006-02-27 16:22 ` [KJ] [Patch] kzalloc() conversion in drivers/usb Eric Sesterhenn
@ 2006-02-27 20:36 ` Eric Sesterhenn
  2006-02-27 20:51 ` Jesper Juhl
                   ` (26 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-02-27 20:36 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 7114 bytes --]

hi,

this patch converts drivers/usb to kzalloc usage.
Compile tested with allyes config.

I think there was a bug in drivers/usb/gadget/inode.c because
it used sizeof(*data) for the kmalloc() and sizeof(data) for
the memset(), since sizeof(data) just returns the size for a pointer.

I assume there is also a bug in drivers/usb/gadget/omap_udc.c
in omap_alloc_request(), req gets allocated via kmalloc() and
the function returns &req->req, no matter if req is NULL, which
looks like a NULL dereference to me, maybe someone who is more familar
with this code might have a look at it.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/dummy_hcd.c linux-2.6.16-rc4-mm2/drivers/usb/gadget/dummy_hcd.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/dummy_hcd.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/gadget/dummy_hcd.c	2006-02-27 20:57:14.000000000 +0100
@@ -478,10 +478,9 @@ dummy_alloc_request (struct usb_ep *_ep,
 		return NULL;
 	ep = usb_ep_to_dummy_ep (_ep);
 
-	req = kmalloc (sizeof *req, mem_flags);
+	req = kzalloc(sizeof(*req), mem_flags);
 	if (!req)
 		return NULL;
-	memset (req, 0, sizeof *req);
 	INIT_LIST_HEAD (&req->queue);
 	return &req->req;
 }
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/goku_udc.c linux-2.6.16-rc4-mm2/drivers/usb/gadget/goku_udc.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/goku_udc.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/gadget/goku_udc.c	2006-02-27 20:57:14.000000000 +0100
@@ -275,11 +275,10 @@ goku_alloc_request(struct usb_ep *_ep, g
 
 	if (!_ep)
 		return NULL;
-	req = kmalloc(sizeof *req, gfp_flags);
+	req = kzalloc(sizeof *req, gfp_flags);
 	if (!req)
 		return NULL;
 
-	memset(req, 0, sizeof *req);
 	req->req.dma = DMA_ADDR_INVALID;
 	INIT_LIST_HEAD(&req->queue);
 	return &req->req;
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/inode.c linux-2.6.16-rc4-mm2/drivers/usb/gadget/inode.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/inode.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/gadget/inode.c	2006-02-27 20:57:14.000000000 +0100
@@ -170,10 +170,9 @@ static struct dev_data *dev_new (void)
 {
 	struct dev_data		*dev;
 
-	dev = kmalloc (sizeof *dev, GFP_KERNEL);
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
 		return NULL;
-	memset (dev, 0, sizeof *dev);
 	dev->state = STATE_DEV_DISABLED;
 	atomic_set (&dev->count, 1);
 	spin_lock_init (&dev->lock);
@@ -1592,10 +1591,9 @@ static int activate_ep_files (struct dev
 	gadget_for_each_ep (ep, dev->gadget) {
 		struct ep_data	*data;
 
-		data = kmalloc (sizeof *data, GFP_KERNEL);
+		data = kzalloc(sizeof(*data), GFP_KERNEL);
 		if (!data)
 			goto enomem;
-		memset (data, 0, sizeof data);
 		data->state = STATE_EP_DISABLED;
 		init_MUTEX (&data->lock);
 		init_waitqueue_head (&data->wait);
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/lh7a40x_udc.c linux-2.6.16-rc4-mm2/drivers/usb/gadget/lh7a40x_udc.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/lh7a40x_udc.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/gadget/lh7a40x_udc.c	2006-02-27 20:57:14.000000000 +0100
@@ -1114,11 +1114,10 @@ static struct usb_request *lh7a40x_alloc
 
 	DEBUG("%s, %p\n", __FUNCTION__, ep);
 
-	req = kmalloc(sizeof *req, gfp_flags);
+	req = kzalloc(sizeof(*req), gfp_flags);
 	if (!req)
 		return 0;
 
-	memset(req, 0, sizeof *req);
 	INIT_LIST_HEAD(&req->queue);
 
 	return &req->req;
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/net2280.c linux-2.6.16-rc4-mm2/drivers/usb/gadget/net2280.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/net2280.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/gadget/net2280.c	2006-02-27 20:57:14.000000000 +0100
@@ -386,11 +386,10 @@ net2280_alloc_request (struct usb_ep *_e
 		return NULL;
 	ep = container_of (_ep, struct net2280_ep, ep);
 
-	req = kmalloc (sizeof *req, gfp_flags);
+	req = kzalloc(sizeof(*req), gfp_flags);
 	if (!req)
 		return NULL;
 
-	memset (req, 0, sizeof *req);
 	req->req.dma = DMA_ADDR_INVALID;
 	INIT_LIST_HEAD (&req->queue);
 
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/omap_udc.c linux-2.6.16-rc4-mm2/drivers/usb/gadget/omap_udc.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/omap_udc.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/gadget/omap_udc.c	2006-02-27 20:57:14.000000000 +0100
@@ -273,9 +273,8 @@ omap_alloc_request(struct usb_ep *ep, gf
 {
 	struct omap_req	*req;
 
-	req = kmalloc(sizeof *req, gfp_flags);
+	req = kzalloc(sizeof(*req), gfp_flags);
 	if (req) {
-		memset (req, 0, sizeof *req);
 		req->req.dma = DMA_ADDR_INVALID;
 		INIT_LIST_HEAD (&req->queue);
 	}
@@ -2586,11 +2585,10 @@ omap_udc_setup(struct platform_device *o
 	/* UDC_PULLUP_EN gates the chip clock */
 	// OTG_SYSCON_1_REG |= DEV_IDLE_EN;
 
-	udc = kmalloc (sizeof *udc, SLAB_KERNEL);
+	udc = kzalloc(sizeof(*udc), SLAB_KERNEL);
 	if (!udc)
 		return -ENOMEM;
 
-	memset(udc, 0, sizeof *udc);
 	spin_lock_init (&udc->lock);
 
 	udc->gadget.ops = &omap_gadget_ops;
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/pxa2xx_udc.c linux-2.6.16-rc4-mm2/drivers/usb/gadget/pxa2xx_udc.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/pxa2xx_udc.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/gadget/pxa2xx_udc.c	2006-02-27 20:57:14.000000000 +0100
@@ -335,11 +335,10 @@ pxa2xx_ep_alloc_request (struct usb_ep *
 {
 	struct pxa2xx_request *req;
 
-	req = kmalloc (sizeof *req, gfp_flags);
+	req = kzalloc(sizeof(*req), gfp_flags);
 	if (!req)
 		return NULL;
 
-	memset (req, 0, sizeof *req);
 	INIT_LIST_HEAD (&req->queue);
 	return &req->req;
 }
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/serial.c linux-2.6.16-rc4-mm2/drivers/usb/gadget/serial.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/serial.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/gadget/serial.c	2006-02-27 20:57:14.000000000 +0100
@@ -2178,10 +2178,9 @@ static int gs_alloc_ports(struct gs_dev 
 		return -EIO;
 
 	for (i=0; i<GS_NUM_PORTS; i++) {
-		if ((port=(struct gs_port *)kmalloc(sizeof(struct gs_port), kmalloc_flags)) == NULL)
+		if ((port=kzalloc(sizeof(struct gs_port), kmalloc_flags)) == NULL)
 			return -ENOMEM;
 
-		memset(port, 0, sizeof(struct gs_port));
 		port->port_dev = dev;
 		port->port_num = i;
 		port->port_line_coding.dwDTERate = cpu_to_le32(GS_DEFAULT_DTE_RATE);
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/zero.c linux-2.6.16-rc4-mm2/drivers/usb/gadget/zero.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/gadget/zero.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/gadget/zero.c	2006-02-27 20:57:14.000000000 +0100
@@ -1188,10 +1188,9 @@ autoconf_fail:
 

 	/* ok, we made sense of the hardware ... */
-	dev = kmalloc (sizeof *dev, SLAB_KERNEL);
+	dev = kzalloc(sizeof(*dev), SLAB_KERNEL);
 	if (!dev)
 		return -ENOMEM;
-	memset (dev, 0, sizeof *dev);
 	spin_lock_init (&dev->lock);
 	dev->gadget = gadget;
 	set_gadget_data (gadget, dev);



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [KJ] [Patch] kzalloc() conversion in drivers/usb/gadget
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (4 preceding siblings ...)
  2006-02-27 20:36 ` [KJ] [Patch] kzalloc() conversion in drivers/usb/gadget Eric Sesterhenn
@ 2006-02-27 20:51 ` Jesper Juhl
  2006-02-28 13:54 ` [KJ] [Patch] kzalloc() conversion in drivers/acpi Eric Sesterhenn
                   ` (25 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Jesper Juhl @ 2006-02-27 20:51 UTC (permalink / raw)
  To: kernel-janitors

On 2/27/06, Eric Sesterhenn <snakebyte@gmx.de> wrote:
> hi,
>
> this patch converts drivers/usb to kzalloc usage.
> Compile tested with allyes config.
>
> I think there was a bug in drivers/usb/gadget/inode.c because
> it used sizeof(*data) for the kmalloc() and sizeof(data) for
> the memset(), since sizeof(data) just returns the size for a pointer.
>
I don't know this code well, but looking briefly at it I'd say your
analysis is correct and your patch fixes that bug.

--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/acpi
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (5 preceding siblings ...)
  2006-02-27 20:51 ` Jesper Juhl
@ 2006-02-28 13:54 ` Eric Sesterhenn
  2006-02-28 13:54 ` [KJ] [Patch] kzalloc() conversion in drivers/s390 Eric Sesterhenn
                   ` (24 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-02-28 13:54 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 19024 bytes --]

hi,

this patch converts drivers/acpi to kzalloc usage.
Compile tested with allyes config.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc4-mm2/drivers/acpi/utils.c.orig	2006-02-28 14:38:06.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/utils.c	2006-02-28 14:38:31.000000000 +0100
@@ -264,11 +264,10 @@ acpi_evaluate_integer(acpi_handle handle
 	if (!data)
 		return_ACPI_STATUS(AE_BAD_PARAMETER);
 
-	element = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
+	element = kzalloc(sizeof(union acpi_object), GFP_KERNEL);
 	if (!element)
 		return_ACPI_STATUS(AE_NO_MEMORY);
 
-	memset(element, 0, sizeof(union acpi_object));
 	buffer.length = sizeof(union acpi_object);
 	buffer.pointer = element;
 	status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
@@ -322,12 +321,11 @@ acpi_evaluate_string(acpi_handle handle,
 		return_ACPI_STATUS(AE_BAD_DATA);
 	}
 
-	*data = kmalloc(element->string.length + 1, GFP_KERNEL);
+	*data = kzalloc(element->string.length + 1, GFP_KERNEL);
 	if (!data) {
 		ACPI_ERROR((AE_INFO, "Memory allocation"));
 		return_VALUE(-ENOMEM);
 	}
-	memset(*data, 0, element->string.length + 1);
 
 	memcpy(*data, element->string.pointer, element->string.length);
 
--- linux-2.6.16-rc4-mm2/drivers/acpi/pci_irq.c.orig	2006-02-28 14:38:40.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/pci_irq.c	2006-02-28 14:39:12.000000000 +0100
@@ -92,10 +92,9 @@ acpi_pci_irq_add_entry(acpi_handle handl
 	if (!prt)
 		return_VALUE(-EINVAL);
 
-	entry = kmalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL);
+	entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL);
 	if (!entry)
 		return_VALUE(-ENOMEM);
-	memset(entry, 0, sizeof(struct acpi_prt_entry));
 
 	entry->id.segment = segment;
 	entry->id.bus = bus;
@@ -165,10 +164,9 @@ int acpi_pci_irq_add_prt(acpi_handle han
 
 	ACPI_FUNCTION_TRACE("acpi_pci_irq_add_prt");
 
-	pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
+	pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
 	if (!pathname)
 		return_VALUE(-ENOMEM);
-	memset(pathname, 0, ACPI_PATHNAME_MAX);
 
 	if (first_time) {
 		acpi_prt.count = 0;
@@ -202,11 +200,9 @@ int acpi_pci_irq_add_prt(acpi_handle han
 		return_VALUE(-ENODEV);
 	}
 
-	prt = kmalloc(buffer.length, GFP_KERNEL);
-	if (!prt) {
+	prt = kzalloc(buffer.length, GFP_KERNEL);
+	if (!prt)
 		return_VALUE(-ENOMEM);
-	}
-	memset(prt, 0, buffer.length);
 	buffer.pointer = prt;
 
 	status = acpi_get_irq_routing_table(handle, &buffer);
--- linux-2.6.16-rc4-mm2/drivers/acpi/asus_acpi.c.orig	2006-02-28 14:39:20.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/asus_acpi.c	2006-02-28 14:39:41.000000000 +0100
@@ -1132,11 +1132,9 @@ static int __init asus_hotk_add(struct a
 	printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n",
 	       ASUS_ACPI_VERSION);
 
-	hotk =
-	    (struct asus_hotk *)kmalloc(sizeof(struct asus_hotk), GFP_KERNEL);
+	hotk = kzalloc(sizeof(struct asus_hotk), GFP_KERNEL);
 	if (!hotk)
 		return -ENOMEM;
-	memset(hotk, 0, sizeof(struct asus_hotk));
 
 	hotk->handle = device->handle;
 	strcpy(acpi_device_name(device), ACPI_HOTK_DEVICE_NAME);
--- linux-2.6.16-rc4-mm2/drivers/acpi/acpi_memhotplug.c.orig	2006-02-28 14:39:50.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/acpi_memhotplug.c	2006-02-28 14:40:00.000000000 +0100
@@ -342,10 +342,9 @@ static int acpi_memory_device_add(struct
 	if (!device)
 		return_VALUE(-EINVAL);
 
-	mem_device = kmalloc(sizeof(struct acpi_memory_device), GFP_KERNEL);
+	mem_device = kzalloc(sizeof(struct acpi_memory_device), GFP_KERNEL);
 	if (!mem_device)
 		return_VALUE(-ENOMEM);
-	memset(mem_device, 0, sizeof(struct acpi_memory_device));
 
 	mem_device->handle = device->handle;
 	sprintf(acpi_device_name(device), "%s", ACPI_MEMORY_DEVICE_NAME);
--- linux-2.6.16-rc4-mm2/drivers/acpi/scan.c.orig	2006-02-28 14:40:08.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/scan.c	2006-02-28 14:41:38.000000000 +0100
@@ -982,12 +982,11 @@ acpi_add_single_object(struct acpi_devic
 	if (!child)
 		return_VALUE(-EINVAL);
 
-	device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL);
+	device = kzalloc(sizeof(struct acpi_device), GFP_KERNEL);
 	if (!device) {
 		ACPI_ERROR((AE_INFO, "Memory allocation error"));
 		return_VALUE(-ENOMEM);
 	}
-	memset(device, 0, sizeof(struct acpi_device));
 
 	device->handle = handle;
 	device->parent = parent;
--- linux-2.6.16-rc4-mm2/drivers/acpi/battery.c.orig	2006-02-28 14:41:47.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/battery.c	2006-02-28 14:42:13.000000000 +0100
@@ -156,12 +156,11 @@ acpi_battery_get_info(struct acpi_batter
 		goto end;
 	}
 
-	data.pointer = kmalloc(data.length, GFP_KERNEL);
+	data.pointer = kzalloc(data.length, GFP_KERNEL);
 	if (!data.pointer) {
 		result = -ENOMEM;
 		goto end;
 	}
-	memset(data.pointer, 0, data.length);
 
 	status = acpi_extract_package(package, &format, &data);
 	if (ACPI_FAILURE(status)) {
@@ -217,12 +216,11 @@ acpi_battery_get_status(struct acpi_batt
 		goto end;
 	}
 
-	data.pointer = kmalloc(data.length, GFP_KERNEL);
+	data.pointer = kzalloc(data.length, GFP_KERNEL);
 	if (!data.pointer) {
 		result = -ENOMEM;
 		goto end;
 	}
-	memset(data.pointer, 0, data.length);
 
 	status = acpi_extract_package(package, &format, &data);
 	if (ACPI_FAILURE(status)) {
@@ -702,10 +700,9 @@ static int acpi_battery_add(struct acpi_
 	if (!device)
 		return_VALUE(-EINVAL);
 
-	battery = kmalloc(sizeof(struct acpi_battery), GFP_KERNEL);
+	battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
 	if (!battery)
 		return_VALUE(-ENOMEM);
-	memset(battery, 0, sizeof(struct acpi_battery));
 
 	battery->handle = device->handle;
 	strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
--- linux-2.6.16-rc4-mm2/drivers/acpi/button.c.orig	2006-02-28 14:42:22.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/button.c	2006-02-28 14:42:29.000000000 +0100
@@ -304,10 +304,9 @@ static int acpi_button_add(struct acpi_d
 	if (!device)
 		return_VALUE(-EINVAL);
 
-	button = kmalloc(sizeof(struct acpi_button), GFP_KERNEL);
+	button = kzalloc(sizeof(struct acpi_button), GFP_KERNEL);
 	if (!button)
 		return_VALUE(-ENOMEM);
-	memset(button, 0, sizeof(struct acpi_button));
 
 	button->device = device;
 	button->handle = device->handle;
--- linux-2.6.16-rc4-mm2/drivers/acpi/ec.c.orig	2006-02-28 14:42:37.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/ec.c	2006-02-28 14:43:12.000000000 +0100
@@ -996,10 +996,9 @@ static int acpi_ec_poll_add(struct acpi_
 	if (!device)
 		return_VALUE(-EINVAL);
 
-	ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
+	ec = kzalloc(sizeof(union acpi_ec), GFP_KERNEL);
 	if (!ec)
 		return_VALUE(-ENOMEM);
-	memset(ec, 0, sizeof(union acpi_ec));
 
 	ec->common.handle = device->handle;
 	ec->common.uid = -1;
@@ -1066,10 +1065,9 @@ static int acpi_ec_intr_add(struct acpi_
 	if (!device)
 		return_VALUE(-EINVAL);
 
-	ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
+	ec = kzalloc(sizeof(union acpi_ec), GFP_KERNEL);
 	if (!ec)
 		return_VALUE(-ENOMEM);
-	memset(ec, 0, sizeof(union acpi_ec));
 
 	ec->common.handle = device->handle;
 	ec->common.uid = -1;
@@ -1357,12 +1355,11 @@ static int __init acpi_ec_fake_ecdt(void
 
 	printk(KERN_INFO PREFIX "Try to make an fake ECDT\n");
 
-	ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
+	ec_ecdt = kzalloc(sizeof(union acpi_ec), GFP_KERNEL);
 	if (!ec_ecdt) {
 		ret = -ENOMEM;
 		goto error;
 	}
-	memset(ec_ecdt, 0, sizeof(union acpi_ec));
 
 	status = acpi_get_devices(ACPI_EC_HID,
 				  acpi_fake_ecdt_callback, NULL, NULL);
@@ -1402,10 +1399,9 @@ static int __init acpi_ec_poll_get_real_
 	/*
 	 * Generate a temporary ec context to use until the namespace is scanned
 	 */
-	ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
+	ec_ecdt = kzalloc(sizeof(union acpi_ec), GFP_KERNEL);
 	if (!ec_ecdt)
 		return -ENOMEM;
-	memset(ec_ecdt, 0, sizeof(union acpi_ec));
 
 	ec_ecdt->common.command_addr = ecdt_ptr->ec_control;
 	ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
@@ -1447,10 +1443,9 @@ static int __init acpi_ec_intr_get_real_
 	/*
 	 * Generate a temporary ec context to use until the namespace is scanned
 	 */
-	ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
+	ec_ecdt = kzalloc(sizeof(union acpi_ec), GFP_KERNEL);
 	if (!ec_ecdt)
 		return -ENOMEM;
-	memset(ec_ecdt, 0, sizeof(union acpi_ec));
 
 	init_MUTEX(&ec_ecdt->intr.sem);
 	init_waitqueue_head(&ec_ecdt->intr.wait);
--- linux-2.6.16-rc4-mm2/drivers/acpi/pci_link.c.orig	2006-02-28 14:43:20.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/pci_link.c	2006-02-28 14:43:41.000000000 +0100
@@ -314,11 +314,10 @@ static int acpi_pci_link_set(struct acpi
 	if (!link || !irq)
 		return_VALUE(-EINVAL);
 
-	resource = kmalloc(sizeof(*resource) + 1, GFP_ATOMIC);
+	resource = kzalloc(sizeof(*resource) + 1, GFP_ATOMIC);
 	if (!resource)
 		return_VALUE(-ENOMEM);
 
-	memset(resource, 0, sizeof(*resource) + 1);
 	buffer.length = sizeof(*resource) + 1;
 	buffer.pointer = resource;
 
@@ -730,10 +729,9 @@ static int acpi_pci_link_add(struct acpi
 	if (!device)
 		return_VALUE(-EINVAL);
 
-	link = kmalloc(sizeof(struct acpi_pci_link), GFP_KERNEL);
+	link = kzalloc(sizeof(struct acpi_pci_link), GFP_KERNEL);
 	if (!link)
 		return_VALUE(-ENOMEM);
-	memset(link, 0, sizeof(struct acpi_pci_link));
 
 	link->device = device;
 	link->handle = device->handle;
--- linux-2.6.16-rc4-mm2/drivers/acpi/ac.c.orig	2006-02-28 14:43:52.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/ac.c	2006-02-28 14:44:00.000000000 +0100
@@ -224,10 +224,9 @@ static int acpi_ac_add(struct acpi_devic
 	if (!device)
 		return_VALUE(-EINVAL);
 
-	ac = kmalloc(sizeof(struct acpi_ac), GFP_KERNEL);
+	ac = kzalloc(sizeof(struct acpi_ac), GFP_KERNEL);
 	if (!ac)
 		return_VALUE(-ENOMEM);
-	memset(ac, 0, sizeof(struct acpi_ac));
 
 	ac->handle = device->handle;
 	strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME);
--- linux-2.6.16-rc4-mm2/drivers/acpi/thermal.c.orig	2006-02-28 14:44:06.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/thermal.c	2006-02-28 14:44:42.000000000 +0100
@@ -933,12 +933,10 @@ acpi_thermal_write_trip_points(struct fi
 
 	ACPI_FUNCTION_TRACE("acpi_thermal_write_trip_points");
 
-	limit_string = kmalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL);
+	limit_string = kzalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL);
 	if (!limit_string)
 		return_VALUE(-ENOMEM);
 
-	memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN);
-
 	active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL);
 	if (!active)
 		return_VALUE(-ENOMEM);
@@ -1310,10 +1308,9 @@ static int acpi_thermal_add(struct acpi_
 	if (!device)
 		return_VALUE(-EINVAL);
 
-	tz = kmalloc(sizeof(struct acpi_thermal), GFP_KERNEL);
+	tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL);
 	if (!tz)
 		return_VALUE(-ENOMEM);
-	memset(tz, 0, sizeof(struct acpi_thermal));
 
 	tz->handle = device->handle;
 	strcpy(tz->name, device->pnp.bus_id);
--- linux-2.6.16-rc4-mm2/drivers/acpi/ibm_acpi.c.orig	2006-02-28 14:44:50.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/ibm_acpi.c	2006-02-28 14:45:00.000000000 +0100
@@ -1750,13 +1750,12 @@ static int __init register_driver(struct
 {
 	int ret;
 
-	ibm->driver = kmalloc(sizeof(struct acpi_driver), GFP_KERNEL);
+	ibm->driver = kzalloc(sizeof(struct acpi_driver), GFP_KERNEL);
 	if (!ibm->driver) {
 		printk(IBM_ERR "kmalloc(ibm->driver) failed\n");
 		return -1;
 	}
 
-	memset(ibm->driver, 0, sizeof(struct acpi_driver));
 	sprintf(ibm->driver->name, "%s/%s", IBM_NAME, ibm->name);
 	ibm->driver->ids = ibm->hid;
 	ibm->driver->ops.add = &ibm_device_add;
--- linux-2.6.16-rc4-mm2/drivers/acpi/container.c.orig	2006-02-28 14:45:07.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/container.c	2006-02-28 14:45:16.000000000 +0100
@@ -98,11 +98,10 @@ static int acpi_container_add(struct acp
 		return_VALUE(-EINVAL);
 	}
 
-	container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL);
+	container = kzalloc(sizeof(struct acpi_container), GFP_KERNEL);
 	if (!container)
 		return_VALUE(-ENOMEM);
 
-	memset(container, 0, sizeof(struct acpi_container));
 	container->handle = device->handle;
 	strcpy(acpi_device_name(device), ACPI_CONTAINER_DEVICE_NAME);
 	strcpy(acpi_device_class(device), ACPI_CONTAINER_CLASS);
--- linux-2.6.16-rc4-mm2/drivers/acpi/hotkey.c.orig	2006-02-28 14:45:22.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/hotkey.c	2006-02-28 14:46:00.000000000 +0100
@@ -247,10 +247,8 @@ static char *format_result(union acpi_ob
 {
 	char *buf = NULL;
 
-	buf = (char *)kmalloc(RESULT_STR_LEN, GFP_KERNEL);
-	if (buf)
-		memset(buf, 0, RESULT_STR_LEN);
-	else
+	buf = kzalloc(RESULT_STR_LEN, GFP_KERNEL);
+	if (!buf)
 		goto do_fail;
 
 	/* Now, just support integer type */
@@ -791,10 +789,9 @@ static ssize_t hotkey_write_config(struc
 		return_VALUE(-EINVAL);
 	}
 
-	key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL);
+	key = kzalloc(sizeof(union acpi_hotkey), GFP_KERNEL);
 	if (!key)
 		goto do_fail;
-	memset(key, 0, sizeof(union acpi_hotkey));
 	if (cmd == 1) {
 		union acpi_hotkey *tmp = NULL;
 		tmp = get_hotkey_by_event(&global_hotkey_list,
--- linux-2.6.16-rc4-mm2/drivers/acpi/pci_root.c.orig	2006-02-28 14:46:16.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/pci_root.c	2006-02-28 14:46:24.000000000 +0100
@@ -165,10 +165,9 @@ static int acpi_pci_root_add(struct acpi
 	if (!device)
 		return_VALUE(-EINVAL);
 
-	root = kmalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
+	root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
 	if (!root)
 		return_VALUE(-ENOMEM);
-	memset(root, 0, sizeof(struct acpi_pci_root));
 	INIT_LIST_HEAD(&root->node);
 
 	root->handle = device->handle;
--- linux-2.6.16-rc4-mm2/drivers/acpi/power.c.orig	2006-02-28 14:46:31.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/power.c	2006-02-28 14:46:39.000000000 +0100
@@ -552,10 +552,9 @@ static int acpi_power_add(struct acpi_de
 	if (!device)
 		return_VALUE(-EINVAL);
 
-	resource = kmalloc(sizeof(struct acpi_power_resource), GFP_KERNEL);
+	resource = kzalloc(sizeof(struct acpi_power_resource), GFP_KERNEL);
 	if (!resource)
 		return_VALUE(-ENOMEM);
-	memset(resource, 0, sizeof(struct acpi_power_resource));
 
 	resource->handle = device->handle;
 	strcpy(resource->name, device->pnp.bus_id);
--- linux-2.6.16-rc4-mm2/drivers/acpi/pci_bind.c.orig	2006-02-28 14:46:46.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/pci_bind.c	2006-02-28 14:47:44.000000000 +0100
@@ -125,19 +125,17 @@ int acpi_pci_bind(struct acpi_device *de
 	if (!device || !device->parent)
 		return_VALUE(-EINVAL);
 
-	pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
+	pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
 	if (!pathname)
 		return_VALUE(-ENOMEM);
-	memset(pathname, 0, ACPI_PATHNAME_MAX);
 	buffer.length = ACPI_PATHNAME_MAX;
 	buffer.pointer = pathname;
 
-	data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
+	data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
 	if (!data) {
 		kfree(pathname);
 		return_VALUE(-ENOMEM);
 	}
-	memset(data, 0, sizeof(struct acpi_pci_data));
 
 	acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
 	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n",
@@ -285,10 +283,9 @@ int acpi_pci_unbind(struct acpi_device *
 	if (!device || !device->parent)
 		return_VALUE(-EINVAL);
 
-	pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
+	pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
 	if (!pathname)
 		return_VALUE(-ENOMEM);
-	memset(pathname, 0, ACPI_PATHNAME_MAX);
 
 	buffer.length = ACPI_PATHNAME_MAX;
 	buffer.pointer = pathname;
@@ -337,10 +334,9 @@ acpi_pci_bind_root(struct acpi_device *d
 
 	ACPI_FUNCTION_TRACE("acpi_pci_bind_root");
 
-	pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
+	pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
 	if (!pathname)
 		return_VALUE(-ENOMEM);
-	memset(pathname, 0, ACPI_PATHNAME_MAX);
 
 	buffer.length = ACPI_PATHNAME_MAX;
 	buffer.pointer = pathname;
@@ -350,12 +346,11 @@ acpi_pci_bind_root(struct acpi_device *d
 		return_VALUE(-EINVAL);
 	}
 
-	data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
+	data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
 	if (!data) {
 		kfree(pathname);
 		return_VALUE(-ENOMEM);
 	}
-	memset(data, 0, sizeof(struct acpi_pci_data));
 
 	data->id = *id;
 	data->bus = bus;
--- linux-2.6.16-rc4-mm2/drivers/acpi/fan.c.orig	2006-02-28 14:47:54.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/fan.c	2006-02-28 14:48:03.000000000 +0100
@@ -187,10 +187,9 @@ static int acpi_fan_add(struct acpi_devi
 	if (!device)
 		return_VALUE(-EINVAL);
 
-	fan = kmalloc(sizeof(struct acpi_fan), GFP_KERNEL);
+	fan = kzalloc(sizeof(struct acpi_fan), GFP_KERNEL);
 	if (!fan)
 		return_VALUE(-ENOMEM);
-	memset(fan, 0, sizeof(struct acpi_fan));
 
 	fan->handle = device->handle;
 	strcpy(acpi_device_name(device), "Fan");
--- linux-2.6.16-rc4-mm2/drivers/acpi/video.c.orig	2006-02-28 14:48:10.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/video.c	2006-02-28 14:48:52.000000000 +0100
@@ -546,11 +546,10 @@ static void acpi_video_device_find_cap(s
 		int count = 0;
 		union acpi_object *o;
 
-		br = kmalloc(sizeof(*br), GFP_KERNEL);
+		br = kzalloc(sizeof(*br), GFP_KERNEL);
 		if (!br) {
 			printk(KERN_ERR "can't allocate memory\n");
 		} else {
-			memset(br, 0, sizeof(*br));
 			br->levels = kmalloc(obj->package.count *
 					     sizeof *(br->levels), GFP_KERNEL);
 			if (!br->levels)
@@ -1296,12 +1295,10 @@ acpi_video_bus_get_one_device(struct acp
 	    acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
 	if (ACPI_SUCCESS(status)) {
 
-		data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
+		data = kzalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
 		if (!data)
 			return_VALUE(-ENOMEM);
 
-		memset(data, 0, sizeof(struct acpi_video_device));
-
 		data->handle = device->handle;
 		strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME);
 		strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
@@ -1737,10 +1734,9 @@ static int acpi_video_bus_add(struct acp
 	if (!device)
 		return_VALUE(-EINVAL);
 
-	video = kmalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
+	video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
 	if (!video)
 		return_VALUE(-ENOMEM);
-	memset(video, 0, sizeof(struct acpi_video_bus));
 
 	video->handle = device->handle;
 	strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME);
--- linux-2.6.16-rc4-mm2/drivers/acpi/processor_core.c.orig	2006-02-28 14:49:00.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/acpi/processor_core.c	2006-02-28 14:49:14.000000000 +0100
@@ -625,10 +625,9 @@ static int acpi_processor_add(struct acp
 	if (!device)
 		return_VALUE(-EINVAL);
 
-	pr = kmalloc(sizeof(struct acpi_processor), GFP_KERNEL);
+	pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL);
 	if (!pr)
 		return_VALUE(-ENOMEM);
-	memset(pr, 0, sizeof(struct acpi_processor));
 
 	pr->handle = device->handle;
 	strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);




[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/s390
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (6 preceding siblings ...)
  2006-02-28 13:54 ` [KJ] [Patch] kzalloc() conversion in drivers/acpi Eric Sesterhenn
@ 2006-02-28 13:54 ` Eric Sesterhenn
  2006-02-28 14:34 ` [KJ] [Patch] kzalloc() conversion in drivers/pci Eric Sesterhenn
                   ` (23 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-02-28 13:54 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 31413 bytes --]

hi,

this patch converts drivers/s390 to kzalloc usage.
Not compile tested.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc4/drivers/s390/net/qeth_main.c.orig	2006-02-27 19:52:59.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/net/qeth_main.c	2006-02-27 19:54:53.000000000 +0100
@@ -297,12 +297,10 @@ qeth_alloc_card(void)
 	struct qeth_card *card;
 
 	QETH_DBF_TEXT(setup, 2, "alloccrd");
-	card = (struct qeth_card *) kmalloc(sizeof(struct qeth_card),
-					    GFP_DMA|GFP_KERNEL);
+	card = kzalloc(sizeof(struct qeth_card), GFP_DMA|GFP_KERNEL);
 	if (!card)
 		return NULL;
 	QETH_DBF_HEX(setup, 2, &card, sizeof(void *));
-	memset(card, 0, sizeof(struct qeth_card));
 	if (qeth_setup_channel(&card->read)) {
 		kfree(card);
 		return NULL;
@@ -1632,9 +1630,8 @@ qeth_alloc_reply(struct qeth_card *card)
 {
 	struct qeth_reply *reply;
 
-	reply = kmalloc(sizeof(struct qeth_reply), GFP_ATOMIC);
+	reply = kzalloc(sizeof(struct qeth_reply), GFP_ATOMIC);
 	if (reply){
-		memset(reply, 0, sizeof(struct qeth_reply));
 		atomic_set(&reply->refcnt, 1);
 		reply->card = card;
 	};
@@ -3348,13 +3345,11 @@ qeth_qdio_establish(struct qeth_card *ca
 
 	QETH_DBF_TEXT(setup, 2, "qdioest");
 
-	qib_param_field = kmalloc(QDIO_MAX_BUFFERS_PER_Q * sizeof(char),
+	qib_param_field = kzalloc(QDIO_MAX_BUFFERS_PER_Q * sizeof(char),
 			      GFP_KERNEL);
  	if (!qib_param_field)
 		return -ENOMEM;
 
- 	memset(qib_param_field, 0, QDIO_MAX_BUFFERS_PER_Q * sizeof(char));
-
 	qeth_create_qib_param_field(card, qib_param_field);
 	qeth_create_qib_param_field_blkt(card, qib_param_field);
 
@@ -4844,9 +4839,8 @@ qeth_arp_query(struct qeth_card *card, c
 	/* get size of userspace buffer and mask_bits -> 6 bytes */
 	if (copy_from_user(&qinfo, udata, 6))
 		return -EFAULT;
-	if (!(qinfo.udata = kmalloc(qinfo.udata_len, GFP_KERNEL)))
+	if (!(qinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL)))
 		return -ENOMEM;
-	memset(qinfo.udata, 0, qinfo.udata_len);
 	qinfo.udata_offset = QETH_QARP_ENTRIES_OFFSET;
 	iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING,
 				       IPA_CMD_ASS_ARP_QUERY_INFO,
@@ -4994,11 +4988,10 @@ qeth_snmp_command(struct qeth_card *card
 		return -EFAULT;
 	}
 	qinfo.udata_len = ureq->hdr.data_len;
-	if (!(qinfo.udata = kmalloc(qinfo.udata_len, GFP_KERNEL))){
+	if (!(qinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL))){
 		kfree(ureq);
 		return -ENOMEM;
 	}
-	memset(qinfo.udata, 0, qinfo.udata_len);
 	qinfo.udata_offset = sizeof(struct qeth_snmp_ureq_hdr);
 
 	iob = qeth_get_adapter_cmd(card, IPA_SETADP_SET_SNMP_CONTROL,
@@ -5604,12 +5597,11 @@ qeth_get_addr_buffer(enum qeth_prot_vers
 {
 	struct qeth_ipaddr *addr;
 
-	addr = kmalloc(sizeof(struct qeth_ipaddr), GFP_ATOMIC);
+	addr = kzalloc(sizeof(struct qeth_ipaddr), GFP_ATOMIC);
 	if (addr == NULL) {
 		PRINT_WARN("Not enough memory to add address\n");
 		return NULL;
 	}
-	memset(addr,0,sizeof(struct qeth_ipaddr));
 	addr->type = QETH_IP_TYPE_NORMAL;
 	addr->proto = prot;
 	return addr;
--- linux-2.6.16-rc4/drivers/s390/net/qeth_sys.c.orig	2006-02-27 19:55:02.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/net/qeth_sys.c	2006-02-27 19:55:14.000000000 +0100
@@ -1145,11 +1145,10 @@ qeth_dev_ipato_add_store(const char *buf
 	if ((rc = qeth_parse_ipatoe(buf, proto, addr, &mask_bits)))
 		return rc;
 
-	if (!(ipatoe = kmalloc(sizeof(struct qeth_ipato_entry), GFP_KERNEL))){
+	if (!(ipatoe = kzalloc(sizeof(struct qeth_ipato_entry), GFP_KERNEL))){
 		PRINT_WARN("No memory to allocate ipato entry\n");
 		return -ENOMEM;
 	}
-	memset(ipatoe, 0, sizeof(struct qeth_ipato_entry));
 	ipatoe->proto = proto;
 	memcpy(ipatoe->addr, addr, (proto == QETH_PROT_IPV4)? 4:16);
 	ipatoe->mask_bits = mask_bits;
--- linux-2.6.16-rc4/drivers/s390/net/lcs.c.orig	2006-02-27 19:55:38.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/net/lcs.c	2006-02-27 19:56:56.000000000 +0100
@@ -115,11 +115,10 @@ lcs_alloc_channel(struct lcs_channel *ch
 	LCS_DBF_TEXT(2, setup, "ichalloc");
 	for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
 		/* alloc memory fo iobuffer */
-		channel->iob[cnt].data = (void *)
-			kmalloc(LCS_IOBUFFERSIZE, GFP_DMA | GFP_KERNEL);
+		channel->iob[cnt].data =
+			kzalloc(LCS_IOBUFFERSIZE, GFP_DMA | GFP_KERNEL);
 		if (channel->iob[cnt].data == NULL)
 			break;
-		memset(channel->iob[cnt].data, 0, LCS_IOBUFFERSIZE);
 		channel->iob[cnt].state = BUF_STATE_EMPTY;
 	}
 	if (cnt < LCS_NUM_BUFFS) {
@@ -182,10 +181,9 @@ lcs_alloc_card(void)
 
 	LCS_DBF_TEXT(2, setup, "alloclcs");
 
-	card = kmalloc(sizeof(struct lcs_card), GFP_KERNEL | GFP_DMA);
+	card = kzalloc(sizeof(struct lcs_card), GFP_KERNEL | GFP_DMA);
 	if (card == NULL)
 		return NULL;
-	memset(card, 0, sizeof(struct lcs_card));
 	card->lan_type = LCS_FRAME_TYPE_AUTO;
 	card->pkt_seq = 0;
 	card->lancmd_timeout = LCS_LANCMD_TIMEOUT_DEFAULT;
@@ -793,10 +791,9 @@ lcs_alloc_reply(struct lcs_cmd *cmd)
 
 	LCS_DBF_TEXT(4, trace, "getreply");
 
-	reply = kmalloc(sizeof(struct lcs_reply), GFP_ATOMIC);
+	reply = kzalloc(sizeof(struct lcs_reply), GFP_ATOMIC);
 	if (!reply)
 		return NULL;
-	memset(reply,0,sizeof(struct lcs_reply));
 	atomic_set(&reply->refcnt,1);
 	reply->sequence_no = cmd->sequence_no;
 	reply->received = 0;
--- linux-2.6.16-rc4/drivers/s390/net/ctctty.c.orig	2006-02-27 19:59:11.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/net/ctctty.c	2006-02-27 19:59:32.000000000 +0100
@@ -1122,12 +1122,11 @@ ctc_tty_init(void)
 	struct tty_driver *device;
 
 	DBF_TEXT(trace, 2, __FUNCTION__);
-	driver = kmalloc(sizeof(ctc_tty_driver), GFP_KERNEL);
+	driver = kzalloc(sizeof(ctc_tty_driver), GFP_KERNEL);
 	if (driver == NULL) {
 		printk(KERN_WARNING "Out of memory in ctc_tty_modem_init\n");
 		return -ENOMEM;
 	}
-	memset(driver, 0, sizeof(ctc_tty_driver));
 	device = alloc_tty_driver(CTC_TTY_MAX_DEVICES);
 	if (!device) {
 		kfree(driver);
--- linux-2.6.16-rc4/drivers/s390/net/claw.c.orig	2006-02-27 19:59:40.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/net/claw.c	2006-02-27 19:59:59.000000000 +0100
@@ -310,7 +310,7 @@ claw_probe(struct ccwgroup_device *cgdev
         printk(KERN_INFO "claw: variable cgdev =\n");
         dumpit((char *)cgdev, sizeof(struct ccwgroup_device));
 #endif
-	privptr = kmalloc(sizeof(struct claw_privbk), GFP_KERNEL);
+	privptr = kzalloc(sizeof(struct claw_privbk), GFP_KERNEL);
 	if (privptr == NULL) {
 		probe_error(cgdev);
 		put_device(&cgdev->dev);
@@ -319,7 +319,6 @@ claw_probe(struct ccwgroup_device *cgdev
 		CLAW_DBF_TEXT_(2,setup,"probex%d",-ENOMEM);
 		return -ENOMEM;
 	}
-	memset(privptr,0x00,sizeof(struct claw_privbk));
 	privptr->p_mtc_envelope= kmalloc( MAX_ENVELOPE_SIZE, GFP_KERNEL);
 	privptr->p_env = kmalloc(sizeof(struct claw_env), GFP_KERNEL);
         if ((privptr->p_mtc_envelope==NULL) || (privptr->p_env==NULL)) {
--- linux-2.6.16-rc4/drivers/s390/net/fsm.c.orig	2006-02-27 20:00:32.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/net/fsm.c	2006-02-27 20:02:23.000000000 +0100
@@ -21,38 +21,34 @@ init_fsm(char *name, const char **state_
 	fsm_function_t *m;
 	fsm *f;
 
-	this = (fsm_instance *)kmalloc(sizeof(fsm_instance), order);
+	this = kzalloc(sizeof(fsm_instance), order);
 	if (this == NULL) {
 		printk(KERN_WARNING
 			"fsm(%s): init_fsm: Couldn't alloc instance\n", name);
 		return NULL;
 	}
-	memset(this, 0, sizeof(fsm_instance));
 	strlcpy(this->name, name, sizeof(this->name));
 
-	f = (fsm *)kmalloc(sizeof(fsm), order);
+	f = kzalloc(sizeof(fsm), order);
 	if (f == NULL) {
 		printk(KERN_WARNING
 			"fsm(%s): init_fsm: Couldn't alloc fsm\n", name);
 		kfree_fsm(this);
 		return NULL;
 	}
-	memset(f, 0, sizeof(fsm));
 	f->nr_events = nr_events;
 	f->nr_states = nr_states;
 	f->event_names = event_names;
 	f->state_names = state_names;
 	this->f = f;
 
-	m = (fsm_function_t *)kmalloc(
-			sizeof(fsm_function_t) * nr_states * nr_events, order);
+	m = kcalloc(nr_states*nr_events, sizeof(fsm_function_t), order);
 	if (m == NULL) {
 		printk(KERN_WARNING
 			"fsm(%s): init_fsm: Couldn't alloc jumptable\n", name);
 		kfree_fsm(this);
 		return NULL;
 	}
-	memset(m, 0, sizeof(fsm_function_t) * f->nr_states * f->nr_events);
 	f->jumpmatrix = m;
 
 	for (i = 0; i < tmpl_len; i++) {
--- linux-2.6.16-rc4/drivers/s390/net/qeth_eddp.c.orig	2006-02-27 20:03:25.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/net/qeth_eddp.c	2006-02-27 20:04:24.000000000 +0100
@@ -389,9 +389,8 @@ qeth_eddp_create_eddp_data(struct qeth_h
 	struct qeth_eddp_data *eddp;
 
 	QETH_DBF_TEXT(trace, 5, "eddpcrda");
-	eddp = kmalloc(sizeof(struct qeth_eddp_data), GFP_ATOMIC);
+	eddp = kzalloc(sizeof(struct qeth_eddp_data), GFP_ATOMIC);
 	if (eddp){
-		memset(eddp, 0, sizeof(struct qeth_eddp_data));
 		eddp->nhl = nhl;
 		eddp->thl = thl;
 		memcpy(&eddp->qh, qh, sizeof(struct qeth_hdr));
@@ -542,12 +541,11 @@ qeth_eddp_create_context_generic(struct 
 
 	QETH_DBF_TEXT(trace, 5, "creddpcg");
 	/* create the context and allocate pages */
-	ctx = kmalloc(sizeof(struct qeth_eddp_context), GFP_ATOMIC);
+	ctx = kzalloc(sizeof(struct qeth_eddp_context), GFP_ATOMIC);
 	if (ctx == NULL){
 		QETH_DBF_TEXT(trace, 2, "ceddpcn1");
 		return NULL;
 	}
-	memset(ctx, 0, sizeof(struct qeth_eddp_context));
 	ctx->type = QETH_LARGE_SEND_EDDP;
 	qeth_eddp_calc_num_pages(ctx, skb, hdr_len);
 	if (ctx->elements_per_skb > QETH_MAX_BUFFER_ELEMENTS(card)){
@@ -555,13 +553,12 @@ qeth_eddp_create_context_generic(struct 
 		kfree(ctx);
 		return NULL;
 	}
-	ctx->pages = kmalloc(ctx->num_pages * sizeof(u8 *), GFP_ATOMIC);
+	ctx->pages = kcalloc(ctx->num_pages, sizeof(u8 *), GFP_ATOMIC);
 	if (ctx->pages == NULL){
 		QETH_DBF_TEXT(trace, 2, "ceddpcn2");
 		kfree(ctx);
 		return NULL;
 	}
-	memset(ctx->pages, 0, ctx->num_pages * sizeof(u8 *));
 	for (i = 0; i < ctx->num_pages; ++i){
 		addr = (u8 *)__get_free_page(GFP_ATOMIC);
 		if (addr == NULL){
@@ -573,15 +570,13 @@ qeth_eddp_create_context_generic(struct 
 		memset(addr, 0, PAGE_SIZE);
 		ctx->pages[i] = addr;
 	}
-	ctx->elements = kmalloc(ctx->num_elements *
+	ctx->elements = kcalloc(ctx->num_elements,
 				sizeof(struct qeth_eddp_element), GFP_ATOMIC);
 	if (ctx->elements == NULL){
 		QETH_DBF_TEXT(trace, 2, "ceddpcn4");
 		qeth_eddp_free_context(ctx);
 		return NULL;
 	}
-	memset(ctx->elements, 0,
-	       ctx->num_elements * sizeof(struct qeth_eddp_element));
 	/* reset num_elements; will be incremented again in fill_buffer to
 	 * reflect number of actually used elements */
 	ctx->num_elements = 0;
--- linux-2.6.16-rc4/drivers/s390/net/iucv.c.orig	2006-02-27 20:04:50.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/net/iucv.c	2006-02-27 20:05:58.000000000 +0100
@@ -386,7 +386,7 @@ iucv_init(void)
 	}
 
 	/* Note: GFP_DMA used used to get memory below 2G */
-	iucv_external_int_buffer = kmalloc(sizeof(iucv_GeneralInterrupt),
+	iucv_external_int_buffer = kzalloc(sizeof(iucv_GeneralInterrupt),
 					   GFP_KERNEL|GFP_DMA);
 	if (!iucv_external_int_buffer) {
 		printk(KERN_WARNING
@@ -396,10 +396,9 @@ iucv_init(void)
 		bus_unregister(&iucv_bus);
 		return -ENOMEM;
 	}
-	memset(iucv_external_int_buffer, 0, sizeof(iucv_GeneralInterrupt));
 
 	/* Initialize parameter pool */
-	iucv_param_pool = kmalloc(sizeof(iucv_param) * PARAM_POOL_SIZE,
+	iucv_param_pool = kzalloc(sizeof(iucv_param) * PARAM_POOL_SIZE,
 				  GFP_KERNEL|GFP_DMA);
 	if (!iucv_param_pool) {
 		printk(KERN_WARNING "%s: Could not allocate param pool\n",
@@ -410,7 +409,6 @@ iucv_init(void)
 		bus_unregister(&iucv_bus);
 		return -ENOMEM;
 	}
-	memset(iucv_param_pool, 0, sizeof(iucv_param) * PARAM_POOL_SIZE);
 
 	/* Initialize irq queue */
 	INIT_LIST_HEAD(&iucv_irq_queue);
@@ -793,15 +791,14 @@ iucv_register_program (__u8 pgmname[16],
 		}
 
 		max_connections = iucv_query_maxconn();
-		iucv_pathid_table = kmalloc(max_connections * sizeof(handler *),
-				       GFP_ATOMIC);
+		iucv_pathid_table = kcalloc(max_connections, sizeof(handler *),
+					GFP_ATOMIC);
 		if (iucv_pathid_table == NULL) {
 			printk(KERN_WARNING "%s: iucv_pathid_table storage "
 			       "allocation failed\n", __FUNCTION__);
 			kfree(new_handler);
 			return NULL;
 		}
-		memset (iucv_pathid_table, 0, max_connections * sizeof(handler *));
 	}
 	memset(new_handler, 0, sizeof (handler));
 	memcpy(new_handler->id.user_data, pgmname,
--- linux-2.6.16-rc4/drivers/s390/net/netiucv.c.orig	2006-02-27 20:06:07.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/net/netiucv.c	2006-02-27 20:06:36.000000000 +0100
@@ -1728,14 +1728,13 @@ static int
 netiucv_register_device(struct net_device *ndev)
 {
 	struct netiucv_priv *priv = ndev->priv;
-	struct device *dev = kmalloc(sizeof(struct device), GFP_KERNEL);
+	struct device *dev = kzalloc(sizeof(struct device), GFP_KERNEL);
 	int ret;
 
 
 	IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
 
 	if (dev) {
-		memset(dev, 0, sizeof(struct device));
 		snprintf(dev->bus_id, BUS_ID_SIZE, "net%s", ndev->name);
 		dev->bus = &iucv_bus;
 		dev->parent = iucv_root;
@@ -1784,11 +1783,9 @@ netiucv_new_connection(struct net_device
 {
 	struct iucv_connection **clist = &iucv_connections;
 	struct iucv_connection *conn =
-		(struct iucv_connection *)
-		kmalloc(sizeof(struct iucv_connection), GFP_KERNEL);
+		kzalloc(sizeof(struct iucv_connection), GFP_KERNEL);
 
 	if (conn) {
-		memset(conn, 0, sizeof(struct iucv_connection));
 		skb_queue_head_init(&conn->collect_queue);
 		skb_queue_head_init(&conn->commit_queue);
 		conn->max_buffsize = NETIUCV_BUFSIZE_DEFAULT;
--- linux-2.6.16-rc4/drivers/s390/block/dasd.c.orig	2006-02-27 20:07:09.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/block/dasd.c	2006-02-27 20:08:19.000000000 +0100
@@ -73,10 +73,9 @@ dasd_alloc_device(void)
 {
 	struct dasd_device *device;
 
-	device = kmalloc(sizeof (struct dasd_device), GFP_ATOMIC);
+	device = kzalloc(sizeof (struct dasd_device), GFP_ATOMIC);
 	if (device == NULL)
 		return ERR_PTR(-ENOMEM);
-	memset(device, 0, sizeof (struct dasd_device));
 	/* open_count = 0 means device online but not in use */
 	atomic_set(&device->open_count, -1);
 
@@ -524,29 +523,26 @@ dasd_kmalloc_request(char *magic, int cp
 	     (cplength*sizeof(struct ccw1)) > PAGE_SIZE)
 		BUG();
 
-	cqr = kmalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC);
+	cqr = kzalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC);
 	if (cqr == NULL)
 		return ERR_PTR(-ENOMEM);
-	memset(cqr, 0, sizeof(struct dasd_ccw_req));
 	cqr->cpaddr = NULL;
 	if (cplength > 0) {
-		cqr->cpaddr = kmalloc(cplength*sizeof(struct ccw1),
+		cqr->cpaddr = kcalloc(cplength, sizeof(struct ccw1),
 				      GFP_ATOMIC | GFP_DMA);
 		if (cqr->cpaddr == NULL) {
 			kfree(cqr);
 			return ERR_PTR(-ENOMEM);
 		}
-		memset(cqr->cpaddr, 0, cplength*sizeof(struct ccw1));
 	}
 	cqr->data = NULL;
 	if (datasize > 0) {
-		cqr->data = kmalloc(datasize, GFP_ATOMIC | GFP_DMA);
+		cqr->data = kzalloc(datasize, GFP_ATOMIC | GFP_DMA);
 		if (cqr->data == NULL) {
 			kfree(cqr->cpaddr);
 			kfree(cqr);
 			return ERR_PTR(-ENOMEM);
 		}
-		memset(cqr->data, 0, datasize);
 	}
 	strncpy((char *) &cqr->magic, magic, 4);
 	ASCEBC((char *) &cqr->magic, 4);
--- linux-2.6.16-rc4/drivers/s390/block/dcssblk.c.orig	2006-02-27 20:08:28.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/block/dcssblk.c	2006-02-27 20:08:38.000000000 +0100
@@ -388,12 +388,11 @@ dcssblk_add_store(struct device *dev, st
 	/*
 	 * get a struct dcssblk_dev_info
 	 */
-	dev_info = kmalloc(sizeof(struct dcssblk_dev_info), GFP_KERNEL);
+	dev_info = kzalloc(sizeof(struct dcssblk_dev_info), GFP_KERNEL);
 	if (dev_info == NULL) {
 		rc = -ENOMEM;
 		goto out;
 	}
-	memset(dev_info, 0, sizeof(struct dcssblk_dev_info));
 
 	strcpy(dev_info->segment_name, local_buf);
 	strlcpy(dev_info->dev.bus_id, local_buf, BUS_ID_SIZE);
--- linux-2.6.16-rc4/drivers/s390/crypto/z90main.c.orig	2006-02-27 20:09:03.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/crypto/z90main.c	2006-02-27 20:10:08.000000000 +0100
@@ -707,13 +707,12 @@ z90crypt_open(struct inode *inode, struc
 	if (quiesce_z90crypt)
 		return -EQUIESCE;
 
-	private_data_p = kmalloc(sizeof(struct priv_data), GFP_KERNEL);
+	private_data_p = kzalloc(sizeof(struct priv_data), GFP_KERNEL);
 	if (!private_data_p) {
 		PRINTK("Memory allocate failed\n");
 		return -ENOMEM;
 	}
 
-	memset((void *)private_data_p, 0, sizeof(struct priv_data));
 	private_data_p->status = STAT_OPEN;
 	private_data_p->opener_pid = PID();
 	filp->private_data = private_data_p;
@@ -2736,13 +2735,11 @@ create_z90crypt(int *cdx_p)
 	z90crypt.max_count = Z90CRYPT_NUM_DEVS;
 	z90crypt.cdx = *cdx_p;
 
-	hdware_blk_p = (struct hdware_block *)
-		kmalloc(sizeof(struct hdware_block), GFP_ATOMIC);
+	hdware_blk_p = kzalloc(sizeof(struct hdware_block), GFP_ATOMIC);
 	if (!hdware_blk_p) {
 		PDEBUG("kmalloc for hardware block failed\n");
 		return ENOMEM;
 	}
-	memset(hdware_blk_p, 0x00, sizeof(struct hdware_block));
 	z90crypt.hdware_info = hdware_blk_p;
 
 	return 0;
@@ -2977,12 +2974,11 @@ create_crypto_device(int index)
 		total_size = sizeof(struct device) +
 			     z90crypt.q_depth_array[index] * sizeof(int);
 
-		dev_ptr = (struct device *) kmalloc(total_size, GFP_ATOMIC);
+		dev_ptr = kzalloc(total_size, GFP_ATOMIC);
 		if (!dev_ptr) {
 			PRINTK("kmalloc device %d failed\n", index);
 			return ENOMEM;
 		}
-		memset(dev_ptr, 0, total_size);
 		dev_ptr->dev_resp_p = kmalloc(MAX_RESPONSE_SIZE, GFP_ATOMIC);
 		if (!dev_ptr->dev_resp_p) {
 			kfree(dev_ptr);
--- linux-2.6.16-rc4/drivers/s390/char/monreader.c.orig	2006-02-27 20:10:22.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/char/monreader.c	2006-02-27 20:11:23.000000000 +0100
@@ -257,14 +257,13 @@ mon_alloc_mem(void)
 	int i,j;
 	struct mon_private *monpriv;
 
-	monpriv = kmalloc(sizeof(struct mon_private), GFP_KERNEL);
+	monpriv = kzalloc(sizeof(struct mon_private), GFP_KERNEL);
 	if (!monpriv) {
 		P_ERROR("no memory for monpriv\n");
 		return NULL;
 	}
-	memset(monpriv, 0, sizeof(struct mon_private));
 	for (i = 0; i < MON_MSGLIM; i++) {
-		monpriv->msg_array[i] = kmalloc(sizeof(struct mon_msg),
+		monpriv->msg_array[i] = kzalloc(sizeof(struct mon_msg),
 						    GFP_KERNEL);
 		if (!monpriv->msg_array[i]) {
 			P_ERROR("open, no memory for msg_array\n");
@@ -272,7 +271,6 @@ mon_alloc_mem(void)
 				kfree(monpriv->msg_array[j]);
 			return NULL;
 		}
-		memset(monpriv->msg_array[i], 0, sizeof(struct mon_msg));
 	}
 	return monpriv;
 }
--- linux-2.6.16-rc4/drivers/s390/char/raw3270.c.orig	2006-02-27 20:11:32.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/char/raw3270.c	2006-02-27 20:11:51.000000000 +0100
@@ -115,10 +115,9 @@ raw3270_request_alloc(size_t size)
 	struct raw3270_request *rq;
 
 	/* Allocate request structure */
-	rq = kmalloc(sizeof(struct raw3270_request), GFP_KERNEL | GFP_DMA);
+	rq = kzalloc(sizeof(struct raw3270_request), GFP_KERNEL | GFP_DMA);
 	if (!rq)
 		return ERR_PTR(-ENOMEM);
-	memset(rq, 0, sizeof(struct raw3270_request));
 
 	/* alloc output buffer. */
 	if (size > 0) {
--- linux-2.6.16-rc4/drivers/s390/char/fs3270.c.orig	2006-02-27 20:12:00.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/char/fs3270.c	2006-02-27 20:12:14.000000000 +0100
@@ -368,10 +368,9 @@ fs3270_alloc_view(void)
 {
 	struct fs3270 *fp;
 
-	fp = (struct fs3270 *) kmalloc(sizeof(struct fs3270),GFP_KERNEL);
+	fp = kzalloc(sizeof(struct fs3270),GFP_KERNEL);
 	if (!fp)
 		return ERR_PTR(-ENOMEM);
-	memset(fp, 0, sizeof(struct fs3270));
 	fp->init = raw3270_request_alloc(0);
 	if (IS_ERR(fp->init)) {
 		kfree(fp);
--- linux-2.6.16-rc4/drivers/s390/char/tape_core.c.orig	2006-02-27 20:12:30.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/char/tape_core.c	2006-02-27 20:13:49.000000000 +0100
@@ -453,16 +453,14 @@ tape_alloc_device(void)
 {
 	struct tape_device *device;
 
-	device = (struct tape_device *)
-		kmalloc(sizeof(struct tape_device), GFP_KERNEL);
+	device = kzalloc(sizeof(struct tape_device), GFP_KERNEL);
 	if (device == NULL) {
 		DBF_EXCEPTION(2, "ti:no mem\n");
 		PRINT_INFO ("can't allocate memory for "
 			    "tape info structure\n");
 		return ERR_PTR(-ENOMEM);
 	}
-	memset(device, 0, sizeof(struct tape_device));
-	device->modeset_byte = (char *) kmalloc(1, GFP_KERNEL | GFP_DMA);
+	device->modeset_byte = kmalloc(1, GFP_KERNEL | GFP_DMA);
 	if (device->modeset_byte == NULL) {
 		DBF_EXCEPTION(2, "ti:no mem\n");
 		PRINT_INFO("can't allocate memory for modeset byte\n");
@@ -659,34 +657,30 @@ tape_alloc_request(int cplength, int dat
 
 	DBF_LH(6, "tape_alloc_request(%d, %d)\n", cplength, datasize);
 
-	request = (struct tape_request *) kmalloc(sizeof(struct tape_request),
-						  GFP_KERNEL);
+	request = kzalloc(sizeof(struct tape_request), GFP_KERNEL);
 	if (request == NULL) {
 		DBF_EXCEPTION(1, "cqra nomem\n");
 		return ERR_PTR(-ENOMEM);
 	}
-	memset(request, 0, sizeof(struct tape_request));
 	/* allocate channel program */
 	if (cplength > 0) {
-		request->cpaddr = kmalloc(cplength*sizeof(struct ccw1),
+		request->cpaddr = kcalloc(cplength, sizeof(struct ccw1),
 					  GFP_ATOMIC | GFP_DMA);
 		if (request->cpaddr == NULL) {
 			DBF_EXCEPTION(1, "cqra nomem\n");
 			kfree(request);
 			return ERR_PTR(-ENOMEM);
 		}
-		memset(request->cpaddr, 0, cplength*sizeof(struct ccw1));
 	}
 	/* alloc small kernel buffer */
 	if (datasize > 0) {
-		request->cpdata = kmalloc(datasize, GFP_KERNEL | GFP_DMA);
+		request->cpdata = kzalloc(datasize, GFP_KERNEL | GFP_DMA);
 		if (request->cpdata == NULL) {
 			DBF_EXCEPTION(1, "cqra nomem\n");
 			kfree(request->cpaddr);
 			kfree(request);
 			return ERR_PTR(-ENOMEM);
 		}
-		memset(request->cpdata, 0, datasize);
 	}
 	DBF_LH(6, "New request %p(%p/%p)\n", request, request->cpaddr,
 		request->cpdata);
--- linux-2.6.16-rc4/drivers/s390/char/tape_class.c.orig	2006-02-27 20:14:35.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/char/tape_class.c	2006-02-27 20:14:45.000000000 +0100
@@ -44,11 +44,10 @@ struct tape_class_device *register_tape_
 	int		rc;
 	char *		s;
 
-	tcd = kmalloc(sizeof(struct tape_class_device), GFP_KERNEL);
+	tcd = kzalloc(sizeof(struct tape_class_device), GFP_KERNEL);
 	if (!tcd)
 		return ERR_PTR(-ENOMEM);
 
-	memset(tcd, 0, sizeof(struct tape_class_device));
 	strncpy(tcd->device_name, device_name, TAPECLASS_NAME_LEN);
 	for (s = strchr(tcd->device_name, '/'); s; s = strchr(s, '/'))
 		*s = '!';
--- linux-2.6.16-rc4/drivers/s390/char/keyboard.c.orig	2006-02-27 20:14:53.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/char/keyboard.c	2006-02-27 20:15:34.000000000 +0100
@@ -50,14 +50,12 @@ kbd_alloc(void) {
 	struct kbd_data *kbd;
 	int i, len;
 
-	kbd = kmalloc(sizeof(struct kbd_data), GFP_KERNEL);
+	kbd = kzalloc(sizeof(struct kbd_data), GFP_KERNEL);
 	if (!kbd)
 		goto out;
-	memset(kbd, 0, sizeof(struct kbd_data));
-	kbd->key_maps = kmalloc(sizeof(key_maps), GFP_KERNEL);
+	kbd->key_maps = kzalloc(sizeof(key_maps), GFP_KERNEL);
 	if (!key_maps)
 		goto out_kbd;
-	memset(kbd->key_maps, 0, sizeof(key_maps));
 	for (i = 0; i < ARRAY_SIZE(key_maps); i++) {
 		if (key_maps[i]) {
 			kbd->key_maps[i] =
@@ -68,10 +66,9 @@ kbd_alloc(void) {
 			       sizeof(u_short)*NR_KEYS);
 		}
 	}
-	kbd->func_table = kmalloc(sizeof(func_table), GFP_KERNEL);
+	kbd->func_table = kzalloc(sizeof(func_table), GFP_KERNEL);
 	if (!kbd->func_table)
 		goto out_maps;
-	memset(kbd->func_table, 0, sizeof(func_table));
 	for (i = 0; i < ARRAY_SIZE(func_table); i++) {
 		if (func_table[i]) {
 			len = strlen(func_table[i]) + 1;
@@ -82,10 +79,9 @@ kbd_alloc(void) {
 		}
 	}
 	kbd->fn_handler =
-		kmalloc(sizeof(fn_handler_fn *) * NR_FN_HANDLER, GFP_KERNEL);
+		kzalloc(sizeof(fn_handler_fn *) * NR_FN_HANDLER, GFP_KERNEL);
 	if (!kbd->fn_handler)
 		goto out_func;
-	memset(kbd->fn_handler, 0, sizeof(fn_handler_fn *) * NR_FN_HANDLER);
 	kbd->accent_table =
 		kmalloc(sizeof(struct kbdiacr)*MAX_DIACR, GFP_KERNEL);
 	if (!kbd->accent_table)
--- linux-2.6.16-rc4/drivers/s390/char/vmlogrdr.c.orig	2006-02-27 20:15:44.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/char/vmlogrdr.c	2006-02-27 20:16:02.000000000 +0100
@@ -759,9 +759,8 @@ vmlogrdr_register_device(struct vmlogrdr
 	struct device *dev;
 	int ret;
 
-	dev = kmalloc(sizeof(struct device), GFP_KERNEL);
+	dev = kzalloc(sizeof(struct device), GFP_KERNEL);
 	if (dev) {
-		memset(dev, 0, sizeof(struct device));
 		snprintf(dev->bus_id, BUS_ID_SIZE, "%s",
 			 priv->internal_name);
 		dev->bus = &iucv_bus;
--- linux-2.6.16-rc4/drivers/s390/char/tty3270.c.orig	2006-02-27 20:16:12.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/char/tty3270.c	2006-02-27 20:16:40.000000000 +0100
@@ -691,10 +691,9 @@ tty3270_alloc_view(void)
 	struct tty3270 *tp;
 	int pages;
 
-	tp = kmalloc(sizeof(struct tty3270),GFP_KERNEL);
+	tp = kzalloc(sizeof(struct tty3270), GFP_KERNEL);
 	if (!tp)
 		goto out_err;
-	memset(tp, 0, sizeof(struct tty3270));
 	tp->freemem_pages =
 		kmalloc(sizeof(void *) * TTY3270_STRING_PAGES, GFP_KERNEL);
 	if (!tp->freemem_pages)
@@ -767,16 +766,14 @@ tty3270_alloc_screen(struct tty3270 *tp)
 	int lines;
 
 	size = sizeof(struct tty3270_line) * (tp->view.rows - 2);
-	tp->screen = kmalloc(size, GFP_KERNEL);
+	tp->screen = kzalloc(size, GFP_KERNEL);
 	if (!tp->screen)
 		goto out_err;
-	memset(tp->screen, 0, size);
 	for (lines = 0; lines < tp->view.rows - 2; lines++) {
 		size = sizeof(struct tty3270_cell) * tp->view.cols;
-		tp->screen[lines].cells = kmalloc(size, GFP_KERNEL);
+		tp->screen[lines].cells = kzalloc(size, GFP_KERNEL);
 		if (!tp->screen[lines].cells)
 			goto out_screen;
-		memset(tp->screen[lines].cells, 0, size);
 	}
 	return 0;
 out_screen:
--- linux-2.6.16-rc4/drivers/s390/s390_rdev.c.orig	2006-02-27 20:16:54.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/s390_rdev.c	2006-02-27 20:17:07.000000000 +0100
@@ -27,10 +27,9 @@ s390_root_dev_register(const char *name)
 
 	if (!strlen(name))
 		return ERR_PTR(-EINVAL);
-	dev = kmalloc(sizeof(struct device), GFP_KERNEL);
+	dev = kzalloc(sizeof(struct device), GFP_KERNEL);
 	if (!dev)
 		return ERR_PTR(-ENOMEM);
-	memset(dev, 0, sizeof(struct device));
 	strncpy(dev->bus_id, name, min(strlen(name), (size_t)BUS_ID_SIZE));
 	dev->release = s390_root_dev_release;
 	ret = device_register(dev);
--- linux-2.6.16-rc4/drivers/s390/cio/chsc.c.orig	2006-02-27 20:17:17.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/cio/chsc.c	2006-02-27 20:17:29.000000000 +0100
@@ -1016,10 +1016,9 @@ new_channel_path(int chpid)
 	struct channel_path *chp;
 	int ret;
 
-	chp = kmalloc(sizeof(struct channel_path), GFP_KERNEL);
+	chp = kzalloc(sizeof(struct channel_path), GFP_KERNEL);
 	if (!chp)
 		return -ENOMEM;
-	memset(chp, 0, sizeof(struct channel_path));
 
 	/* fill in status, etc. */
 	chp->id = chpid;
--- linux-2.6.16-rc4/drivers/s390/cio/qdio.c.orig	2006-02-27 20:17:37.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/cio/qdio.c	2006-02-27 20:19:28.000000000 +0100
@@ -1677,16 +1677,14 @@ qdio_alloc_qs(struct qdio_irq *irq_ptr,
 	int result=-ENOMEM;
 
 	for (i=0;i<no_input_qs;i++) {
-		q=kmalloc(sizeof(struct qdio_q),GFP_KERNEL);
+		q=kzalloc(sizeof(struct qdio_q),GFP_KERNEL);
 
 		if (!q) {
 			QDIO_PRINT_ERR("kmalloc of q failed!\n");
 			goto out;
 		}
 
-		memset(q,0,sizeof(struct qdio_q));
-
-		q->slib=kmalloc(PAGE_SIZE,GFP_KERNEL);
+		q->slib = kmalloc(PAGE_SIZE, GFP_KERNEL);
 		if (!q->slib) {
 			QDIO_PRINT_ERR("kmalloc of slib failed!\n");
 			goto out;
@@ -1696,14 +1694,12 @@ qdio_alloc_qs(struct qdio_irq *irq_ptr,
 	}
 
 	for (i=0;i<no_output_qs;i++) {
-		q=kmalloc(sizeof(struct qdio_q),GFP_KERNEL);
+		q = kzalloc(sizeof(struct qdio_q), GFP_KERNEL);
 
 		if (!q) {
 			goto out;
 		}
 
-		memset(q,0,sizeof(struct qdio_q));
-
 		q->slib=kmalloc(PAGE_SIZE,GFP_KERNEL);
 		if (!q->slib) {
 			QDIO_PRINT_ERR("kmalloc of slib failed!\n");
@@ -2975,7 +2971,7 @@ qdio_allocate(struct qdio_initialize *in
 	qdio_allocate_do_dbf(init_data);
 
 	/* create irq */
-	irq_ptr=kmalloc(sizeof(struct qdio_irq), GFP_KERNEL | GFP_DMA);
+	irq_ptr = kzalloc(sizeof(struct qdio_irq), GFP_KERNEL | GFP_DMA);
 
 	QDIO_DBF_TEXT0(0,setup,"irq_ptr:");
 	QDIO_DBF_HEX0(0,setup,&irq_ptr,sizeof(void*));
@@ -2985,8 +2981,6 @@ qdio_allocate(struct qdio_initialize *in
 		return -ENOMEM;
 	}
 
-	memset(irq_ptr,0,sizeof(struct qdio_irq));
-
 	init_MUTEX(&irq_ptr->setting_up_sema);
 
 	/* QDR must be in DMA area since CCW data address is only 32 bit */
@@ -3677,10 +3671,10 @@ qdio_get_qdio_memory(void)
 
 	for (i=1;i<INDICATORS_PER_CACHELINE;i++)
 		indicator_used[i]=0;
-	indicators=(__u32*)kmalloc(sizeof(__u32)*(INDICATORS_PER_CACHELINE),
+	indicators = kzalloc(sizeof(__u32)*(INDICATORS_PER_CACHELINE),
 				   GFP_KERNEL);
-       	if (!indicators) return -ENOMEM;
-	memset(indicators,0,sizeof(__u32)*(INDICATORS_PER_CACHELINE));
+       	if (!indicators)
+		return -ENOMEM;
 	return 0;
 }
 
--- linux-2.6.16-rc4/drivers/s390/cio/device.c.orig	2006-02-27 20:19:38.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/cio/device.c	2006-02-27 20:20:11.000000000 +0100
@@ -826,17 +826,15 @@ io_subchannel_probe (struct subchannel *
 			get_device(&cdev->dev);
 		return 0;
 	}
-	cdev  = kmalloc (sizeof(*cdev), GFP_KERNEL);
+	cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
 	if (!cdev)
 		return -ENOMEM;
-	memset(cdev, 0, sizeof(struct ccw_device));
-	cdev->private = kmalloc(sizeof(struct ccw_device_private), 
+	cdev->private = kzalloc(sizeof(struct ccw_device_private), 
 				GFP_KERNEL | GFP_DMA);
 	if (!cdev->private) {
 		kfree(cdev);
 		return -ENOMEM;
 	}
-	memset(cdev->private, 0, sizeof(struct ccw_device_private));
 	atomic_set(&cdev->private->onoff, 0);
 	cdev->dev = (struct device) {
 		.parent = &sch->dev,
--- linux-2.6.16-rc4/drivers/s390/cio/device_ops.c.orig	2006-02-27 20:20:51.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/cio/device_ops.c	2006-02-27 20:21:25.000000000 +0100
@@ -359,10 +359,9 @@ read_dev_chars (struct ccw_device *cdev,
 	CIO_TRACE_EVENT (4, "rddevch");
 	CIO_TRACE_EVENT (4, sch->dev.bus_id);
 
-	rdc_ccw = kmalloc(sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
+	rdc_ccw = kzalloc(sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
 	if (!rdc_ccw)
 		return -ENOMEM;
-	memset(rdc_ccw, 0, sizeof(struct ccw1));
 	rdc_ccw->cmd_code = CCW_CMD_RDC;
 	rdc_ccw->count = length;
 	rdc_ccw->flags = CCW_FLAG_SLI;
@@ -426,16 +425,14 @@ read_conf_data_lpm (struct ccw_device *c
 	if (!ciw || ciw->cmd == 0)
 		return -EOPNOTSUPP;
 
-	rcd_ccw = kmalloc(sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
+	rcd_ccw = kzalloc(sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
 	if (!rcd_ccw)
 		return -ENOMEM;
-	memset(rcd_ccw, 0, sizeof(struct ccw1));
-	rcd_buf = kmalloc(ciw->count, GFP_KERNEL | GFP_DMA);
+	rcd_buf = kzalloc(ciw->count, GFP_KERNEL | GFP_DMA);
  	if (!rcd_buf) {
 		kfree(rcd_ccw);
 		return -ENOMEM;
 	}
- 	memset (rcd_buf, 0, ciw->count);
 	rcd_ccw->cmd_code = ciw->cmd;
 	rcd_ccw->cda = (__u32) __pa (rcd_buf);
 	rcd_ccw->count = ciw->count;
--- linux-2.6.16-rc4/drivers/s390/cio/css.c.orig	2006-02-27 20:21:34.000000000 +0100
+++ linux-2.6.16-rc4/drivers/s390/cio/css.c	2006-02-27 20:21:46.000000000 +0100
@@ -586,10 +586,9 @@ css_enqueue_subchannel_slow(struct subch
 	struct slow_subchannel *new_slow_sch;
 	unsigned long flags;
 
-	new_slow_sch = kmalloc(sizeof(struct slow_subchannel), GFP_ATOMIC);
+	new_slow_sch = kzalloc(sizeof(struct slow_subchannel), GFP_ATOMIC);
 	if (!new_slow_sch)
 		return -ENOMEM;
-	memset(new_slow_sch, 0, sizeof(struct slow_subchannel));
 	new_slow_sch->schid = schid;
 	spin_lock_irqsave(&slow_subchannel_lock, flags);
 	list_add_tail(&new_slow_sch->slow_list, &slow_subchannels_head);



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/pci
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (7 preceding siblings ...)
  2006-02-28 13:54 ` [KJ] [Patch] kzalloc() conversion in drivers/s390 Eric Sesterhenn
@ 2006-02-28 14:34 ` Eric Sesterhenn
  2006-02-28 21:39 ` [KJ] [Patch] kzalloc() conversion in drivers/usb/gadget Alexey Dobriyan
                   ` (22 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-02-28 14:34 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 36263 bytes --]

hi,

this patch converts drivers/pci to kzalloc usage.
Compile tested with allyes config.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc4-mm2/drivers/pci/pcie/portdrv_core.c.orig	2006-02-28 14:58:19.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/pci/pcie/portdrv_core.c	2006-02-28 14:58:32.000000000 +0100
@@ -248,11 +248,10 @@ static struct pcie_device* alloc_pcie_de
 {
 	struct pcie_device *device;
 
-	device = kmalloc(sizeof(struct pcie_device), GFP_KERNEL);
+	device = kzalloc(sizeof(struct pcie_device), GFP_KERNEL);
 	if (!device)
 		return NULL;
 
-	memset(device, 0, sizeof(struct pcie_device));
 	pcie_device_init(parent, device, port_type, service_type, irq,irq_mode);
 	printk(KERN_DEBUG "Allocate Port Service[%s]\n", device->device.bus_id);
 	return device;
--- linux-2.6.16-rc4-mm2/drivers/pci/pci-sysfs.c.orig	2006-02-28 14:58:45.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/pci/pci-sysfs.c	2006-02-28 14:58:55.000000000 +0100
@@ -501,9 +501,8 @@ int pci_create_sysfs_dev_files (struct p
 	if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) {
 		struct bin_attribute *rom_attr;
 		
-		rom_attr = kmalloc(sizeof(*rom_attr), GFP_ATOMIC);
+		rom_attr = kzalloc(sizeof(*rom_attr), GFP_ATOMIC);
 		if (rom_attr) {
-			memset(rom_attr, 0x00, sizeof(*rom_attr));
 			pdev->rom_attr = rom_attr;
 			rom_attr->size = pci_resource_len(pdev, PCI_ROM_RESOURCE);
 			rom_attr->attr.name = "rom";
--- linux-2.6.16-rc4-mm2/drivers/pci/pci-driver.c.orig	2006-02-28 14:59:02.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/pci/pci-driver.c	2006-02-28 14:59:14.000000000 +0100
@@ -53,11 +53,10 @@ store_new_id(struct device_driver *drive
 	if (fields < 0)
 		return -EINVAL;
 
-	dynid = kmalloc(sizeof(*dynid), GFP_KERNEL);
+	dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
 	if (!dynid)
 		return -ENOMEM;
 
-	memset(dynid, 0, sizeof(*dynid));
 	INIT_LIST_HEAD(&dynid->node);
 	dynid->id.vendor = vendor;
 	dynid->id.device = device;
--- linux-2.6.16-rc4-mm2/drivers/pci/probe.c.orig	2006-02-28 14:59:22.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/pci/probe.c	2006-02-28 14:59:59.000000000 +0100
@@ -33,10 +33,9 @@ LIST_HEAD(pci_devices);
  */
 static void pci_create_legacy_files(struct pci_bus *b)
 {
-	b->legacy_io = kmalloc(sizeof(struct bin_attribute) * 2,
+	b->legacy_io = kzalloc(sizeof(struct bin_attribute) * 2,
 			       GFP_ATOMIC);
 	if (b->legacy_io) {
-		memset(b->legacy_io, 0, sizeof(struct bin_attribute) * 2);
 		b->legacy_io->attr.name = "legacy_io";
 		b->legacy_io->size = 0xffff;
 		b->legacy_io->attr.mode = S_IRUSR | S_IWUSR;
@@ -320,9 +319,8 @@ static struct pci_bus * __devinit pci_al
 {
 	struct pci_bus *b;
 
-	b = kmalloc(sizeof(*b), GFP_KERNEL);
+	b = kzalloc(sizeof(*b), GFP_KERNEL);
 	if (b) {
-		memset(b, 0, sizeof(*b));
 		INIT_LIST_HEAD(&b->node);
 		INIT_LIST_HEAD(&b->children);
 		INIT_LIST_HEAD(&b->devices);
@@ -797,11 +795,10 @@ pci_scan_device(struct pci_bus *bus, int
 	if (pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type))
 		return NULL;
 
-	dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL);
+	dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL);
 	if (!dev)
 		return NULL;
 
-	memset(dev, 0, sizeof(struct pci_dev));
 	dev->bus = bus;
 	dev->sysdata = bus->sysdata;
 	dev->dev.parent = bus->bridge;
--- linux-2.6.16-rc4-mm2/drivers/pci/hotplug/ibmphp_ebda.c.orig	2006-02-28 15:00:51.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/pci/hotplug/ibmphp_ebda.c	2006-02-28 15:07:04.000000000 +0100
@@ -72,13 +72,7 @@ static int ebda_rio_table (void);
 
 static struct ebda_hpc_list * __init alloc_ebda_hpc_list (void)
 {
-	struct ebda_hpc_list *list;
-
-	list = kmalloc (sizeof (struct ebda_hpc_list), GFP_KERNEL);
-	if (!list)
-		return NULL;
-	memset (list, 0, sizeof (*list));
-	return list;
+	return kzalloc(sizeof(struct ebda_hpc_list), GFP_KERNEL);
 }
 
 static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count)
@@ -87,21 +81,18 @@ static struct controller *alloc_ebda_hpc
 	struct ebda_hpc_slot *slots;
 	struct ebda_hpc_bus *buses;
 
-	controller = kmalloc (sizeof (struct controller), GFP_KERNEL);
+	controller = kzalloc(sizeof(struct controller), GFP_KERNEL);
 	if (!controller)
 		goto error;
-	memset (controller, 0, sizeof (*controller));
 
-	slots = kmalloc (sizeof (struct ebda_hpc_slot) * slot_count, GFP_KERNEL);
+	slots = kcalloc(slot_count, sizeof(struct ebda_hpc_slot), GFP_KERNEL);
 	if (!slots)
 		goto error_contr;
-	memset (slots, 0, sizeof (*slots) * slot_count);
 	controller->slots = slots;
 
-	buses = kmalloc (sizeof (struct ebda_hpc_bus) * bus_count, GFP_KERNEL);
+	buses = kcalloc(bus_count, sizeof(struct ebda_hpc_bus), GFP_KERNEL);
 	if (!buses)
 		goto error_slots;
-	memset (buses, 0, sizeof (*buses) * bus_count);
 	controller->buses = buses;
 
 	return controller;
@@ -122,24 +113,12 @@ static void free_ebda_hpc (struct contro
 
 static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list (void)
 {
-	struct ebda_rsrc_list *list;
-
-	list = kmalloc (sizeof (struct ebda_rsrc_list), GFP_KERNEL);
-	if (!list)
-		return NULL;
-	memset (list, 0, sizeof (*list));
-	return list;
+	return kzalloc(sizeof(struct ebda_rsrc_list), GFP_KERNEL);
 }
 
 static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc (void)
 {
-	struct ebda_pci_rsrc *resource;
-
-	resource = kmalloc (sizeof (struct ebda_pci_rsrc), GFP_KERNEL);
-	if (!resource)
-		return NULL;
-	memset (resource, 0, sizeof (*resource));
-	return resource;
+	return kzalloc(sizeof(struct ebda_pci_rsrc), GFP_KERNEL);
 }
 
 static void __init print_bus_info (void)
@@ -390,10 +369,9 @@ int __init ibmphp_access_ebda (void)
 			debug ("now enter io table ---\n");
 			debug ("rio blk id: %x\n", blk_id);
 
-			rio_table_ptr = kmalloc (sizeof (struct rio_table_hdr), GFP_KERNEL);
+			rio_table_ptr = kzalloc(sizeof(struct rio_table_hdr), GFP_KERNEL);
 			if (!rio_table_ptr)
 				return -ENOMEM; 
-			memset (rio_table_ptr, 0, sizeof (struct rio_table_hdr) );
 			rio_table_ptr->ver_num = readb (io_mem + offset);
 			rio_table_ptr->scal_count = readb (io_mem + offset + 1);
 			rio_table_ptr->riodev_count = readb (io_mem + offset + 2);
@@ -445,10 +423,9 @@ static int __init ebda_rio_table (void)
 
 	// we do concern about rio details
 	for (i = 0; i < rio_table_ptr->riodev_count; i++) {
-		rio_detail_ptr = kmalloc (sizeof (struct rio_detail), GFP_KERNEL);
+		rio_detail_ptr = kzalloc(sizeof(struct rio_detail), GFP_KERNEL);
 		if (!rio_detail_ptr)
 			return -ENOMEM;
-		memset (rio_detail_ptr, 0, sizeof (struct rio_detail));
 		rio_detail_ptr->rio_node_id = readb (io_mem + offset);
 		rio_detail_ptr->bbar = readl (io_mem + offset + 1);
 		rio_detail_ptr->rio_type = readb (io_mem + offset + 5);
@@ -503,10 +480,9 @@ static int __init combine_wpg_for_chassi
 		rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list);
 		opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num);
 		if (!opt_rio_ptr) {
-			opt_rio_ptr = (struct opt_rio *) kmalloc (sizeof (struct opt_rio), GFP_KERNEL);
+			opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL);
 			if (!opt_rio_ptr)
 				return -ENOMEM;
-			memset (opt_rio_ptr, 0, sizeof (struct opt_rio));
 			opt_rio_ptr->rio_type = rio_detail_ptr->rio_type;
 			opt_rio_ptr->chassis_num = rio_detail_ptr->chassis_num;
 			opt_rio_ptr->first_slot_num = rio_detail_ptr->first_slot_num;
@@ -546,10 +522,9 @@ static int combine_wpg_for_expansion (vo
 		rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list);
 		opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num);
 		if (!opt_rio_lo_ptr) {
-			opt_rio_lo_ptr = (struct opt_rio_lo *) kmalloc (sizeof (struct opt_rio_lo), GFP_KERNEL);
+			opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL);
 			if (!opt_rio_lo_ptr)
 				return -ENOMEM;
-			memset (opt_rio_lo_ptr, 0, sizeof (struct opt_rio_lo));
 			opt_rio_lo_ptr->rio_type = rio_detail_ptr->rio_type;
 			opt_rio_lo_ptr->chassis_num = rio_detail_ptr->chassis_num;
 			opt_rio_lo_ptr->first_slot_num = rio_detail_ptr->first_slot_num;
@@ -842,12 +817,11 @@ static int __init ebda_rsrc_controller (
 
 			bus_info_ptr2 = ibmphp_find_same_bus_num (slot_ptr->slot_bus_num);
 			if (!bus_info_ptr2) {
-				bus_info_ptr1 = (struct bus_info *) kmalloc (sizeof (struct bus_info), GFP_KERNEL);
+				bus_info_ptr1 = kzalloc(sizeof(struct bus_info), GFP_KERNEL);
 				if (!bus_info_ptr1) {
 					rc = -ENOMEM;
 					goto error_no_hp_slot;
 				}
-				memset (bus_info_ptr1, 0, sizeof (struct bus_info));
 				bus_info_ptr1->slot_min = slot_ptr->slot_num;
 				bus_info_ptr1->slot_max = slot_ptr->slot_num;
 				bus_info_ptr1->slot_count += 1;
@@ -946,19 +920,17 @@ static int __init ebda_rsrc_controller (
 		// register slots with hpc core as well as create linked list of ibm slot
 		for (index = 0; index < hpc_ptr->slot_count; index++) {
 
-			hp_slot_ptr = kmalloc(sizeof(*hp_slot_ptr), GFP_KERNEL);
+			hp_slot_ptr = kzalloc(sizeof(*hp_slot_ptr), GFP_KERNEL);
 			if (!hp_slot_ptr) {
 				rc = -ENOMEM;
 				goto error_no_hp_slot;
 			}
-			memset(hp_slot_ptr, 0, sizeof(*hp_slot_ptr));
 
-			hp_slot_ptr->info = kmalloc (sizeof(struct hotplug_slot_info), GFP_KERNEL);
+			hp_slot_ptr->info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
 			if (!hp_slot_ptr->info) {
 				rc = -ENOMEM;
 				goto error_no_hp_info;
 			}
-			memset(hp_slot_ptr->info, 0, sizeof(struct hotplug_slot_info));
 
 			hp_slot_ptr->name = kmalloc(30, GFP_KERNEL);
 			if (!hp_slot_ptr->name) {
@@ -966,12 +938,11 @@ static int __init ebda_rsrc_controller (
 				goto error_no_hp_name;
 			}
 
-			tmp_slot = kmalloc(sizeof(*tmp_slot), GFP_KERNEL);
+			tmp_slot = kzalloc(sizeof(*tmp_slot), GFP_KERNEL);
 			if (!tmp_slot) {
 				rc = -ENOMEM;
 				goto error_no_slot;
 			}
-			memset(tmp_slot, 0, sizeof(*tmp_slot));
 
 			tmp_slot->flag = TRUE;
 
--- linux-2.6.16-rc4-mm2/drivers/pci/hotplug/pciehp_core.c.orig	2006-02-28 15:07:09.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/pci/hotplug/pciehp_core.c	2006-02-28 15:08:14.000000000 +0100
@@ -117,27 +117,23 @@ static int init_slots(struct controller 
 	slot_number = ctrl->first_slot;
 
 	while (number_of_slots) {
-		slot = kmalloc(sizeof(*slot), GFP_KERNEL);
+		slot = kzalloc(sizeof(*slot), GFP_KERNEL);
 		if (!slot)
 			goto error;
 
-		memset(slot, 0, sizeof(struct slot));
 		slot->hotplug_slot =
-				kmalloc(sizeof(*(slot->hotplug_slot)),
+				kzalloc(sizeof(*(slot->hotplug_slot)),
 						GFP_KERNEL);
 		if (!slot->hotplug_slot)
 			goto error_slot;
 		hotplug_slot = slot->hotplug_slot;
-		memset(hotplug_slot, 0, sizeof(struct hotplug_slot));
 
 		hotplug_slot->info =
-			kmalloc(sizeof(*(hotplug_slot->info)),
+			kzalloc(sizeof(*(hotplug_slot->info)),
 						GFP_KERNEL);
 		if (!hotplug_slot->info)
 			goto error_hpslot;
 		hotplug_slot_info = hotplug_slot->info;
-		memset(hotplug_slot_info, 0,
-					sizeof(struct hotplug_slot_info));
 		hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
 		if (!hotplug_slot->name)
 			goto error_info;
@@ -373,12 +369,11 @@ static int pciehp_probe(struct pcie_devi
 	u8 value;
 	struct pci_dev *pdev;
 	
-	ctrl = kmalloc(sizeof(*ctrl), GFP_KERNEL);
+	ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
 	if (!ctrl) {
 		err("%s : out of memory\n", __FUNCTION__);
 		goto err_out_none;
 	}
-	memset(ctrl, 0, sizeof(struct controller));
 
 	pdev = dev->port;
 	ctrl->pci_dev = pdev;
--- linux-2.6.16-rc4-mm2/drivers/pci/hotplug/cpqphp_core.c.orig	2006-02-28 15:08:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/pci/hotplug/cpqphp_core.c	2006-02-28 15:09:21.000000000 +0100
@@ -347,26 +347,22 @@ static int ctrl_slot_setup(struct contro
 	slot_number = ctrl->first_slot;
 
 	while (number_of_slots) {
-		slot = kmalloc(sizeof(*slot), GFP_KERNEL);
+		slot = kzalloc(sizeof(*slot), GFP_KERNEL);
 		if (!slot)
 			goto error;
 
-		memset(slot, 0, sizeof(struct slot));
-		slot->hotplug_slot = kmalloc(sizeof(*(slot->hotplug_slot)),
+		slot->hotplug_slot = kzalloc(sizeof(*(slot->hotplug_slot)),
 						GFP_KERNEL);
 		if (!slot->hotplug_slot)
 			goto error_slot;
 		hotplug_slot = slot->hotplug_slot;
-		memset(hotplug_slot, 0, sizeof(struct hotplug_slot));
 
 		hotplug_slot->info =
-				kmalloc(sizeof(*(hotplug_slot->info)),
+				kzalloc(sizeof(*(hotplug_slot->info)),
 							GFP_KERNEL);
 		if (!hotplug_slot->info)
 			goto error_hpslot;
 		hotplug_slot_info = hotplug_slot->info;
-		memset(hotplug_slot_info, 0,
-				sizeof(struct hotplug_slot_info));
 		hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
 
 		if (!hotplug_slot->name)
@@ -854,13 +850,12 @@ static int cpqhpc_probe(struct pci_dev *
 			goto err_disable_device;
 		}
 
-		ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL);
+		ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL);
 		if (!ctrl) {
 			err("%s : out of memory\n", __FUNCTION__);
 			rc = -ENOMEM;
 			goto err_disable_device;
 		}
-		memset(ctrl, 0, sizeof(struct controller));
 
 		rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsystem_deviceid);
 		if (rc) {
--- linux-2.6.16-rc4-mm2/drivers/pci/hotplug/cpci_hotplug_core.c.orig	2006-02-28 15:10:07.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/pci/hotplug/cpci_hotplug_core.c	2006-02-28 15:10:46.000000000 +0100
@@ -248,22 +248,19 @@ cpci_hp_register_bus(struct pci_bus *bus
 	 * with the pci_hotplug subsystem.
 	 */
 	for (i = first; i <= last; ++i) {
-		slot = kmalloc(sizeof (struct slot), GFP_KERNEL);
+		slot = kzalloc(sizeof (struct slot), GFP_KERNEL);
 		if (!slot)
 			goto error;
-		memset(slot, 0, sizeof (struct slot));
 
 		hotplug_slot =
-		    kmalloc(sizeof (struct hotplug_slot), GFP_KERNEL);
+			kzalloc(sizeof (struct hotplug_slot), GFP_KERNEL);
 		if (!hotplug_slot)
 			goto error_slot;
-		memset(hotplug_slot, 0, sizeof (struct hotplug_slot));
 		slot->hotplug_slot = hotplug_slot;
 
-		info = kmalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL);
+		info = kzalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL);
 		if (!info)
 			goto error_hpslot;
-		memset(info, 0, sizeof (struct hotplug_slot_info));
 		hotplug_slot->info = info;
 
 		name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
--- linux-2.6.16-rc4-mm2/drivers/pci/hotplug/ibmphp_core.c.orig	2006-02-28 15:10:56.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/pci/hotplug/ibmphp_core.c	2006-02-28 15:11:15.000000000 +0100
@@ -1141,7 +1141,7 @@ static int enable_slot(struct hotplug_sl
 		goto error_power;
 	}
 
-	slot_cur->func = kmalloc(sizeof(struct pci_func), GFP_KERNEL);
+	slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL);
 	if (!slot_cur->func) {
 		/* We cannot do update_slot_info here, since no memory for
 		 * kmalloc n.e.ways, and update_slot_info allocates some */
@@ -1149,7 +1149,6 @@ static int enable_slot(struct hotplug_sl
 		rc = -ENOMEM;
 		goto error_power;
 	}
-	memset(slot_cur->func, 0, sizeof(struct pci_func));
 	slot_cur->func->busno = slot_cur->bus;
 	slot_cur->func->device = slot_cur->device;
 	for (i = 0; i < 4; i++)
@@ -1252,13 +1251,12 @@ int ibmphp_do_disable_slot(struct slot *
 
 	if (slot_cur->func == NULL) {
 		/* We need this for fncs's that were there on bootup */
-		slot_cur->func = kmalloc(sizeof(struct pci_func), GFP_KERNEL);
+		slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL);
 		if (!slot_cur->func) {
 			err("out of system memory\n");
 			rc = -ENOMEM;
 			goto error;
 		}
-		memset(slot_cur->func, 0, sizeof(struct pci_func));
 		slot_cur->func->busno = slot_cur->bus;
 		slot_cur->func->device = slot_cur->device;
 	}
--- linux-2.6.16-rc4-mm2/drivers/pci/hotplug/rpaphp_slot.c.orig	2006-02-28 15:11:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/pci/hotplug/rpaphp_slot.c	2006-02-28 15:12:06.000000000 +0100
@@ -84,19 +84,16 @@ struct slot *alloc_slot_struct(struct de
 {
 	struct slot *slot;
 	
-	slot = kmalloc(sizeof (struct slot), GFP_KERNEL);
+	slot = kzalloc(sizeof(struct slot), GFP_KERNEL);
 	if (!slot)
 		goto error_nomem;
-	memset(slot, 0, sizeof (struct slot));
-	slot->hotplug_slot = kmalloc(sizeof (struct hotplug_slot), GFP_KERNEL);
+	slot->hotplug_slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
 	if (!slot->hotplug_slot)
 		goto error_slot;	
-	memset(slot->hotplug_slot, 0, sizeof (struct hotplug_slot));
-	slot->hotplug_slot->info = kmalloc(sizeof (struct hotplug_slot_info),
+	slot->hotplug_slot->info = kzalloc(sizeof(struct hotplug_slot_info),
 					   GFP_KERNEL);
 	if (!slot->hotplug_slot->info)
 		goto error_hpslot;
-	memset(slot->hotplug_slot->info, 0, sizeof (struct hotplug_slot_info));
 	slot->hotplug_slot->name = kmalloc(BUS_ID_SIZE + 1, GFP_KERNEL);
 	if (!slot->hotplug_slot->name)
 		goto error_info;	
--- linux-2.6.16-rc4-mm2/drivers/pci/hotplug/ibmphp_res.c.orig	2006-02-28 15:13:06.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/pci/hotplug/ibmphp_res.c	2006-02-28 15:15:40.000000000 +0100
@@ -55,13 +55,12 @@ static struct bus_node * __init alloc_er
 		return NULL;
 	}
 
-	newbus = kmalloc (sizeof (struct bus_node), GFP_KERNEL);
+	newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL);
 	if (!newbus) {
 		err ("out of system memory\n");
 		return NULL;
 	}
 
-	memset (newbus, 0, sizeof (struct bus_node));
 	if (flag)
 		newbus->busno = busno;
 	else
@@ -79,12 +78,11 @@ static struct resource_node * __init all
 		return NULL;
 	}
 
-	rs = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+	rs = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
 	if (!rs) {
 		err ("out of system memory\n");
 		return NULL;
 	}
-	memset (rs, 0, sizeof (struct resource_node));
 	rs->busno = curr->bus_num;
 	rs->devfunc = curr->dev_fun;
 	rs->start = curr->start_addr;
@@ -100,12 +98,11 @@ static int __init alloc_bus_range (struc
 	u8 num_ranges = 0;
 
 	if (first_bus) {
-		newbus = kmalloc (sizeof (struct bus_node), GFP_KERNEL);
+		newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL);
 		if (!newbus) {
 			err ("out of system memory.\n");
 			return -ENOMEM;
 		}
-		memset (newbus, 0, sizeof (struct bus_node));
 		newbus->busno = curr->bus_num;
 	} else {
 		newbus = *new_bus;
@@ -122,14 +119,13 @@ static int __init alloc_bus_range (struc
 		}
 	}
 
-	newrange = kmalloc (sizeof (struct range_node), GFP_KERNEL);
+	newrange = kzalloc(sizeof(struct range_node), GFP_KERNEL);
 	if (!newrange) {
 		if (first_bus)
 			kfree (newbus);
 		err ("out of system memory\n");
 		return -ENOMEM;
 	}
-	memset (newrange, 0, sizeof (struct range_node));
 	newrange->start = curr->start_addr;
 	newrange->end = curr->end_addr;
 		
@@ -1705,12 +1701,11 @@ static int __init once_over (void)
 
 				bus_cur->firstPFMemFromMem = pfmem_cur;
 
-				mem = kmalloc (sizeof (struct resource_node), GFP_KERNEL);		
+				mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL);		
 				if (!mem) {
 					err ("out of system memory\n");
 					return -ENOMEM;
 				}
-				memset (mem, 0, sizeof (struct resource_node));
 				mem->type = MEM;
 				mem->busno = pfmem_cur->busno;
 				mem->devfunc = pfmem_cur->devfunc;
@@ -1994,12 +1989,11 @@ static int __init update_bridge_ranges (
 						end_address |= (upper_io_end << 16);
 
 						if ((start_address) && (start_address <= end_address)) {
-							range = kmalloc (sizeof (struct range_node), GFP_KERNEL);
+							range = kzalloc(sizeof(struct range_node), GFP_KERNEL);
 							if (!range) {
 								err ("out of system memory\n");
 								return -ENOMEM;
 							}
-							memset (range, 0, sizeof (struct range_node));
 							range->start = start_address;
 							range->end = end_address + 0xfff;
 
@@ -2020,13 +2014,12 @@ static int __init update_bridge_ranges (
 							fix_resources (bus_sec);
 
 							if (ibmphp_find_resource (bus_cur, start_address, &io, IO)) {
-								io = kmalloc (sizeof (struct resource_node), GFP_KERNEL);							
+								io = kzalloc(sizeof(struct resource_node), GFP_KERNEL);							
 								if (!io) {
 									kfree (range);
 									err ("out of system memory\n");
 									return -ENOMEM;
 								}
-								memset (io, 0, sizeof (struct resource_node));
 								io->type = IO;
 								io->busno = bus_cur->busno;
 								io->devfunc = ((device << 3) | (function & 0x7));
@@ -2045,12 +2038,11 @@ static int __init update_bridge_ranges (
 
 						if ((start_address) && (start_address <= end_address)) {
 
-							range = kmalloc (sizeof (struct range_node), GFP_KERNEL);
+							range = kzalloc(sizeof(struct range_node), GFP_KERNEL);
 							if (!range) {
 								err ("out of system memory\n");
 								return -ENOMEM;
 							}
-							memset (range, 0, sizeof (struct range_node));
 							range->start = start_address;
 							range->end = end_address + 0xfffff;
 
@@ -2072,13 +2064,12 @@ static int __init update_bridge_ranges (
 							fix_resources (bus_sec);
 
 							if (ibmphp_find_resource (bus_cur, start_address, &mem, MEM)) {
-								mem = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+								mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
 								if (!mem) {
 									kfree (range);
 									err ("out of system memory\n");
 									return -ENOMEM;
 								}
-								memset (mem, 0, sizeof (struct resource_node));
 								mem->type = MEM;
 								mem->busno = bus_cur->busno;
 								mem->devfunc = ((device << 3) | (function & 0x7));
@@ -2101,12 +2092,11 @@ static int __init update_bridge_ranges (
 
 						if ((start_address) && (start_address <= end_address)) {
 
-							range = kmalloc (sizeof (struct range_node), GFP_KERNEL);
+							range = kzalloc(sizeof(struct range_node), GFP_KERNEL);
 							if (!range) {
 								err ("out of system memory\n");
 								return -ENOMEM;
 							}
-							memset (range, 0, sizeof (struct range_node));
 							range->start = start_address;
 							range->end = end_address + 0xfffff;
 
@@ -2127,13 +2117,12 @@ static int __init update_bridge_ranges (
 
 							fix_resources (bus_sec);
 							if (ibmphp_find_resource (bus_cur, start_address, &pfmem, PFMEM)) {
-								pfmem = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+								pfmem = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
 								if (!pfmem) {
 									kfree (range);
 									err ("out of system memory\n");
 									return -ENOMEM;
 								}
-								memset (pfmem, 0, sizeof (struct resource_node));
 								pfmem->type = PFMEM;
 								pfmem->busno = bus_cur->busno;
 								pfmem->devfunc = ((device << 3) | (function & 0x7));
--- linux-2.6.16-rc4-mm2/drivers/pci/hotplug/acpiphp_glue.c.orig	2006-02-28 15:15:56.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/pci/hotplug/acpiphp_glue.c	2006-02-28 15:16:31.000000000 +0100
@@ -143,10 +143,9 @@ register_slot(acpi_handle handle, u32 lv
 	device = (adr >> 16) & 0xffff;
 	function = adr & 0xffff;
 
-	newfunc = kmalloc(sizeof(struct acpiphp_func), GFP_KERNEL);
+	newfunc = kzalloc(sizeof(struct acpiphp_func), GFP_KERNEL);
 	if (!newfunc)
 		return AE_NO_MEMORY;
-	memset(newfunc, 0, sizeof(struct acpiphp_func));
 
 	INIT_LIST_HEAD(&newfunc->sibling);
 	newfunc->handle = handle;
@@ -189,13 +188,12 @@ register_slot(acpi_handle handle, u32 lv
 		}
 
 	if (!slot) {
-		slot = kmalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
+		slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
 		if (!slot) {
 			kfree(newfunc);
 			return AE_NO_MEMORY;
 		}
 
-		memset(slot, 0, sizeof(struct acpiphp_slot));
 		slot->bridge = bridge;
 		slot->device = device;
 		slot->sun = sun;
@@ -376,12 +374,10 @@ static void add_host_bridge(acpi_handle 
 {
 	struct acpiphp_bridge *bridge;
 
-	bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
+	bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
 	if (bridge == NULL)
 		return;
 
-	memset(bridge, 0, sizeof(struct acpiphp_bridge));
-
 	bridge->type = BRIDGE_TYPE_HOST;
 	bridge->handle = handle;
 
@@ -398,14 +394,12 @@ static void add_p2p_bridge(acpi_handle *
 {
 	struct acpiphp_bridge *bridge;
 
-	bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
+	bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
 	if (bridge == NULL) {
 		err("out of memory\n");
 		return;
 	}
 
-	memset(bridge, 0, sizeof(struct acpiphp_bridge));
-
 	bridge->type = BRIDGE_TYPE_P2P;
 	bridge->handle = handle;
 
--- linux-2.6.16-rc4-mm2/drivers/pci/hotplug/ibmphp_pci.c.orig	2006-02-28 15:16:53.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/pci/hotplug/ibmphp_pci.c	2006-02-28 15:21:22.000000000 +0100
@@ -164,12 +164,11 @@ int ibmphp_configure_card (struct pci_fu
 						cleanup_count = 6;
 						goto error;
 					}
-					newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL);
+					newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
 					if (!newfunc) {
 						err ("out of system memory\n");
 						return -ENOMEM;
 					}
-					memset (newfunc, 0, sizeof (struct pci_func));
 					newfunc->busno = cur_func->busno;
 					newfunc->device = device;
 					cur_func->next = newfunc;
@@ -203,12 +202,11 @@ int ibmphp_configure_card (struct pci_fu
 					flag = FALSE;
 					for (i = 0; i < 32; i++) {
 						if (func->devices[i]) {
-							newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL);
+							newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
 							if (!newfunc) {
 								err ("out of system memory\n");
 								return -ENOMEM;
 							}
-							memset (newfunc, 0, sizeof (struct pci_func));
 							newfunc->busno = sec_number;
 							newfunc->device = (u8) i;
 							for (j = 0; j < 4; j++)
@@ -232,12 +230,11 @@ int ibmphp_configure_card (struct pci_fu
 						}
 					}
 
-					newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL);
+					newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
 					if (!newfunc) {
 						err ("out of system memory\n");
 						return -ENOMEM;
 					}
-					memset (newfunc, 0, sizeof (struct pci_func));
 					newfunc->busno = cur_func->busno;
 					newfunc->device = device;
 					for (j = 0; j < 4; j++)
@@ -279,12 +276,11 @@ int ibmphp_configure_card (struct pci_fu
 					for (i = 0; i < 32; i++) {
 						if (func->devices[i]) {
 							debug ("inside for loop, device is %x\n", i);
-							newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL);
+							newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
 							if (!newfunc) {
 								err (" out of system memory\n");
 								return -ENOMEM;
 							}
-							memset (newfunc, 0, sizeof (struct pci_func));
 							newfunc->busno = sec_number;
 							newfunc->device = (u8) i;
 							for (j = 0; j < 4; j++)
@@ -405,13 +401,12 @@ static int configure_device (struct pci_
 
 			debug ("len[count] in IO %x, count %d\n", len[count], count);
 
-			io[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+			io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
 
 			if (!io[count]) {
 				err ("out of system memory\n");
 				return -ENOMEM;
 			}
-			memset (io[count], 0, sizeof (struct resource_node));
 			io[count]->type = IO;
 			io[count]->busno = func->busno;
 			io[count]->devfunc = PCI_DEVFN(func->device, func->function);
@@ -444,12 +439,11 @@ static int configure_device (struct pci_
 
 				debug ("len[count] in PFMEM %x, count %d\n", len[count], count);
 
-				pfmem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+				pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
 				if (!pfmem[count]) {
 					err ("out of system memory\n");
 					return -ENOMEM;
 				}
-				memset (pfmem[count], 0, sizeof (struct resource_node));
 				pfmem[count]->type = PFMEM;
 				pfmem[count]->busno = func->busno;
 				pfmem[count]->devfunc = PCI_DEVFN(func->device,
@@ -460,13 +454,12 @@ static int configure_device (struct pci_
 					ibmphp_add_resource (pfmem[count]);
 					func->pfmem[count] = pfmem[count];
 				} else {
-					mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL);
+					mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
 					if (!mem_tmp) {
 						err ("out of system memory\n");
 						kfree (pfmem[count]);
 						return -ENOMEM;
 					}
-					memset (mem_tmp, 0, sizeof (struct resource_node));
 					mem_tmp->type = MEM;
 					mem_tmp->busno = pfmem[count]->busno;
 					mem_tmp->devfunc = pfmem[count]->devfunc;
@@ -512,12 +505,11 @@ static int configure_device (struct pci_
 
 				debug ("len[count] in Mem %x, count %d\n", len[count], count);
 
-				mem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+				mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
 				if (!mem[count]) {
 					err ("out of system memory\n");
 					return -ENOMEM;
 				}
-				memset (mem[count], 0, sizeof (struct resource_node));
 				mem[count]->type = MEM;
 				mem[count]->busno = func->busno;
 				mem[count]->devfunc = PCI_DEVFN(func->device,
@@ -677,14 +669,13 @@ static int configure_bridge (struct pci_
 
 			debug ("len[count] in IO = %x\n", len[count]);
 
-			bus_io[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+			bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
 		
 			if (!bus_io[count]) {
 				err ("out of system memory\n");
 				retval = -ENOMEM;
 				goto error;
 			}
-			memset (bus_io[count], 0, sizeof (struct resource_node));
 			bus_io[count]->type = IO;
 			bus_io[count]->busno = func->busno;
 			bus_io[count]->devfunc = PCI_DEVFN(func->device,
@@ -711,13 +702,12 @@ static int configure_bridge (struct pci_
 
 				debug ("len[count] in PFMEM = %x\n", len[count]);
 
-				bus_pfmem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+				bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
 				if (!bus_pfmem[count]) {
 					err ("out of system memory\n");
 					retval = -ENOMEM;
 					goto error;
 				}
-				memset (bus_pfmem[count], 0, sizeof (struct resource_node));
 				bus_pfmem[count]->type = PFMEM;
 				bus_pfmem[count]->busno = func->busno;
 				bus_pfmem[count]->devfunc = PCI_DEVFN(func->device,
@@ -728,13 +718,12 @@ static int configure_bridge (struct pci_
 					ibmphp_add_resource (bus_pfmem[count]);
 					func->pfmem[count] = bus_pfmem[count];
 				} else {
-					mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL);
+					mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
 					if (!mem_tmp) {
 						err ("out of system memory\n");
 						retval = -ENOMEM;
 						goto error;
 					}
-					memset (mem_tmp, 0, sizeof (struct resource_node));
 					mem_tmp->type = MEM;
 					mem_tmp->busno = bus_pfmem[count]->busno;
 					mem_tmp->devfunc = bus_pfmem[count]->devfunc;
@@ -770,13 +759,12 @@ static int configure_bridge (struct pci_
 
 				debug ("len[count] in Memory is %x\n", len[count]);
 
-				bus_mem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+				bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
 				if (!bus_mem[count]) {
 					err ("out of system memory\n");
 					retval = -ENOMEM;
 					goto error;
 				}
-				memset (bus_mem[count], 0, sizeof (struct resource_node));
 				bus_mem[count]->type = MEM;
 				bus_mem[count]->busno = func->busno;
 				bus_mem[count]->devfunc = PCI_DEVFN(func->device,
@@ -841,14 +829,13 @@ static int configure_bridge (struct pci_
 		flag_io = TRUE;
 	} else {
 		debug ("it wants %x IO behind the bridge\n", amount_needed->io);
-		io = kmalloc(sizeof(*io), GFP_KERNEL);
+		io = kzalloc(sizeof(*io), GFP_KERNEL);
 		
 		if (!io) {
 			err ("out of system memory\n");
 			retval = -ENOMEM;
 			goto error;
 		}
-		memset (io, 0, sizeof (struct resource_node));
 		io->type = IO;
 		io->busno = func->busno;
 		io->devfunc = PCI_DEVFN(func->device, func->function);
@@ -865,13 +852,12 @@ static int configure_bridge (struct pci_
 		flag_mem = TRUE;
 	} else {
 		debug ("it wants %x memory behind the bridge\n", amount_needed->mem);
-		mem = kmalloc(sizeof(*mem), GFP_KERNEL);
+		mem = kzalloc(sizeof(*mem), GFP_KERNEL);
 		if (!mem) {
 			err ("out of system memory\n");
 			retval = -ENOMEM;
 			goto error;
 		}
-		memset (mem, 0, sizeof (struct resource_node));
 		mem->type = MEM;
 		mem->busno = func->busno;
 		mem->devfunc = PCI_DEVFN(func->device, func->function);
@@ -888,13 +874,12 @@ static int configure_bridge (struct pci_
 		flag_pfmem = TRUE;
 	} else {
 		debug ("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem);
-		pfmem = kmalloc(sizeof(*pfmem), GFP_KERNEL);
+		pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL);
 		if (!pfmem) {
 			err ("out of system memory\n");
 			retval = -ENOMEM;
 			goto error;
 		}
-		memset (pfmem, 0, sizeof (struct resource_node));
 		pfmem->type = PFMEM;
 		pfmem->busno = func->busno;
 		pfmem->devfunc = PCI_DEVFN(func->device, func->function);
@@ -904,13 +889,12 @@ static int configure_bridge (struct pci_
 			ibmphp_add_resource (pfmem);
 			flag_pfmem = TRUE;
 		} else {
-			mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL);
+			mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
 			if (!mem_tmp) {
 				err ("out of system memory\n");
 				retval = -ENOMEM;
 				goto error;
 			}
-			memset (mem_tmp, 0, sizeof (struct resource_node));
 			mem_tmp->type = MEM;
 			mem_tmp->busno = pfmem->busno;
 			mem_tmp->devfunc = pfmem->devfunc;
@@ -936,13 +920,12 @@ static int configure_bridge (struct pci_
 		 */
 		bus = ibmphp_find_res_bus (sec_number);
 		if (!bus) {
-			bus = kmalloc(sizeof(*bus), GFP_KERNEL);
+			bus = kzalloc(sizeof(*bus), GFP_KERNEL);
 			if (!bus) {
 				err ("out of system memory\n");
 				retval = -ENOMEM;
 				goto error;
 			}
-			memset (bus, 0, sizeof (struct bus_node));
 			bus->busno = sec_number;
 			debug ("b4 adding new bus\n");
 			rc = add_new_bus (bus, io, mem, pfmem, func->busno);
@@ -1111,10 +1094,9 @@ static struct res_needed *scan_behind_br
 	};
 	struct res_needed *amount;
 
-	amount = kmalloc(sizeof(*amount), GFP_KERNEL);
+	amount = kzalloc(sizeof(*amount), GFP_KERNEL);
 	if (amount == NULL)
 		return NULL;
-	memset (amount, 0, sizeof (struct res_needed));
 
 	ibmphp_pci_bus->number = busno;
 
@@ -1672,12 +1654,11 @@ static int add_new_bus (struct bus_node 
 		list_add (&bus->bus_list, &cur_bus->bus_list);
 	}
 	if (io) {
-		io_range = kmalloc(sizeof(*io_range), GFP_KERNEL);
+		io_range = kzalloc(sizeof(*io_range), GFP_KERNEL);
 		if (!io_range) {
 			err ("out of system memory\n");
 			return -ENOMEM;
 		}
-		memset (io_range, 0, sizeof (struct range_node));
 		io_range->start = io->start;
 		io_range->end = io->end;
 		io_range->rangeno = 1;
@@ -1685,12 +1666,11 @@ static int add_new_bus (struct bus_node 
 		bus->rangeIO = io_range;
 	}
 	if (mem) {
-		mem_range = kmalloc(sizeof(*mem_range), GFP_KERNEL);
+		mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL);
 		if (!mem_range) {
 			err ("out of system memory\n");
 			return -ENOMEM;
 		}
-		memset (mem_range, 0, sizeof (struct range_node));
 		mem_range->start = mem->start;
 		mem_range->end = mem->end;
 		mem_range->rangeno = 1;
@@ -1698,12 +1678,11 @@ static int add_new_bus (struct bus_node 
 		bus->rangeMem = mem_range;
 	}
 	if (pfmem) {
-		pfmem_range = kmalloc(sizeof(*pfmem_range), GFP_KERNEL);
+		pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL);
 		if (!pfmem_range) {	
 			err ("out of system memory\n");
 			return -ENOMEM;
 		}
-		memset (pfmem_range, 0, sizeof (struct range_node));
 		pfmem_range->start = pfmem->start;
 		pfmem_range->end = pfmem->end;
 		pfmem_range->rangeno = 1;
--- linux-2.6.16-rc4-mm2/drivers/pci/hotplug/fakephp.c.orig	2006-02-28 15:22:05.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/pci/hotplug/fakephp.c	2006-02-28 15:22:29.000000000 +0100
@@ -95,15 +95,13 @@ static int add_slot(struct pci_dev *dev)
 	struct hotplug_slot *slot;
 	int retval = -ENOMEM;
 
-	slot = kmalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
+	slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
 	if (!slot)
 		goto error;
-	memset(slot, 0, sizeof(*slot));
 
-	slot->info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
+	slot->info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
 	if (!slot->info)
 		goto error_slot;
-	memset(slot->info, 0, sizeof(struct hotplug_slot_info));
 
 	slot->info->power_status = 1;
 	slot->info->max_bus_speed = PCI_SPEED_UNKNOWN;
@@ -227,11 +225,10 @@ static void pci_rescan_bus(const struct 
 {
 	unsigned int devfn;
 	struct pci_dev *dev;
-	dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL);
+	dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL);
 	if (!dev)
 		return;
 
-	memset(dev, 0, sizeof(dev));
 	dev->bus = (struct pci_bus*)bus;
 	dev->sysdata = bus->sysdata;
 	for (devfn = 0; devfn < 0x100; devfn += 8) {



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [KJ] [Patch] kzalloc() conversion in drivers/usb/gadget
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (8 preceding siblings ...)
  2006-02-28 14:34 ` [KJ] [Patch] kzalloc() conversion in drivers/pci Eric Sesterhenn
@ 2006-02-28 21:39 ` Alexey Dobriyan
  2006-02-28 21:49 ` Jesper Juhl
                   ` (21 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Alexey Dobriyan @ 2006-02-28 21:39 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 661 bytes --]

On Mon, Feb 27, 2006 at 09:51:53PM +0100, Jesper Juhl wrote:
> On 2/27/06, Eric Sesterhenn <snakebyte@gmx.de> wrote:
> > this patch converts drivers/usb to kzalloc usage.
> > Compile tested with allyes config.
> >
> > I think there was a bug in drivers/usb/gadget/inode.c because
> > it used sizeof(*data) for the kmalloc() and sizeof(data) for
> > the memset(), since sizeof(data) just returns the size for a pointer.
> >
> I don't know this code well, but looking briefly at it I'd say your
> analysis is correct and your patch fixes that bug.

That's what kernel janitors are for. Looking above and below mostly
trivial changes, noticing suspicious things.


[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [KJ] [Patch] kzalloc() conversion in drivers/usb/gadget
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (9 preceding siblings ...)
  2006-02-28 21:39 ` [KJ] [Patch] kzalloc() conversion in drivers/usb/gadget Alexey Dobriyan
@ 2006-02-28 21:49 ` Jesper Juhl
  2006-03-01  9:00 ` [KJ] [Patch] kzalloc() conversion in drivers/char Eric Sesterhenn
                   ` (20 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Jesper Juhl @ 2006-02-28 21:49 UTC (permalink / raw)
  To: kernel-janitors

On 2/28/06, Alexey Dobriyan <adobriyan@gmail.com> wrote:
> On Mon, Feb 27, 2006 at 09:51:53PM +0100, Jesper Juhl wrote:
> > On 2/27/06, Eric Sesterhenn <snakebyte@gmx.de> wrote:
> > > this patch converts drivers/usb to kzalloc usage.
> > > Compile tested with allyes config.
> > >
> > > I think there was a bug in drivers/usb/gadget/inode.c because
> > > it used sizeof(*data) for the kmalloc() and sizeof(data) for
> > > the memset(), since sizeof(data) just returns the size for a pointer.
> > >
> > I don't know this code well, but looking briefly at it I'd say your
> > analysis is correct and your patch fixes that bug.
>
> That's what kernel janitors are for. Looking above and below mostly
> trivial changes, noticing suspicious things.
>

Yes, and that's exactely why I geve Eric some feedback when I had read
his patch. To let him know that at least one other person had looked
at the work he had done and thought it looked good.

I'm sorry, but I don't really know what the intention of your comment was...?

--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/char
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (10 preceding siblings ...)
  2006-02-28 21:49 ` Jesper Juhl
@ 2006-03-01  9:00 ` Eric Sesterhenn
  2006-03-01 23:29 ` [KJ] [Patch] kzalloc() conversion in drivers/mtd Eric Sesterhenn
                   ` (19 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-01  9:00 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 18871 bytes --]

hi,

this patch converts drivers/pci to kzalloc usage.
Compile tested with allyes config.

char/rio/rio_linux.c and char/sx.c had a ckmalloc()
function, which i removed and changed the callers
to kzalloc(). 

zft_kmalloc() in char/ftape/zftape/zftape-buffers.c
seems a bit strange to me, since it never returns, when
it cant get memory allocated. 

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc4-mm2/drivers/char/ftape/lowlevel/ftape-buffer.c.orig	2006-03-01 09:04:01.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/ftape/lowlevel/ftape-buffer.c	2006-03-01 09:04:15.000000000 +0100
@@ -74,11 +74,10 @@ static int add_one_buffer(void)
 	if (ft_nr_buffers >= FT_MAX_NR_BUFFERS) {
 		TRACE_EXIT -ENOMEM;
 	}
-	ft_buffer[ft_nr_buffers] = kmalloc(sizeof(buffer_struct), GFP_KERNEL);
+	ft_buffer[ft_nr_buffers] = kzalloc(sizeof(buffer_struct), GFP_KERNEL);
 	if (ft_buffer[ft_nr_buffers] == NULL) {
 		TRACE_EXIT -ENOMEM;
 	}
-	memset(ft_buffer[ft_nr_buffers], 0, sizeof(buffer_struct));
 	ft_buffer[ft_nr_buffers]->address = dmaalloc(FT_BUFF_SIZE);
 	if (ft_buffer[ft_nr_buffers]->address == NULL) {
 		kfree(ft_buffer[ft_nr_buffers]);
--- linux-2.6.16-rc4-mm2/drivers/char/ftape/zftape/zftape-buffers.c.orig	2006-03-01 09:04:42.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/ftape/zftape/zftape-buffers.c	2006-03-01 09:06:13.000000000 +0100
@@ -112,10 +112,9 @@ void *zft_kmalloc(size_t size)
 {
 	void *new;
 
-	while ((new = kmalloc(size, GFP_KERNEL)) == NULL) {
+	while ((new = kzalloc(size, GFP_KERNEL)) == NULL) {
 		msleep_interruptible(100);
 	}
-	memset(new, 0, size);
 	used_memory += size;
 	if (peak_memory < used_memory) {
 		peak_memory = used_memory;
--- linux-2.6.16-rc4-mm2/drivers/char/hvcs.c.orig	2006-03-01 09:06:27.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/hvcs.c	2006-03-01 09:06:50.000000000 +0100
@@ -623,13 +623,10 @@ static int __devinit hvcs_probe(
 		return -EFAULT;
 	}
 
-	hvcsd = kmalloc(sizeof(*hvcsd), GFP_KERNEL);
+	hvcsd = kzalloc(sizeof(*hvcsd), GFP_KERNEL);
 	if (!hvcsd)
 		return -ENODEV;
 
-	/* hvcsd->tty is zeroed out with the memset */
-	memset(hvcsd, 0x00, sizeof(*hvcsd));
-
 	spin_lock_init(&hvcsd->lock);
 	/* Automatically incs the refcount the first time */
 	kobject_init(&hvcsd->kobj);
--- linux-2.6.16-rc4-mm2/drivers/char/hvc_console.c.orig	2006-03-01 09:06:58.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/hvc_console.c	2006-03-01 09:07:07.000000000 +0100
@@ -744,12 +744,10 @@ struct hvc_struct __devinit *hvc_alloc(u
 	struct hvc_struct *hp;
 	int i;
 
-	hp = kmalloc(sizeof(*hp), GFP_KERNEL);
+	hp = kzalloc(sizeof(*hp), GFP_KERNEL);
 	if (!hp)
 		return ERR_PTR(-ENOMEM);
 
-	memset(hp, 0x00, sizeof(*hp));
-
 	hp->vtermno = vtermno;
 	hp->irq = irq;
 	hp->ops = ops;
--- linux-2.6.16-rc4-mm2/drivers/char/tty_io.c.orig	2006-03-01 09:07:21.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/tty_io.c	2006-03-01 09:10:01.000000000 +0100
@@ -158,12 +158,7 @@ static void release_mem(struct tty_struc
 
 static struct tty_struct *alloc_tty_struct(void)
 {
-	struct tty_struct *tty;
-
-	tty = kmalloc(sizeof(struct tty_struct), GFP_KERNEL);
-	if (tty)
-		memset(tty, 0, sizeof(struct tty_struct));
-	return tty;
+	return kzalloc(sizeof(struct tty_struct), GFP_KERNEL);
 }
 
 static void tty_buffer_free_all(struct tty_struct *);
@@ -1506,11 +1501,9 @@ static int init_dev(struct tty_driver *d
 	}
 
 	if (!*ltp_loc) {
-		ltp = (struct termios *) kmalloc(sizeof(struct termios),
-						 GFP_KERNEL);
+		ltp = kzalloc(sizeof(struct termios), GFP_KERNEL);
 		if (!ltp)
 			goto free_mem_out;
-		memset(ltp, 0, sizeof(struct termios));
 	}
 
 	if (driver->type == TTY_DRIVER_TYPE_PTY) {
@@ -1539,11 +1532,9 @@ static int init_dev(struct tty_driver *d
 		}
 
 		if (!*o_ltp_loc) {
-			o_ltp = (struct termios *)
-				kmalloc(sizeof(struct termios), GFP_KERNEL);
+			o_ltp = kzalloc(sizeof(struct termios), GFP_KERNEL);
 			if (!o_ltp)
 				goto free_mem_out;
-			memset(o_ltp, 0, sizeof(struct termios));
 		}
 
 		/*
@@ -2997,9 +2988,8 @@ struct tty_driver *alloc_tty_driver(int 
 {
 	struct tty_driver *driver;
 
-	driver = kmalloc(sizeof(struct tty_driver), GFP_KERNEL);
+	driver = kzalloc(sizeof(struct tty_driver), GFP_KERNEL);
 	if (driver) {
-		memset(driver, 0, sizeof(struct tty_driver));
 		driver->magic = TTY_DRIVER_MAGIC;
 		driver->num = lines;
 		/* later we'll move allocation of tables here */
@@ -3058,10 +3048,9 @@ int tty_register_driver(struct tty_drive
 		return 0;
 
 	if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM)) {
-		p = kmalloc(driver->num * 3 * sizeof(void *), GFP_KERNEL);
+		p = kcalloc(driver->num, 3 * sizeof(void *), GFP_KERNEL);
 		if (!p)
 			return -ENOMEM;
-		memset(p, 0, driver->num * 3 * sizeof(void *));
 	}
 
 	if (!driver->major) {
--- linux-2.6.16-rc4-mm2/drivers/char/ipmi/ipmi_si_intf.c.orig	2006-03-01 09:10:14.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/ipmi/ipmi_si_intf.c	2006-03-01 09:10:55.000000000 +0100
@@ -1242,12 +1242,11 @@ static int try_init_port(int intf_num, s
 			      ports[intf_num]))
 		return -ENODEV;
 
-	info = kmalloc(sizeof(*info), GFP_KERNEL);
+	info = kzalloc(sizeof(*info), GFP_KERNEL);
 	if (! info) {
 		printk(KERN_ERR "ipmi_si: Could not allocate SI data (1)\n");
 		return -ENOMEM;
 	}
-	memset(info, 0, sizeof(*info));
 
 	info->io_setup = port_setup;
 	info->io.info = &(ports[intf_num]);
@@ -1403,12 +1402,11 @@ static int try_init_mem(int intf_num, st
 			      addrs[intf_num]))
 		return -ENODEV;
 
-	info = kmalloc(sizeof(*info), GFP_KERNEL);
+	info = kzalloc(sizeof(*info), GFP_KERNEL);
 	if (! info) {
 		printk(KERN_ERR "ipmi_si: Could not allocate SI data (2)\n");
 		return -ENOMEM;
 	}
-	memset(info, 0, sizeof(*info));
 
 	info->io_setup = mem_setup;
 	info->io.info = &addrs[intf_num];
@@ -1602,12 +1600,11 @@ static int try_init_acpi(int intf_num, s
 		return -EIO;
 	}
 
-	info = kmalloc(sizeof(*info), GFP_KERNEL);
+	info = kzalloc(sizeof(*info), GFP_KERNEL);
 	if (! info) {
 		printk(KERN_ERR "ipmi_si: Could not allocate SI data (3)\n");
 		return -ENOMEM;
 	}
-	memset(info, 0, sizeof(*info));
 
 	if (spmi->InterruptType & 1) {
 		/* We've got a GPE interrupt. */
@@ -1780,12 +1777,11 @@ static int try_init_smbios(int intf_num,
 			return -EIO;
 	}
 
-	info = kmalloc(sizeof(*info), GFP_KERNEL);
+	info = kzalloc(sizeof(*info), GFP_KERNEL);
 	if (! info) {
 		printk(KERN_ERR "ipmi_si: Could not allocate SI data (4)\n");
 		return -ENOMEM;
 	}
-	memset(info, 0, sizeof(*info));
 
 	if (ipmi_data->addr_space == 1) {
 		io_type = "memory";
@@ -1886,13 +1882,12 @@ static int find_pci_smic(int intf_num, s
 		return -ENODEV;
 	}
 
-	info = kmalloc(sizeof(*info), GFP_KERNEL);
+	info = kzalloc(sizeof(*info), GFP_KERNEL);
 	if (! info) {
 		pci_dev_put(pci_dev);
 		printk(KERN_ERR "ipmi_si: Could not allocate SI data (5)\n");
 		return -ENOMEM;
 	}
-	memset(info, 0, sizeof(*info));
 
 	info->io_setup = port_setup;
 	ports[intf_num] = base_addr;
--- linux-2.6.16-rc4-mm2/drivers/char/ipmi/ipmi_msghandler.c.orig	2006-03-01 09:11:05.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/ipmi/ipmi_msghandler.c	2006-03-01 09:11:14.000000000 +0100
@@ -1825,10 +1825,9 @@ int ipmi_register_smi(struct ipmi_smi_ha
 			return -ENODEV;
 	}
 
-	intf = kmalloc(sizeof(*intf), GFP_KERNEL);
+	intf = kzalloc(sizeof(*intf), GFP_KERNEL);
 	if (!intf)
 		return -ENOMEM;
-	memset(intf, 0, sizeof(*intf));
 	intf->intf_num = -1;
 	kref_init(&intf->refcount);
 	intf->version_major = version_major;
--- linux-2.6.16-rc4-mm2/drivers/char/amiserial.c.orig	2006-03-01 09:11:25.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/amiserial.c	2006-03-01 09:11:38.000000000 +0100
@@ -1742,12 +1742,11 @@ static int get_async_struct(int line, st
 		*ret_info = sstate->info;
 		return 0;
 	}
-	info = kmalloc(sizeof(struct async_struct), GFP_KERNEL);
+	info = kzalloc(sizeof(struct async_struct), GFP_KERNEL);
 	if (!info) {
 		sstate->count--;
 		return -ENOMEM;
 	}
-	memset(info, 0, sizeof(struct async_struct));
 #ifdef DECLARE_WAITQUEUE
 	init_waitqueue_head(&info->open_wait);
 	init_waitqueue_head(&info->close_wait);
--- linux-2.6.16-rc4-mm2/drivers/char/random.c.orig	2006-03-01 09:11:45.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/random.c	2006-03-01 09:13:21.000000000 +0100
@@ -912,11 +912,9 @@ void rand_initialize_irq(int irq)
 	 * If kmalloc returns null, we just won't use that entropy
 	 * source.
 	 */
-	state = kmalloc(sizeof(struct timer_rand_state), GFP_KERNEL);
-	if (state) {
-		memset(state, 0, sizeof(struct timer_rand_state));
+	state = kzalloc(sizeof(struct timer_rand_state), GFP_KERNEL);
+	if (state)
 		irq_timer_state[irq] = state;
-	}
 }
 
 void rand_initialize_disk(struct gendisk *disk)
@@ -927,11 +925,9 @@ void rand_initialize_disk(struct gendisk
 	 * If kmalloc returns null, we just won't use that entropy
 	 * source.
 	 */
-	state = kmalloc(sizeof(struct timer_rand_state), GFP_KERNEL);
-	if (state) {
-		memset(state, 0, sizeof(struct timer_rand_state));
+	state = kzalloc(sizeof(struct timer_rand_state), GFP_KERNEL);
+	if (state)
 		disk->random = state;
-	}
 }
 
 static ssize_t
--- linux-2.6.16-rc4-mm2/drivers/char/consolemap.c.orig	2006-03-01 09:13:30.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/consolemap.c	2006-03-01 09:14:41.000000000 +0100
@@ -193,11 +193,10 @@ static void set_inverse_transl(struct vc
 	q = p->inverse_translations[i];
 
 	if (!q) {
-		q = p->inverse_translations[i] = (unsigned char *) 
-			kmalloc(MAX_GLYPH, GFP_KERNEL);
+		q = p->inverse_translations[i] =
+			kzalloc(MAX_GLYPH, GFP_KERNEL);
 		if (!q) return;
 	}
-	memset(q, 0, MAX_GLYPH);
 
 	for (j = 0; j < E_TABSZ; j++) {
 		glyph = conv_uni_to_pc(conp, t[j]);
@@ -444,12 +443,11 @@ int con_clear_unimap(struct vc_data *vc,
 	p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
 	if (p && p->readonly) return -EIO;
 	if (!p || --p->refcount) {
-		q = (struct uni_pagedir *)kmalloc(sizeof(*p), GFP_KERNEL);
+		q = kzalloc(sizeof(*p), GFP_KERNEL);
 		if (!q) {
 			if (p) p->refcount++;
 			return -ENOMEM;
 		}
-		memset(q, 0, sizeof(*q));
 		q->refcount=1;
 		*vc->vc_uni_pagedir_loc = (unsigned long)q;
 	} else {
--- linux-2.6.16-rc4-mm2/drivers/char/rio/rio_linux.c.orig	2006-03-01 09:54:52.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/rio/rio_linux.c	2006-03-01 09:55:53.000000000 +0100
@@ -844,19 +844,6 @@ static int rio_init_drivers(void)
 	return 1;
 }
 
-
-static void *ckmalloc(int size)
-{
-	void *p;
-
-	p = kmalloc(size, GFP_KERNEL);
-	if (p)
-		memset(p, 0, size);
-	return p;
-}
-
-
-
 static int rio_init_datastructures(void)
 {
 	int i;
@@ -875,18 +862,18 @@ static int rio_init_datastructures(void)
 #define TMIO_SZ sizeof(struct termios *)
 	rio_dprintk(RIO_DEBUG_INIT, "getting : %d %d %d %d %d bytes\n", RI_SZ, RIO_HOSTS * HOST_SZ, RIO_PORTS * PORT_SZ, RIO_PORTS * TMIO_SZ, RIO_PORTS * TMIO_SZ);
 
-	if (!(p = ckmalloc(RI_SZ)))
+	if (!(p = kzalloc(RI_SZ, GFP_KERNEL)))
 		goto free0;
-	if (!(p->RIOHosts = ckmalloc(RIO_HOSTS * HOST_SZ)))
+	if (!(p->RIOHosts = kzalloc(RIO_HOSTS * HOST_SZ, GFP_KERNEL)))
 		goto free1;
-	if (!(p->RIOPortp = ckmalloc(RIO_PORTS * PORT_SZ)))
+	if (!(p->RIOPortp = kzalloc(RIO_PORTS * PORT_SZ, GFP_KERNEL)))
 		goto free2;
 	p->RIOConf = RIOConf;
 	rio_dprintk(RIO_DEBUG_INIT, "Got : %p %p %p\n", p, p->RIOHosts, p->RIOPortp);
 
 #if 1
 	for (i = 0; i < RIO_PORTS; i++) {
-		port = p->RIOPortp[i] = ckmalloc(sizeof(struct Port));
+		port = p->RIOPortp[i] = kzalloc(sizeof(struct Port), GFP_KERNEL);
 		if (!port) {
 			goto free6;
 		}
--- linux-2.6.16-rc4-mm2/drivers/char/watchdog/pcwd_usb.c.orig	2006-03-01 09:17:03.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/watchdog/pcwd_usb.c	2006-03-01 09:17:34.000000000 +0100
@@ -597,12 +597,11 @@ static int usb_pcwd_probe(struct usb_int
 	maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
 
 	/* allocate memory for our device and initialize it */
-	usb_pcwd = kmalloc (sizeof(struct usb_pcwd_private), GFP_KERNEL);
+	usb_pcwd = kzalloc(sizeof(struct usb_pcwd_private), GFP_KERNEL);
 	if (usb_pcwd == NULL) {
 		printk(KERN_ERR PFX "Out of memory\n");
 		goto error;
 	}
-	memset (usb_pcwd, 0x00, sizeof (*usb_pcwd));
 
 	usb_pcwd_device = usb_pcwd;
 
--- linux-2.6.16-rc4-mm2/drivers/char/watchdog/mpcore_wdt.c.orig	2006-03-01 09:17:46.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/watchdog/mpcore_wdt.c	2006-03-01 09:17:55.000000000 +0100
@@ -329,12 +329,11 @@ static int __devinit mpcore_wdt_probe(st
 		goto err_out;
 	}
 
-	wdt = kmalloc(sizeof(struct mpcore_wdt), GFP_KERNEL);
+	wdt = kzalloc(sizeof(struct mpcore_wdt), GFP_KERNEL);
 	if (!wdt) {
 		ret = -ENOMEM;
 		goto err_out;
 	}
-	memset(wdt, 0, sizeof(struct mpcore_wdt));
 
 	wdt->dev = &dev->dev;
 	wdt->irq = platform_get_irq(dev, 0);
--- linux-2.6.16-rc4-mm2/drivers/char/rocket.c.orig	2006-03-01 09:18:04.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/rocket.c	2006-03-01 09:18:27.000000000 +0100
@@ -654,12 +654,11 @@ static void init_r_port(int board, int a
 	ctlp = sCtlNumToCtlPtr(board);
 
 	/*  Get a r_port struct for the port, fill it in and save it globally, indexed by line number */
-	info = kmalloc(sizeof (struct r_port), GFP_KERNEL);
+	info = kzalloc(sizeof(struct r_port), GFP_KERNEL);
 	if (!info) {
 		printk(KERN_INFO "Couldn't allocate info struct for line #%d\n", line);
 		return;
 	}
-	memset(info, 0, sizeof (struct r_port));
 
 	info->magic = RPORT_MAGIC;
 	info->line = line;
--- linux-2.6.16-rc4-mm2/drivers/char/n_hdlc.c.orig	2006-03-01 09:18:41.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/n_hdlc.c	2006-03-01 09:18:55.000000000 +0100
@@ -802,13 +802,11 @@ static struct n_hdlc *n_hdlc_alloc(void)
 {
 	struct n_hdlc_buf *buf;
 	int i;
-	struct n_hdlc *n_hdlc = kmalloc(sizeof(*n_hdlc), GFP_KERNEL);
+	struct n_hdlc *n_hdlc = kzalloc(sizeof(*n_hdlc), GFP_KERNEL);
 
 	if (!n_hdlc)
 		return NULL;
 
-	memset(n_hdlc, 0, sizeof(*n_hdlc));
-
 	n_hdlc_buf_list_init(&n_hdlc->rx_free_buf_list);
 	n_hdlc_buf_list_init(&n_hdlc->tx_free_buf_list);
 	n_hdlc_buf_list_init(&n_hdlc->rx_buf_list);
--- linux-2.6.16-rc4-mm2/drivers/char/keyboard.c.orig	2006-03-01 09:19:17.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/keyboard.c	2006-03-01 09:19:29.000000000 +0100
@@ -1193,9 +1193,8 @@ static struct input_handle *kbd_connect(
 	if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit))
 		return NULL;
 
-	if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL)))
+	if (!(handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL)))
 		return NULL;
-	memset(handle, 0, sizeof(struct input_handle));
 
 	handle->dev = dev;
 	handle->handler = handler;
--- linux-2.6.16-rc4-mm2/drivers/char/ip2main.c.orig	2006-03-01 09:19:40.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/ip2main.c	2006-03-01 09:19:58.000000000 +0100
@@ -648,10 +648,9 @@ ip2_loadmain(int *iop, int *irqp, unsign
 	}	/* for */
 	for ( i = 0; i < IP2_MAX_BOARDS; ++i ) {
 		if ( ip2config.addr[i] ) {
-			pB = kmalloc( sizeof(i2eBordStr), GFP_KERNEL);
+			pB = kzalloc(sizeof(i2eBordStr), GFP_KERNEL);
 			if ( pB != NULL ) {
 				i2BoardPtrTable[i] = pB;
-				memset( pB, 0, sizeof(i2eBordStr) );
 				iiSetAddress( pB, ip2config.addr[i], ii2DelayTimer );
 				iiReset( pB );
 			} else {
--- linux-2.6.16-rc4-mm2/drivers/char/vt.c.orig	2006-03-01 09:20:07.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/vt.c	2006-03-01 09:20:21.000000000 +0100
@@ -709,10 +709,9 @@ int vc_allocate(unsigned int currcons)	/
 	    /* although the numbers above are not valid since long ago, the
 	       point is still up-to-date and the comment still has its value
 	       even if only as a historical artifact.  --mj, July 1998 */
-	    vc = kmalloc(sizeof(struct vc_data), GFP_KERNEL);
+	    vc = kzalloc(sizeof(struct vc_data), GFP_KERNEL);
 	    if (!vc)
 		return -ENOMEM;
-	    memset(vc, 0, sizeof(*vc));
 	    vc_cons[currcons].d = vc;
 	    visual_init(vc, currcons, 1);
 	    if (!*vc->vc_uni_pagedir_loc)
--- linux-2.6.16-rc4-mm2/drivers/char/sx.c.orig	2006-03-01 09:20:28.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/sx.c	2006-03-01 09:21:57.000000000 +0100
@@ -2274,18 +2274,6 @@ static int sx_init_drivers(void)
 	return 0;
 }
 
-
-static void * ckmalloc (int size)
-{
-	void *p;
-
-	p = kmalloc(size, GFP_KERNEL);
-	if (p) 
-		memset(p, 0, size);
-	return p;
-}
-
-
 static int sx_init_portstructs (int nboards, int nports)
 {
 	struct sx_board *board;
@@ -2298,7 +2286,7 @@ static int sx_init_portstructs (int nboa
 
 	/* Many drivers statically allocate the maximum number of ports
 	   There is no reason not to allocate them dynamically. Is there? -- REW */
-	sx_ports          = ckmalloc(nports * sizeof (struct sx_port));
+	sx_ports          = kcalloc(nports, sizeof(struct sx_port), GFP_KERNEL);
 	if (!sx_ports)
 		return -ENOMEM;
 
--- linux-2.6.16-rc4-mm2/drivers/char/synclink.c.orig	2006-03-01 09:22:09.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/synclink.c	2006-03-01 09:22:48.000000000 +0100
@@ -4352,13 +4352,11 @@ static struct mgsl_struct* mgsl_allocate
 {
 	struct mgsl_struct *info;
 	
-	info = (struct mgsl_struct *)kmalloc(sizeof(struct mgsl_struct),
-		 GFP_KERNEL);
+	info = kzalloc(sizeof(struct mgsl_struct), GFP_KERNEL);
 		 
 	if (!info) {
 		printk("Error can't allocate device instance data\n");
 	} else {
-		memset(info, 0, sizeof(struct mgsl_struct));
 		info->magic = MGSL_MAGIC;
 		INIT_WORK(&info->task, mgsl_bh_handler, info);
 		info->max_frame_size = 4096;
--- linux-2.6.16-rc4-mm2/drivers/char/drm/ffb_drv.c.orig	2006-03-01 09:23:02.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/drm/ffb_drv.c	2006-03-01 09:23:14.000000000 +0100
@@ -219,10 +219,9 @@ static int ffb_presetup(drm_device_t * d
 		return -ENODEV;
 
 	/* code used to use numdevs no numdevs anymore */
-	ffb_priv = kmalloc(sizeof(ffb_dev_priv_t), GFP_KERNEL);
+	ffb_priv = kzalloc(sizeof(ffb_dev_priv_t), GFP_KERNEL);
 	if (!ffb_priv)
 		return -ENOMEM;
-	memset(ffb_priv, 0, sizeof(*ffb_priv));
 	dev->dev_private = ffb_priv;
 
 	ret = ffb_init_one(dev, ffb_position[i].node, ffb_position[i].root, i);
--- linux-2.6.16-rc4-mm2/drivers/char/drm/via_dmablit.c.orig	2006-03-01 09:23:33.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/char/drm/via_dmablit.c	2006-03-01 09:24:35.000000000 +0100
@@ -268,10 +268,10 @@ via_alloc_desc_pages(drm_via_sg_info_t *
 	vsg->num_desc_pages = (vsg->num_desc + vsg->descriptors_per_page - 1) / 
 		vsg->descriptors_per_page;
 
-	if (NULL ==  (vsg->desc_pages = kmalloc(sizeof(void *) * vsg->num_desc_pages, GFP_KERNEL))) 
+	if (NULL ==  (vsg->desc_pages = kcalloc(vsg->num_desc_pages,
+					sizeof(void *), GFP_KERNEL))) 
 		return DRM_ERR(ENOMEM);
 	
-	memset(vsg->desc_pages, 0, sizeof(void *) * vsg->num_desc_pages);
 	vsg->state = dr_via_desc_pages_alloc;
 	for (i=0; i<vsg->num_desc_pages; ++i) {
 		if (NULL == (vsg->desc_pages[i] = 



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/mtd
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (11 preceding siblings ...)
  2006-03-01  9:00 ` [KJ] [Patch] kzalloc() conversion in drivers/char Eric Sesterhenn
@ 2006-03-01 23:29 ` Eric Sesterhenn
  2006-03-02 11:58 ` [KJ] [Patch] kzalloc() conversion in drivers/serial Eric Sesterhenn
                   ` (18 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-01 23:29 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 16343 bytes --]

hi,

this patch converts drivers/mtd to kzalloc usage.
Compile tested with allyes config.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc4-mm2/drivers/mtd/onenand/generic.c.orig	2006-02-28 18:55:50.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/onenand/generic.c	2006-02-28 18:56:00.000000000 +0100
@@ -45,12 +45,10 @@ static int __devinit generic_onenand_pro
 	unsigned long size = res->end - res->start + 1;
 	int err;
 
-	info = kmalloc(sizeof(struct onenand_info), GFP_KERNEL);
+	info = kzalloc(sizeof(struct onenand_info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
 
-	memset(info, 0, sizeof(struct onenand_info));
-
 	if (!request_mem_region(res->start, size, dev->driver->name)) {
 		err = -EBUSY;
 		goto out_free_info;
--- linux-2.6.16-rc4-mm2/drivers/mtd/mtdblock_ro.c.orig	2006-02-28 18:56:12.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/mtdblock_ro.c	2006-02-28 18:56:26.000000000 +0100
@@ -33,13 +33,11 @@ static int mtdblock_writesect(struct mtd
 
 static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 {
-	struct mtd_blktrans_dev *dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+	struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 
 	if (!dev)
 		return;
 
-	memset(dev, 0, sizeof(*dev));
-
 	dev->mtd = mtd;
 	dev->devnum = mtd->index;
 	dev->blksize = 512;
--- linux-2.6.16-rc4-mm2/drivers/mtd/mtdblock.c.orig	2006-02-28 18:56:30.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/mtdblock.c	2006-02-28 18:56:49.000000000 +0100
@@ -278,11 +278,10 @@ static int mtdblock_open(struct mtd_blkt
 	}
 
 	/* OK, it's not open. Create cache info for it */
-	mtdblk = kmalloc(sizeof(struct mtdblk_dev), GFP_KERNEL);
+	mtdblk = kzalloc(sizeof(struct mtdblk_dev), GFP_KERNEL);
 	if (!mtdblk)
 		return -ENOMEM;
 
-	memset(mtdblk, 0, sizeof(*mtdblk));
 	mtdblk->count = 1;
 	mtdblk->mtd = mtd;
 
@@ -340,13 +339,11 @@ static int mtdblock_flush(struct mtd_blk
 
 static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 {
-	struct mtd_blktrans_dev *dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+	struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 
 	if (!dev)
 		return;
 
-	memset(dev, 0, sizeof(*dev));
-
 	dev->mtd = mtd;
 	dev->devnum = mtd->index;
 	dev->blksize = 512;
--- linux-2.6.16-rc4-mm2/drivers/mtd/chips/cfi_cmdset_0002.c.orig	2006-02-28 18:57:04.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/chips/cfi_cmdset_0002.c	2006-02-28 18:57:15.000000000 +0100
@@ -218,12 +218,11 @@ struct mtd_info *cfi_cmdset_0002(struct 
 	struct mtd_info *mtd;
 	int i;
 
-	mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+	mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
 	if (!mtd) {
 		printk(KERN_WARNING "Failed to allocate memory for MTD device\n");
 		return NULL;
 	}
-	memset(mtd, 0, sizeof(*mtd));
 	mtd->priv = map;
 	mtd->type = MTD_NORFLASH;
 
--- linux-2.6.16-rc4-mm2/drivers/mtd/chips/amd_flash.c.orig	2006-02-28 18:57:25.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/chips/amd_flash.c	2006-02-28 18:57:43.000000000 +0100
@@ -650,13 +650,12 @@ static struct mtd_info *amd_flash_probe(
 	int reg_idx;
 	int offset;
 
-	mtd = (struct mtd_info*)kmalloc(sizeof(*mtd), GFP_KERNEL);
+	mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
 	if (!mtd) {
 		printk(KERN_WARNING
 		       "%s: kmalloc failed for info structure\n", map->name);
 		return NULL;
 	}
-	memset(mtd, 0, sizeof(*mtd));
 	mtd->priv = map;
 
 	memset(&temp, 0, sizeof(temp));
--- linux-2.6.16-rc4-mm2/drivers/mtd/chips/jedec.c.orig	2006-02-28 18:57:53.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/chips/jedec.c	2006-02-28 18:58:15.000000000 +0100
@@ -116,11 +116,10 @@ static struct mtd_info *jedec_probe(stru
    char Part[200];
    memset(&priv,0,sizeof(priv));
 
-   MTD = kmalloc(sizeof(struct mtd_info) + sizeof(struct jedec_private), GFP_KERNEL);
+   MTD = kzalloc(sizeof(struct mtd_info) + sizeof(struct jedec_private), GFP_KERNEL);
    if (!MTD)
 	   return NULL;
 
-   memset(MTD, 0, sizeof(struct mtd_info) + sizeof(struct jedec_private));
    priv = (struct jedec_private *)&MTD[1];
 
    my_bank_size = map->size;
--- linux-2.6.16-rc4-mm2/drivers/mtd/chips/cfi_cmdset_0001.c.orig	2006-02-28 18:58:31.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/chips/cfi_cmdset_0001.c	2006-02-28 18:58:40.000000000 +0100
@@ -344,12 +344,11 @@ struct mtd_info *cfi_cmdset_0001(struct 
 	struct mtd_info *mtd;
 	int i;
 
-	mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+	mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
 	if (!mtd) {
 		printk(KERN_ERR "Failed to allocate memory for MTD device\n");
 		return NULL;
 	}
-	memset(mtd, 0, sizeof(*mtd));
 	mtd->priv = map;
 	mtd->type = MTD_NORFLASH;
 
--- linux-2.6.16-rc4-mm2/drivers/mtd/chips/gen_probe.c.orig	2006-02-28 18:59:31.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/chips/gen_probe.c	2006-02-28 18:59:52.000000000 +0100
@@ -101,13 +101,12 @@ static struct cfi_private *genprobe_iden
 	 */
 	max_chips = map->size >> cfi.chipshift;
 	mapsize = (max_chips / 8) + ((max_chips % 8) ? 1 : 0);
-	chip_map = kmalloc(mapsize, GFP_KERNEL);
+	chip_map = kzalloc(mapsize, GFP_KERNEL);
 	if (!chip_map) {
 		printk(KERN_WARNING "%s: kmalloc failed for CFI chip map\n", map->name);
 		kfree(cfi.cfiq);
 		return NULL;
 	}
-	memset (chip_map, 0, mapsize);
 
 	set_bit(0, chip_map); /* Mark first chip valid */
 
--- linux-2.6.16-rc4-mm2/drivers/mtd/chips/map_ram.c.orig	2006-02-28 19:00:03.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/chips/map_ram.c	2006-02-28 19:00:14.000000000 +0100
@@ -55,12 +55,10 @@ static struct mtd_info *map_ram_probe(st
 #endif
 	/* OK. It seems to be RAM. */
 
-	mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+	mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
 	if (!mtd)
 		return NULL;
 
-	memset(mtd, 0, sizeof(*mtd));
-
 	map->fldrv = &mapram_chipdrv;
 	mtd->priv = map;
 	mtd->name = map->name;
--- linux-2.6.16-rc4-mm2/drivers/mtd/chips/map_rom.c.orig	2006-02-28 19:00:44.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/chips/map_rom.c	2006-02-28 19:00:51.000000000 +0100
@@ -31,12 +31,10 @@ static struct mtd_info *map_rom_probe(st
 {
 	struct mtd_info *mtd;
 
-	mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+	mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
 	if (!mtd)
 		return NULL;
 
-	memset(mtd, 0, sizeof(*mtd));
-
 	map->fldrv = &maprom_chipdrv;
 	mtd->priv = map;
 	mtd->name = map->name;
--- linux-2.6.16-rc4-mm2/drivers/mtd/mtd_blkdevs.c.orig	2006-02-28 19:01:03.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/mtd_blkdevs.c	2006-02-28 19:01:16.000000000 +0100
@@ -372,12 +372,10 @@ int register_mtd_blktrans(struct mtd_blk
 	if (!blktrans_notifier.list.next)
 		register_mtd_user(&blktrans_notifier);
 
-	tr->blkcore_priv = kmalloc(sizeof(*tr->blkcore_priv), GFP_KERNEL);
+	tr->blkcore_priv = kzalloc(sizeof(*tr->blkcore_priv), GFP_KERNEL);
 	if (!tr->blkcore_priv)
 		return -ENOMEM;
 
-	memset(tr->blkcore_priv, 0, sizeof(*tr->blkcore_priv));
-
 	mutex_lock(&mtd_table_mutex);
 
 	ret = register_blkdev(tr->major, tr->name);
--- linux-2.6.16-rc4-mm2/drivers/mtd/afs.c.orig	2006-02-28 19:01:23.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/afs.c	2006-02-28 19:01:38.000000000 +0100
@@ -207,11 +207,10 @@ static int parse_afs_partitions(struct m
 	if (!sz)
 		return ret;
 
-	parts = kmalloc(sz, GFP_KERNEL);
+	parts = kzalloc(sz, GFP_KERNEL);
 	if (!parts)
 		return -ENOMEM;
 
-	memset(parts, 0, sz);
 	str = (char *)(parts + idx);
 
 	/*
--- linux-2.6.16-rc4-mm2/drivers/mtd/devices/pmc551.c.orig	2006-02-28 19:01:47.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/devices/pmc551.c	2006-02-28 19:02:16.000000000 +0100
@@ -712,21 +712,18 @@ static int __init init_pmc551(void)
 			msize = length;
 		}
 
-                mtd = kmalloc(sizeof(struct mtd_info), GFP_KERNEL);
+                mtd = kzalloc(sizeof(struct mtd_info), GFP_KERNEL);
                 if (!mtd) {
                         printk(KERN_NOTICE "pmc551: Cannot allocate new MTD device.\n");
                         break;
                 }
 
-                memset(mtd, 0, sizeof(struct mtd_info));
-
-                priv = kmalloc (sizeof(struct mypriv), GFP_KERNEL);
+                priv = kzalloc (sizeof(struct mypriv), GFP_KERNEL);
                 if (!priv) {
                         printk(KERN_NOTICE "pmc551: Cannot allocate new MTD device.\n");
                         kfree(mtd);
                         break;
                 }
-                memset(priv, 0, sizeof(*priv));
                 mtd->priv = priv;
                 priv->dev = PCI_Device;
 
--- linux-2.6.16-rc4-mm2/drivers/mtd/devices/phram.c.orig	2006-02-28 19:02:25.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/devices/phram.c	2006-02-28 19:02:37.000000000 +0100
@@ -126,12 +126,10 @@ static int register_device(char *name, u
 	struct phram_mtd_list *new;
 	int ret = -ENOMEM;
 
-	new = kmalloc(sizeof(*new), GFP_KERNEL);
+	new = kzalloc(sizeof(*new), GFP_KERNEL);
 	if (!new)
 		goto out0;
 
-	memset(new, 0, sizeof(*new));
-
 	ret = -EIO;
 	new->mtd.priv = ioremap(start, len);
 	if (!new->mtd.priv) {
--- linux-2.6.16-rc4-mm2/drivers/mtd/devices/ms02-nv.c.orig	2006-02-28 19:02:45.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/devices/ms02-nv.c	2006-02-28 19:03:31.000000000 +0100
@@ -131,11 +131,10 @@ static int __init ms02nv_init_one(ulong 
 	int ret = -ENODEV;
 
 	/* The module decodes 8MiB of address space. */
-	mod_res = kmalloc(sizeof(*mod_res), GFP_KERNEL);
+	mod_res = kzalloc(sizeof(*mod_res), GFP_KERNEL);
 	if (!mod_res)
 		return -ENOMEM;
 
-	memset(mod_res, 0, sizeof(*mod_res));
 	mod_res->name = ms02nv_name;
 	mod_res->start = addr;
 	mod_res->end = addr + MS02NV_SLOT_SIZE - 1;
@@ -153,24 +152,21 @@ static int __init ms02nv_init_one(ulong 
 	}
 
 	ret = -ENOMEM;
-	mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+	mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
 	if (!mtd)
 		goto err_out_mod_res_rel;
-	memset(mtd, 0, sizeof(*mtd));
-	mp = kmalloc(sizeof(*mp), GFP_KERNEL);
+	mp = kzalloc(sizeof(*mp), GFP_KERNEL);
 	if (!mp)
 		goto err_out_mtd;
-	memset(mp, 0, sizeof(*mp));
 
 	mtd->priv = mp;
 	mp->resource.module = mod_res;
 
 	/* Firmware's diagnostic NVRAM area. */
-	diag_res = kmalloc(sizeof(*diag_res), GFP_KERNEL);
+	diag_res = kzalloc(sizeof(*diag_res), GFP_KERNEL);
 	if (!diag_res)
 		goto err_out_mp;
 
-	memset(diag_res, 0, sizeof(*diag_res));
 	diag_res->name = ms02nv_res_diag_ram;
 	diag_res->start = addr;
 	diag_res->end = addr + MS02NV_RAM - 1;
@@ -180,11 +176,10 @@ static int __init ms02nv_init_one(ulong 
 	mp->resource.diag_ram = diag_res;
 
 	/* User-available general-purpose NVRAM area. */
-	user_res = kmalloc(sizeof(*user_res), GFP_KERNEL);
+	user_res = kzalloc(sizeof(*user_res), GFP_KERNEL);
 	if (!user_res)
 		goto err_out_diag_res;
 
-	memset(user_res, 0, sizeof(*user_res));
 	user_res->name = ms02nv_res_user_ram;
 	user_res->start = addr + MS02NV_RAM;
 	user_res->end = addr + size - 1;
@@ -194,11 +189,10 @@ static int __init ms02nv_init_one(ulong 
 	mp->resource.user_ram = user_res;
 
 	/* Control and status register. */
-	csr_res = kmalloc(sizeof(*csr_res), GFP_KERNEL);
+	csr_res = kzalloc(sizeof(*csr_res), GFP_KERNEL);
 	if (!csr_res)
 		goto err_out_user_res;
 
-	memset(csr_res, 0, sizeof(*csr_res));
 	csr_res->name = ms02nv_res_csr;
 	csr_res->start = addr + MS02NV_CSR;
 	csr_res->end = addr + MS02NV_CSR + 3;
--- linux-2.6.16-rc4-mm2/drivers/mtd/devices/block2mtd.c.orig	2006-02-28 19:03:44.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/devices/block2mtd.c	2006-02-28 19:04:13.000000000 +0100
@@ -293,10 +293,9 @@ static struct block2mtd_dev *add_device(
 	if (!devname)
 		return NULL;
 
-	dev = kmalloc(sizeof(struct block2mtd_dev), GFP_KERNEL);
+	dev = kzalloc(sizeof(struct block2mtd_dev), GFP_KERNEL);
 	if (!dev)
 		return NULL;
-	memset(dev, 0, sizeof(*dev));
 
 	/* Get a handle on the device */
 	bdev = open_bdev_excl(devname, O_RDWR, NULL);
--- linux-2.6.16-rc4-mm2/drivers/mtd/devices/slram.c.orig	2006-02-28 19:04:23.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/devices/slram.c	2006-02-28 19:05:13.000000000 +0100
@@ -168,19 +168,16 @@ static int register_device(char *name, u
 		E("slram: Cannot allocate new MTD device.\n");
 		return(-ENOMEM);
 	}
-	(*curmtd)->mtdinfo = kmalloc(sizeof(struct mtd_info), GFP_KERNEL);
+	(*curmtd)->mtdinfo = kzalloc(sizeof(struct mtd_info), GFP_KERNEL);
 	(*curmtd)->next = NULL;
 
 	if ((*curmtd)->mtdinfo)	{
-		memset((char *)(*curmtd)->mtdinfo, 0, sizeof(struct mtd_info));
 		(*curmtd)->mtdinfo->priv =
-			kmalloc(sizeof(slram_priv_t), GFP_KERNEL);
+			kzalloc(sizeof(slram_priv_t), GFP_KERNEL);
 
 		if (!(*curmtd)->mtdinfo->priv) {
 			kfree((*curmtd)->mtdinfo);
 			(*curmtd)->mtdinfo = NULL;
-		} else {
-			memset((*curmtd)->mtdinfo->priv,0,sizeof(slram_priv_t));
 		}
 	}
 
--- linux-2.6.16-rc4-mm2/drivers/mtd/maps/ceiva.c.orig	2006-02-28 19:05:31.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/maps/ceiva.c	2006-02-28 19:05:48.000000000 +0100
@@ -123,10 +123,9 @@ static int __init clps_setup_mtd(struct 
 	/*
 	 * Allocate the map_info structs in one go.
 	 */
-	maps = kmalloc(sizeof(struct map_info) * nr, GFP_KERNEL);
+	maps = kcalloc(nr, sizeof(struct map_info), GFP_KERNEL);
 	if (!maps)
 		return -ENOMEM;
-	memset(maps, 0, sizeof(struct map_info) * nr);
 	/*
 	 * Claim and then map the memory regions.
 	 */

--- linux-2.6.16-rc4-mm2/drivers/mtd/maps/tqm834x.c.orig	2006-02-28 19:06:59.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/maps/tqm834x.c	2006-02-28 19:07:55.000000000 +0100
@@ -133,20 +133,16 @@ static int __init init_tqm834x_mtd(void)
 
 		pr_debug("%s: chip probing count %d\n", __FUNCTION__, idx);
 
-		map_banks[idx] =
-			(struct map_info *)kmalloc(sizeof(struct map_info),
-						   GFP_KERNEL);
+		map_banks[idx] = kzalloc(sizeof(struct map_info), GFP_KERNEL);
 		if (map_banks[idx] == NULL) {
 			ret = -ENOMEM;
 			goto error_mem;
 		}
-		memset((void *)map_banks[idx], 0, sizeof(struct map_info));
-		map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL);
+		map_banks[idx]->name = kzalloc(16, GFP_KERNEL);
 		if (map_banks[idx]->name == NULL) {
 			ret = -ENOMEM;
 			goto error_mem;
 		}
-		memset((void *)map_banks[idx]->name, 0, 16);
 
 		sprintf(map_banks[idx]->name, "TQM834x-%d", idx);
 		map_banks[idx]->size = flash_size;
--- linux-2.6.16-rc4-mm2/drivers/mtd/maps/tqm8xxl.c.orig	2006-02-28 19:08:03.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/maps/tqm8xxl.c	2006-02-28 19:08:30.000000000 +0100
@@ -135,14 +135,13 @@ int __init init_tqm_mtd(void)
 
 		printk(KERN_INFO "%s: chip probing count %d\n", __FUNCTION__, idx);
 
-		map_banks[idx] = (struct map_info *)kmalloc(sizeof(struct map_info), GFP_KERNEL);
+		map_banks[idx] = kzalloc(sizeof(struct map_info), GFP_KERNEL);
 		if(map_banks[idx] == NULL) {
 			ret = -ENOMEM;
 			/* FIXME: What if some MTD devices were probed already? */
 			goto error_mem;
 		}
 
-		memset((void *)map_banks[idx], 0, sizeof(struct map_info));
 		map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL);
 
 		if (!map_banks[idx]->name) {
--- linux-2.6.16-rc4-mm2/drivers/mtd/maps/omap_nor.c.orig	2006-02-28 19:08:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/maps/omap_nor.c	2006-02-28 19:08:48.000000000 +0100
@@ -78,12 +78,10 @@ static int __devinit omapflash_probe(str
 	struct resource *res = pdev->resource;
 	unsigned long size = res->end - res->start + 1;
 
-	info = kmalloc(sizeof(struct omapflash_info), GFP_KERNEL);
+	info = kzalloc(sizeof(struct omapflash_info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
 
-	memset(info, 0, sizeof(struct omapflash_info));
-
 	if (!request_mem_region(res->start, size, "flash")) {
 		err = -EBUSY;
 		goto out_free_info;
--- linux-2.6.16-rc4-mm2/drivers/mtd/nand/diskonchip.c.orig	2006-02-28 19:08:59.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/mtd/nand/diskonchip.c	2006-02-28 19:09:21.000000000 +0100
@@ -1645,13 +1645,12 @@ static int __init doc_probe(unsigned lon
 	      sizeof(struct nand_chip) +
 	      sizeof(struct doc_priv) +
 	      (2 * sizeof(struct nand_bbt_descr));
-	mtd =  kmalloc(len, GFP_KERNEL);
+	mtd =  kzalloc(len, GFP_KERNEL);
 	if (!mtd) {
 		printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len);
 		ret = -ENOMEM;
 		goto fail;
 	}
-	memset(mtd, 0, len);
 
 	nand			= (struct nand_chip *) (mtd + 1);
 	doc			= (struct doc_priv *) (nand + 1);



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/serial
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (12 preceding siblings ...)
  2006-03-01 23:29 ` [KJ] [Patch] kzalloc() conversion in drivers/mtd Eric Sesterhenn
@ 2006-03-02 11:58 ` Eric Sesterhenn
  2006-03-04 17:56   ` Eric Sesterhenn
                   ` (17 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-02 11:58 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 9421 bytes --]

hi,

this patch converts drivers/serial to kzalloc usage.
Compile tested with allyes config.

ip22zilog.c and sunzilog.c contained their own kzalloc() variant
alloc_one_table() which i removed, and replaced the callers with kzalloc()

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/serial/ioc4_serial.c.orig	2006-03-02 10:00:24.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/serial/ioc4_serial.c	2006-03-02 10:01:03.000000000 +0100
@@ -1034,13 +1034,12 @@ static int inline ioc4_attach_local(stru
 	/* Create port structures for each port */
 	for (port_number = 0; port_number < IOC4_NUM_SERIAL_PORTS;
 							port_number++) {
-		port = kmalloc(sizeof(struct ioc4_port), GFP_KERNEL);
+		port = kzalloc(sizeof(struct ioc4_port), GFP_KERNEL);
 		if (!port) {
 			printk(KERN_WARNING
 				"IOC4 serial memory not available for port\n");
 			return -ENOMEM;
 		}
-		memset(port, 0, sizeof(struct ioc4_port));
 		spin_lock_init(&port->ip_lock);
 
 		/* we need to remember the previous ones, to point back to
@@ -2671,7 +2670,7 @@ ioc4_serial_attach_one(struct ioc4_drive
 	idd->idd_serial_data = control;
 
 	/* Allocate the soft structure */
-	soft = kmalloc(sizeof(struct ioc4_soft), GFP_KERNEL);
+	soft = kzalloc(sizeof(struct ioc4_soft), GFP_KERNEL);
 	if (!soft) {
 		printk(KERN_WARNING
 		       "ioc4 (%p): unable to get memory for the soft struct\n",
@@ -2679,7 +2678,6 @@ ioc4_serial_attach_one(struct ioc4_drive
 		ret = -ENOMEM;
 		goto out3;
 	}
-	memset(soft, 0, sizeof(struct ioc4_soft));
 
 	spin_lock_init(&soft->is_ir_lock);
 	soft->is_ioc4_misc_addr = idd->idd_misc_regs;
--- linux-2.6.16-rc5-mm1/drivers/serial/serial_cs.c.orig	2006-03-02 10:01:12.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/serial/serial_cs.c	2006-03-02 10:01:21.000000000 +0100
@@ -212,10 +212,9 @@ static int serial_probe(struct pcmcia_de
 	DEBUG(0, "serial_attach()\n");
 
 	/* Create new serial device */
-	info = kmalloc(sizeof (*info), GFP_KERNEL);
+	info = kzalloc(sizeof (*info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
-	memset(info, 0, sizeof (*info));
 	info->p_dev = link;
 	link->priv = info;
 
--- linux-2.6.16-rc5-mm1/drivers/serial/8250_acorn.c.orig	2006-03-02 10:01:32.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/serial/8250_acorn.c	2006-03-02 10:01:44.000000000 +0100
@@ -47,11 +47,10 @@ serial_card_probe(struct expansion_card 
 	unsigned char __iomem *virt_addr;
 	unsigned int i;
 
-	info = kmalloc(sizeof(struct serial_card_info), GFP_KERNEL);
+	info = kzalloc(sizeof(struct serial_card_info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
 
-	memset(info, 0, sizeof(struct serial_card_info));
 	info->num_ports = type->num_ports;
 
 	bus_addr = ecard_resource_start(ec, type->type);
--- linux-2.6.16-rc5-mm1/drivers/serial/8250_acpi.c.orig	2006-03-02 10:01:49.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/serial/8250_acpi.c	2006-03-02 10:01:59.000000000 +0100
@@ -104,12 +104,11 @@ static int acpi_serial_add(struct acpi_d
 	port.uartclk = 1843200;
 	port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
 
-	priv = kmalloc(sizeof(struct serial_private), GFP_KERNEL);
+	priv = kzalloc(sizeof(struct serial_private), GFP_KERNEL);
 	if (!priv) {
 		result = -ENOMEM;
 		goto fail;
 	}
-	memset(priv, 0, sizeof(*priv));
 
 	status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
 				     acpi_serial_resource, &port);
--- linux-2.6.16-rc5-mm1/drivers/serial/sunsu.c.orig	2006-03-02 10:02:36.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/serial/sunsu.c	2006-03-02 10:02:48.000000000 +0100
@@ -1303,10 +1303,8 @@ static int __init sunsu_kbd_ms_init(stru
 	       sunsu_type(&up->port));
 
 #ifdef CONFIG_SERIO
-	up->serio = serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
+	up->serio = serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
 	if (serio) {
-		memset(serio, 0, sizeof(*serio));
-
 		serio->port_data = up;
 
 		serio->id.type = SERIO_RS232;
--- linux-2.6.16-rc5-mm1/drivers/serial/sunzilog.c.orig	2006-03-02 10:02:59.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/serial/sunzilog.c	2006-03-02 10:04:45.000000000 +0100
@@ -1022,23 +1022,12 @@ static struct uart_driver sunzilog_reg =
 	.major		=	TTY_MAJOR,
 };
 
-static void * __init alloc_one_table(unsigned long size)
-{
-	void *ret;
-
-	ret = kmalloc(size, GFP_KERNEL);
-	if (ret != NULL)
-		memset(ret, 0, size);
-
-	return ret;
-}
-
 static void __init sunzilog_alloc_tables(void)
 {
 	sunzilog_port_table = 
-		alloc_one_table(NUM_CHANNELS * sizeof(struct uart_sunzilog_port));
+		kzalloc(NUM_CHANNELS * sizeof(struct uart_sunzilog_port), GFP_KERNEL);
 	sunzilog_chip_regs = 
-		alloc_one_table(NUM_SUNZILOG * sizeof(struct zilog_layout __iomem *));
+		kzalloc(NUM_SUNZILOG * sizeof(struct zilog_layout __iomem *), GFP_KERNEL);
 
 	if (sunzilog_port_table == NULL || sunzilog_chip_regs == NULL) {
 		prom_printf("SunZilog: Cannot allocate tables.\n");
@@ -1555,10 +1544,8 @@ static void __init sunzilog_register_ser
 {
 	struct serio *serio;
 
-	up->serio = serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
+	up->serio = serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
 	if (serio) {
-		memset(serio, 0, sizeof(*serio));
-
 		serio->port_data = up;
 
 		serio->id.type = SERIO_RS232;
--- linux-2.6.16-rc5-mm1/drivers/serial/ip22zilog.c.orig	2006-03-02 10:04:54.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/serial/ip22zilog.c	2006-03-02 10:05:51.000000000 +0100
@@ -925,23 +925,12 @@ static struct zilog_layout **ip22zilog_c
 static struct uart_ip22zilog_port *ip22zilog_irq_chain;
 static int zilog_irq = -1;
 
-static void * __init alloc_one_table(unsigned long size)
-{
-	void *ret;
-
-	ret = kmalloc(size, GFP_KERNEL);
-	if (ret != NULL)
-		memset(ret, 0, size);
-
-	return ret;
-}
-
 static void __init ip22zilog_alloc_tables(void)
 {
-	ip22zilog_port_table = (struct uart_ip22zilog_port *)
-		alloc_one_table(NUM_CHANNELS * sizeof(struct uart_ip22zilog_port));
-	ip22zilog_chip_regs = (struct zilog_layout **)
-		alloc_one_table(NUM_IP22ZILOG * sizeof(struct zilog_layout *));
+	ip22zilog_port_table =
+		kzalloc(NUM_CHANNELS * sizeof(struct uart_ip22zilog_port), GFP_KERNEL);
+	ip22zilog_chip_regs =
+		kzalloc(NUM_IP22ZILOG * sizeof(struct zilog_layout *), GFP_KERNEL);
 
 	if (ip22zilog_port_table == NULL || ip22zilog_chip_regs == NULL) {
 		panic("IP22-Zilog: Cannot allocate IP22-Zilog tables.");
--- linux-2.6.16-rc5-mm1/drivers/serial/serial_core.c.orig	2006-03-02 10:06:01.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/serial/serial_core.c	2006-03-02 10:06:36.000000000 +0100
@@ -1492,9 +1492,8 @@ static struct uart_state *uart_get(struc
 	}
 
 	if (!state->info) {
-		state->info = kmalloc(sizeof(struct uart_info), GFP_KERNEL);
+		state->info = kzalloc(sizeof(struct uart_info), GFP_KERNEL);
 		if (state->info) {
-			memset(state->info, 0, sizeof(struct uart_info));
 			init_waitqueue_head(&state->info->open_wait);
 			init_waitqueue_head(&state->info->delta_msr_wait);
 
@@ -2152,13 +2151,11 @@ int uart_register_driver(struct uart_dri
 	 * Maybe we should be using a slab cache for this, especially if
 	 * we have a large number of ports to handle.
 	 */
-	drv->state = kmalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL);
+	drv->state = kcalloc(drv->nr, sizeof(struct uart_state), GFP_KERNEL);
 	retval = -ENOMEM;
 	if (!drv->state)
 		goto out;
 
-	memset(drv->state, 0, sizeof(struct uart_state) * drv->nr);
-
 	normal  = alloc_tty_driver(drv->nr);
 	if (!normal)
 		goto out;
--- linux-2.6.16-rc5-mm1/drivers/serial/jsm/jsm_tty.c.orig	2006-03-02 10:07:15.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/serial/jsm/jsm_tty.c	2006-03-02 10:08:01.000000000 +0100
@@ -194,31 +194,28 @@ static int jsm_tty_open(struct uart_port
 	/* Drop locks, as malloc with GFP_KERNEL can sleep */
 
 	if (!channel->ch_rqueue) {
-		channel->ch_rqueue = (u8 *) kmalloc(RQUEUESIZE, GFP_KERNEL);
+		channel->ch_rqueue = kzalloc(RQUEUESIZE, GFP_KERNEL);
 		if (!channel->ch_rqueue) {
 			jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev,
 				"unable to allocate read queue buf");
 			return -ENOMEM;
 		}
-		memset(channel->ch_rqueue, 0, RQUEUESIZE);
 	}
 	if (!channel->ch_equeue) {
-		channel->ch_equeue = (u8 *) kmalloc(EQUEUESIZE, GFP_KERNEL);
+		channel->ch_equeue = kzalloc(EQUEUESIZE, GFP_KERNEL);
 		if (!channel->ch_equeue) {
 			jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev,
 				"unable to allocate error queue buf");
 			return -ENOMEM;
 		}
-		memset(channel->ch_equeue, 0, EQUEUESIZE);
 	}
 	if (!channel->ch_wqueue) {
-		channel->ch_wqueue = (u8 *) kmalloc(WQUEUESIZE, GFP_KERNEL);
+		channel->ch_wqueue = kzalloc(WQUEUESIZE, GFP_KERNEL);
 		if (!channel->ch_wqueue) {
 			jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev,
 				"unable to allocate write queue buf");
 			return -ENOMEM;
 		}
-		memset(channel->ch_wqueue, 0, WQUEUESIZE);
 	}
 
 	channel->ch_flags &= ~(CH_OPENING);
@@ -392,13 +389,12 @@ int jsm_tty_init(struct jsm_board *brd)
 			 * Okay to malloc with GFP_KERNEL, we are not at
 			 * interrupt context, and there are no locks held.
 			 */
-			brd->channels[i] = kmalloc(sizeof(struct jsm_channel), GFP_KERNEL);
+			brd->channels[i] = kzalloc(sizeof(struct jsm_channel), GFP_KERNEL);
 			if (!brd->channels[i]) {
 				jsm_printk(CORE, ERR, &brd->pci_dev,
 					"%s:%d Unable to allocate memory for channel struct\n",
 							 __FILE__, __LINE__);
 			}
-			memset(brd->channels[i], 0, sizeof(struct jsm_channel));
 		}
 	}
 



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/net
@ 2006-03-04 17:56   ` Eric Sesterhenn
  0 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-04 17:56 UTC (permalink / raw)
  To: kernel-janitors; +Cc: netdev

[-- Attachment #1: Type: text/plain, Size: 42367 bytes --]

hi,

this patch converts drivers/net to kzalloc usage.
Compile tested with allyes config.

It also fixes a bug in drivers/net/chelsio/espi.c, because
it called the memset() before checking if kmalloc failed.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/net/e1000/e1000_ethtool.c.orig	2006-03-02 14:24:18.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/e1000/e1000_ethtool.c	2006-03-02 14:24:59.000000000 +0100
@@ -638,20 +638,18 @@ e1000_set_ringparam(struct net_device *n
 	tx_old = adapter->tx_ring;
 	rx_old = adapter->rx_ring;
 
-	adapter->tx_ring = kmalloc(tx_ring_size, GFP_KERNEL);
+	adapter->tx_ring = kzalloc(tx_ring_size, GFP_KERNEL);
 	if (!adapter->tx_ring) {
 		err = -ENOMEM;
 		goto err_setup_rx;
 	}
-	memset(adapter->tx_ring, 0, tx_ring_size);
 
-	adapter->rx_ring = kmalloc(rx_ring_size, GFP_KERNEL);
+	adapter->rx_ring = kzalloc(rx_ring_size, GFP_KERNEL);
 	if (!adapter->rx_ring) {
 		kfree(adapter->tx_ring);
 		err = -ENOMEM;
 		goto err_setup_rx;
 	}
-	memset(adapter->rx_ring, 0, rx_ring_size);
 
 	txdr = adapter->tx_ring;
 	rxdr = adapter->rx_ring;
@@ -1017,11 +1015,10 @@ e1000_setup_desc_rings(struct e1000_adap
 		txdr->count = E1000_DEFAULT_TXD;
 
 	size = txdr->count * sizeof(struct e1000_buffer);
-	if (!(txdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
+	if (!(txdr->buffer_info = kzalloc(size, GFP_KERNEL))) {
 		ret_val = 1;
 		goto err_nomem;
 	}
-	memset(txdr->buffer_info, 0, size);
 
 	txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
 	E1000_ROUNDUP(txdr->size, 4096);
@@ -1073,11 +1070,10 @@ e1000_setup_desc_rings(struct e1000_adap
 		rxdr->count = E1000_DEFAULT_RXD;
 
 	size = rxdr->count * sizeof(struct e1000_buffer);
-	if (!(rxdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
+	if (!(rxdr->buffer_info = kzalloc(size, GFP_KERNEL))) {
 		ret_val = 4;
 		goto err_nomem;
 	}
-	memset(rxdr->buffer_info, 0, size);
 
 	rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc);
 	if (!(rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma))) {
--- linux-2.6.16-rc5-mm1/drivers/net/e1000/e1000_main.c.orig	2006-03-02 14:25:05.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/e1000/e1000_main.c	2006-03-02 14:26:09.000000000 +0100
@@ -1114,28 +1114,25 @@ e1000_alloc_queues(struct e1000_adapter 
 	int size;
 
 	size = sizeof(struct e1000_tx_ring) * adapter->num_tx_queues;
-	adapter->tx_ring = kmalloc(size, GFP_KERNEL);
+	adapter->tx_ring = kzalloc(size, GFP_KERNEL);
 	if (!adapter->tx_ring)
 		return -ENOMEM;
-	memset(adapter->tx_ring, 0, size);
 
 	size = sizeof(struct e1000_rx_ring) * adapter->num_rx_queues;
-	adapter->rx_ring = kmalloc(size, GFP_KERNEL);
+	adapter->rx_ring = kzalloc(size, GFP_KERNEL);
 	if (!adapter->rx_ring) {
 		kfree(adapter->tx_ring);
 		return -ENOMEM;
 	}
-	memset(adapter->rx_ring, 0, size);
 
 #ifdef CONFIG_E1000_NAPI
 	size = sizeof(struct net_device) * adapter->num_rx_queues;
-	adapter->polling_netdev = kmalloc(size, GFP_KERNEL);
+	adapter->polling_netdev = kzalloc(size, GFP_KERNEL);
 	if (!adapter->polling_netdev) {
 		kfree(adapter->tx_ring);
 		kfree(adapter->rx_ring);
 		return -ENOMEM;
 	}
-	memset(adapter->polling_netdev, 0, size);
 #endif
 
 #ifdef CONFIG_E1000_MQ
@@ -1544,17 +1541,16 @@ e1000_setup_rx_resources(struct e1000_ad
 	memset(rxdr->buffer_info, 0, size);
 
 	size = sizeof(struct e1000_ps_page) * rxdr->count;
-	rxdr->ps_page = kmalloc(size, GFP_KERNEL);
+	rxdr->ps_page = kzalloc(size, GFP_KERNEL);
 	if (!rxdr->ps_page) {
 		vfree(rxdr->buffer_info);
 		DPRINTK(PROBE, ERR,
 		"Unable to allocate memory for the receive descriptor ring\n");
 		return -ENOMEM;
 	}
-	memset(rxdr->ps_page, 0, size);
 
 	size = sizeof(struct e1000_ps_page_dma) * rxdr->count;
-	rxdr->ps_page_dma = kmalloc(size, GFP_KERNEL);
+	rxdr->ps_page_dma = kzalloc(size, GFP_KERNEL);
 	if (!rxdr->ps_page_dma) {
 		vfree(rxdr->buffer_info);
 		kfree(rxdr->ps_page);
@@ -1562,7 +1558,6 @@ e1000_setup_rx_resources(struct e1000_ad
 		"Unable to allocate memory for the receive descriptor ring\n");
 		return -ENOMEM;
 	}
-	memset(rxdr->ps_page_dma, 0, size);
 
 	if (adapter->hw.mac_type <= e1000_82547_rev_2)
 		desc_len = sizeof(struct e1000_rx_desc);
--- linux-2.6.16-rc5-mm1/drivers/net/pcmcia/ibmtr_cs.c.orig	2006-03-02 14:26:19.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/pcmcia/ibmtr_cs.c	2006-03-02 14:26:28.000000000 +0100
@@ -146,9 +146,8 @@ static int ibmtr_attach(struct pcmcia_de
     DEBUG(0, "ibmtr_attach()\n");
 
     /* Create new token-ring device */
-    info = kmalloc(sizeof(*info), GFP_KERNEL); 
+    info = kzalloc(sizeof(*info), GFP_KERNEL); 
     if (!info) return -ENOMEM;
-    memset(info,0,sizeof(*info));
     dev = alloc_trdev(sizeof(struct tok_info));
     if (!dev) {
 	kfree(info);
--- linux-2.6.16-rc5-mm1/drivers/net/slhc.c.orig	2006-03-02 14:26:39.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/slhc.c	2006-03-02 14:27:11.000000000 +0100
@@ -95,27 +95,23 @@ slhc_init(int rslots, int tslots)
 	register struct cstate *ts;
 	struct slcompress *comp;
 
-	comp = (struct slcompress *)kmalloc(sizeof(struct slcompress),
-					    GFP_KERNEL);
+	comp = kzalloc(sizeof(struct slcompress), GFP_KERNEL);
 	if (! comp)
 		goto out_fail;
-	memset(comp, 0, sizeof(struct slcompress));
 
 	if ( rslots > 0  &&  rslots < 256 ) {
 		size_t rsize = rslots * sizeof(struct cstate);
-		comp->rstate = (struct cstate *) kmalloc(rsize, GFP_KERNEL);
+		comp->rstate = kzalloc(rsize, GFP_KERNEL);
 		if (! comp->rstate)
 			goto out_free;
-		memset(comp->rstate, 0, rsize);
 		comp->rslot_limit = rslots - 1;
 	}
 
 	if ( tslots > 0  &&  tslots < 256 ) {
 		size_t tsize = tslots * sizeof(struct cstate);
-		comp->tstate = (struct cstate *) kmalloc(tsize, GFP_KERNEL);
+		comp->tstate = kzalloc(tsize, GFP_KERNEL);
 		if (! comp->tstate)
 			goto out_free2;
-		memset(comp->tstate, 0, tsize);
 		comp->tslot_limit = tslots - 1;
 	}
 
--- linux-2.6.16-rc5-mm1/drivers/net/sb1250-mac.c.orig	2006-03-02 14:27:18.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/sb1250-mac.c	2006-03-02 14:27:35.000000000 +0100
@@ -743,9 +743,7 @@ static void sbdma_initctx(sbmacdma_t *d,
 	 */
 
 	d->sbdma_ctxtable = (struct sk_buff **)
-		kmalloc(d->sbdma_maxdescr*sizeof(struct sk_buff *), GFP_KERNEL);
-
-	memset(d->sbdma_ctxtable,0,d->sbdma_maxdescr*sizeof(struct sk_buff *));
+		kzalloc(d->sbdma_maxdescr*sizeof(struct sk_buff *), GFP_KERNEL);
 
 #ifdef CONFIG_SBMAC_COALESCE
 	/*
--- linux-2.6.16-rc5-mm1/drivers/net/ppp_async.c.orig	2006-03-02 14:27:44.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/ppp_async.c	2006-03-02 14:27:52.000000000 +0100
@@ -159,12 +159,11 @@ ppp_asynctty_open(struct tty_struct *tty
 	int err;
 
 	err = -ENOMEM;
-	ap = kmalloc(sizeof(*ap), GFP_KERNEL);
+	ap = kzalloc(sizeof(*ap), GFP_KERNEL);
 	if (ap == 0)
 		goto out;
 
 	/* initialize the asyncppp structure */
-	memset(ap, 0, sizeof(*ap));
 	ap->tty = tty;
 	ap->mru = PPP_MRU;
 	spin_lock_init(&ap->xmit_lock);
--- linux-2.6.16-rc5-mm1/drivers/net/loopback.c.orig	2006-03-02 14:28:00.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/loopback.c	2006-03-02 14:28:13.000000000 +0100
@@ -224,9 +224,8 @@ int __init loopback_init(void)
 	struct net_device_stats *stats;
 
 	/* Can survive without statistics */
-	stats = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
+	stats = kzalloc(sizeof(struct net_device_stats), GFP_KERNEL);
 	if (stats) {
-		memset(stats, 0, sizeof(struct net_device_stats));
 		loopback_dev.priv = stats;
 		loopback_dev.get_stats = &get_stats;
 	}
--- linux-2.6.16-rc5-mm1/drivers/net/bnx2.c.orig	2006-03-02 14:28:26.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/bnx2.c	2006-03-02 14:29:22.000000000 +0100
@@ -397,12 +397,11 @@ bnx2_alloc_mem(struct bnx2 *bp)
 {
 	int i;
 
-	bp->tx_buf_ring = kmalloc(sizeof(struct sw_bd) * TX_DESC_CNT,
+	bp->tx_buf_ring = kzalloc(sizeof(struct sw_bd) * TX_DESC_CNT,
 				     GFP_KERNEL);
 	if (bp->tx_buf_ring == NULL)
 		return -ENOMEM;
 
-	memset(bp->tx_buf_ring, 0, sizeof(struct sw_bd) * TX_DESC_CNT);
 	bp->tx_desc_ring = pci_alloc_consistent(bp->pdev,
 					        sizeof(struct tx_bd) *
 						TX_DESC_CNT,
--- linux-2.6.16-rc5-mm1/drivers/net/ppp_deflate.c.orig	2006-03-02 14:29:33.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/ppp_deflate.c	2006-03-02 14:30:00.000000000 +0100
@@ -121,12 +121,10 @@ static void *z_comp_alloc(unsigned char 
 	if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
 		return NULL;
 
-	state = (struct ppp_deflate_state *) kmalloc(sizeof(*state),
-						     GFP_KERNEL);
+	state = kzalloc(sizeof(*state), GFP_KERNEL);
 	if (state == NULL)
 		return NULL;
 
-	memset (state, 0, sizeof (struct ppp_deflate_state));
 	state->strm.next_in   = NULL;
 	state->w_size         = w_size;
 	state->strm.workspace = vmalloc(zlib_deflate_workspacesize());
@@ -341,11 +339,10 @@ static void *z_decomp_alloc(unsigned cha
 	if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
 		return NULL;
 
-	state = (struct ppp_deflate_state *) kmalloc(sizeof(*state), GFP_KERNEL);
+	state = kzalloc(sizeof(*state), GFP_KERNEL);
 	if (state == NULL)
 		return NULL;
 
-	memset (state, 0, sizeof (struct ppp_deflate_state));
 	state->w_size         = w_size;
 	state->strm.next_out  = NULL;
 	state->strm.workspace = kmalloc(zlib_inflate_workspacesize(),
--- linux-2.6.16-rc5-mm1/drivers/net/iseries_veth.c.orig	2006-03-02 14:30:09.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/iseries_veth.c	2006-03-02 14:30:43.000000000 +0100
@@ -820,10 +820,9 @@ static int veth_init_connection(u8 rlp)
 	     || ! HvLpConfig_doLpsCommunicateOnVirtualLan(this_lp, rlp) )
 		return 0;
 
-	cnx = kmalloc(sizeof(*cnx), GFP_KERNEL);
+	cnx = kzalloc(sizeof(*cnx), GFP_KERNEL);
 	if (! cnx)
 		return -ENOMEM;
-	memset(cnx, 0, sizeof(*cnx));
 
 	cnx->remote_lp = rlp;
 	spin_lock_init(&cnx->lock);
@@ -850,14 +849,13 @@ static int veth_init_connection(u8 rlp)
 	if (rc != 0)
 		return rc;
 
-	msgs = kmalloc(VETH_NUMBUFFERS * sizeof(struct veth_msg), GFP_KERNEL);
+	msgs = kzalloc(VETH_NUMBUFFERS * sizeof(struct veth_msg), GFP_KERNEL);
 	if (! msgs) {
 		veth_error("Can't allocate buffers for LPAR %d.\n", rlp);
 		return -ENOMEM;
 	}
 
 	cnx->msgs = msgs;
-	memset(msgs, 0, VETH_NUMBUFFERS * sizeof(struct veth_msg));
 
 	for (i = 0; i < VETH_NUMBUFFERS; i++) {
 		msgs[i].token = i;
--- linux-2.6.16-rc5-mm1/drivers/net/via-velocity.c.orig	2006-03-02 14:30:54.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/via-velocity.c	2006-03-02 14:31:24.000000000 +0100
@@ -1072,10 +1072,9 @@ static int velocity_init_rd_ring(struct 
 	unsigned int rsize = sizeof(struct velocity_rd_info) * 
 					vptr->options.numrx;
 
-	vptr->rd_info = kmalloc(rsize, GFP_KERNEL);
+	vptr->rd_info = kzalloc(rsize, GFP_KERNEL);
 	if(vptr->rd_info == NULL)
 		goto out;
-	memset(vptr->rd_info, 0, rsize);
 
 	vptr->rd_filled = vptr->rd_dirty = vptr->rd_curr = 0;
 
@@ -1146,14 +1145,13 @@ static int velocity_init_td_ring(struct 
 	for (j = 0; j < vptr->num_txq; j++) {
 		curr = vptr->td_pool_dma[j];
 
-		vptr->td_infos[j] = kmalloc(tsize, GFP_KERNEL);
+		vptr->td_infos[j] = kzalloc(tsize, GFP_KERNEL);
 		if(vptr->td_infos[j] == NULL)
 		{
 			while(--j >= 0)
 				kfree(vptr->td_infos[j]);
 			return -ENOMEM;
 		}
-		memset(vptr->td_infos[j], 0, tsize);
 
 		for (i = 0; i < vptr->options.numtx; i++, curr += sizeof(struct tx_desc)) {
 			td = &(vptr->td_rings[j][i]);
--- linux-2.6.16-rc5-mm1/drivers/net/pcnet32.c.orig	2006-03-02 14:31:32.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/pcnet32.c	2006-03-02 15:04:10.000000000 +0100
@@ -1480,41 +1480,37 @@ static int pcnet32_alloc_ring(struct net
 	return -ENOMEM;
     }
 
-    lp->tx_dma_addr = kmalloc(sizeof(dma_addr_t) * lp->tx_ring_size,
+    lp->tx_dma_addr = kcalloc(lp->tx_ring_size, sizeof(dma_addr_t),
 	    GFP_ATOMIC);
     if (!lp->tx_dma_addr) {
 	if (pcnet32_debug & NETIF_MSG_DRV)
 	    printk("\n" KERN_ERR PFX "%s: Memory allocation failed.\n", name);
 	return -ENOMEM;
     }
-    memset(lp->tx_dma_addr, 0, sizeof(dma_addr_t) * lp->tx_ring_size);
 
-    lp->rx_dma_addr = kmalloc(sizeof(dma_addr_t) * lp->rx_ring_size,
+    lp->rx_dma_addr = kcalloc(lp->rx_ring_size, sizeof(dma_addr_t),
 	    GFP_ATOMIC);
     if (!lp->rx_dma_addr) {
 	if (pcnet32_debug & NETIF_MSG_DRV)
 	    printk("\n" KERN_ERR PFX "%s: Memory allocation failed.\n", name);
 	return -ENOMEM;
     }
-    memset(lp->rx_dma_addr, 0, sizeof(dma_addr_t) * lp->rx_ring_size);
 
-    lp->tx_skbuff = kmalloc(sizeof(struct sk_buff *) * lp->tx_ring_size,
+    lp->tx_skbuff = kcalloc(lp->tx_ring_size, sizeof(struct sk_buff *),
 	    GFP_ATOMIC);
     if (!lp->tx_skbuff) {
 	if (pcnet32_debug & NETIF_MSG_DRV)
 	    printk("\n" KERN_ERR PFX "%s: Memory allocation failed.\n", name);
 	return -ENOMEM;
     }
-    memset(lp->tx_skbuff, 0, sizeof(struct sk_buff *) * lp->tx_ring_size);
 
-    lp->rx_skbuff = kmalloc(sizeof(struct sk_buff *) * lp->rx_ring_size,
+    lp->rx_skbuff = kcalloc(lp->rx_ring_size, sizeof(struct sk_buff *),
 	    GFP_ATOMIC);
     if (!lp->rx_skbuff) {
 	if (pcnet32_debug & NETIF_MSG_DRV)
 	    printk("\n" KERN_ERR PFX "%s: Memory allocation failed.\n", name);
 	return -ENOMEM;
     }
-    memset(lp->rx_skbuff, 0, sizeof(struct sk_buff *) * lp->rx_ring_size);
 
     return 0;
 }
--- linux-2.6.16-rc5-mm1/drivers/net/fs_enet/fs_enet-mii.c.orig	2006-03-02 14:33:53.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/fs_enet/fs_enet-mii.c	2006-03-02 14:34:01.000000000 +0100
@@ -389,12 +389,11 @@ static struct fs_enet_mii_bus *create_bu
 	struct fs_enet_mii_bus *bus;
 	int ret = 0;
 
-	bus = kmalloc(sizeof(*bus), GFP_KERNEL);
+	bus = kzalloc(sizeof(*bus), GFP_KERNEL);
 	if (bus == NULL) {
 		ret = -ENOMEM;
 		goto err;
 	}
-	memset(bus, 0, sizeof(*bus));
 	spin_lock_init(&bus->mii_lock);
 	bus->bus_info = bi;
 	bus->refs = 0;
--- linux-2.6.16-rc5-mm1/drivers/net/ppp_mppe.c.orig	2006-03-02 14:34:21.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/ppp_mppe.c	2006-03-02 14:34:35.000000000 +0100
@@ -191,12 +191,10 @@ static void *mppe_alloc(unsigned char *o
 	    || options[0] != CI_MPPE || options[1] != CILEN_MPPE)
 		goto out;
 
-	state = (struct ppp_mppe_state *) kmalloc(sizeof(*state), GFP_KERNEL);
+	state = kzalloc(sizeof(*state), GFP_KERNEL);
 	if (state == NULL)
 		goto out;
 
-	memset(state, 0, sizeof(*state));
-
 	state->arc4 = crypto_alloc_tfm("arc4", 0);
 	if (!state->arc4)
 		goto out_free;
--- linux-2.6.16-rc5-mm1/drivers/net/irda/irtty-sir.c.orig	2006-03-02 14:34:51.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/irda/irtty-sir.c	2006-03-02 14:35:01.000000000 +0100
@@ -505,10 +505,9 @@ static int irtty_open(struct tty_struct 
 	}
 
 	/* allocate private device info block */
-	priv = kmalloc(sizeof(*priv), GFP_KERNEL);
+	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		goto out_put;
-	memset(priv, 0, sizeof(*priv));
 
 	priv->magic = IRTTY_MAGIC;
 	priv->tty = tty;
--- linux-2.6.16-rc5-mm1/drivers/net/irda/irda-usb.c.orig	2006-03-02 14:35:49.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/irda/irda-usb.c	2006-03-02 14:36:12.000000000 +0100
@@ -1343,10 +1343,9 @@ static inline struct irda_class_desc *ir
 	struct irda_class_desc *desc;
 	int ret;
 
-	desc = kmalloc(sizeof (*desc), GFP_KERNEL);
+	desc = kzalloc(sizeof (*desc), GFP_KERNEL);
 	if (desc == NULL) 
 		return NULL;
-	memset(desc, 0, sizeof(*desc));
 
 	/* USB-IrDA class spec 1.0:
 	 *	6.1.3: Standard "Get Descriptor" Device Request is not
@@ -1495,12 +1494,10 @@ static int irda_usb_probe(struct usb_int
 	/* Don't change this buffer size and allocation without doing
 	 * some heavy and complete testing. Don't ask why :-(
 	 * Jean II */
-	self->speed_buff = (char *) kmalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL);
+	self->speed_buff = kzalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL);
 	if (self->speed_buff == NULL) 
 		goto err_out_3;
 
-	memset(self->speed_buff, 0, IRDA_USB_SPEED_MTU);
-
 	ret = irda_usb_open(self);
 	if (ret) 
 		goto err_out_4;
--- linux-2.6.16-rc5-mm1/drivers/net/chelsio/sge.c.orig	2006-03-02 14:36:45.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/chelsio/sge.c	2006-03-02 14:37:23.000000000 +0100
@@ -336,10 +336,9 @@ static int alloc_rx_resources(struct sge
 			goto err_no_mem;
 		memset(q->entries, 0, size);
 		size = sizeof(struct freelQ_ce) * q->size;
-		q->centries = kmalloc(size, GFP_KERNEL);
+		q->centries = kzalloc(size, GFP_KERNEL);
 		if (!q->centries)
 			goto err_no_mem;
-		memset(q->centries, 0, size);
 	}
 
 	/*
@@ -464,10 +463,9 @@ static int alloc_tx_resources(struct sge
 			goto err_no_mem;
 		memset(q->entries, 0, size);
 		size = sizeof(struct cmdQ_ce) * q->size;
-		q->centries = kmalloc(size, GFP_KERNEL);
+		q->centries = kzalloc(size, GFP_KERNEL);
 		if (!q->centries)
 			goto err_no_mem;
-		memset(q->centries, 0, size);
 	}
 
 	/*
@@ -1649,11 +1647,10 @@ static void espibug_workaround(void *dat
 struct sge * __devinit t1_sge_create(struct adapter *adapter,
 				     struct sge_params *p)
 {
-	struct sge *sge = kmalloc(sizeof(*sge), GFP_KERNEL);
+	struct sge *sge = kzalloc(sizeof(*sge), GFP_KERNEL);
 
 	if (!sge)
 		return NULL;
-	memset(sge, 0, sizeof(*sge));
 
 	sge->adapter = adapter;
 	sge->netdev = adapter->port[0].dev;
--- linux-2.6.16-rc5-mm1/drivers/net/chelsio/espi.c.orig	2006-03-02 14:37:51.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/chelsio/espi.c	2006-03-02 14:38:49.000000000 +0100
@@ -296,9 +296,7 @@ void t1_espi_destroy(struct peespi *espi
 
 struct peespi *t1_espi_create(adapter_t *adapter)
 {
-	struct peespi *espi = kmalloc(sizeof(*espi), GFP_KERNEL);
-
-	memset(espi, 0, sizeof(*espi));
+	struct peespi *espi = kzalloc(sizeof(*espi), GFP_KERNEL);
 
 	if (espi)
 		espi->adapter = adapter;
--- linux-2.6.16-rc5-mm1/drivers/net/chelsio/mv88x201x.c.orig	2006-03-02 14:38:57.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/chelsio/mv88x201x.c	2006-03-02 14:39:07.000000000 +0100
@@ -205,11 +205,10 @@ static struct cphy *mv88x201x_phy_create
 					 struct mdio_ops *mdio_ops)
 {
 	u32 val;
-	struct cphy *cphy = kmalloc(sizeof(*cphy), GFP_KERNEL);
+	struct cphy *cphy = kzalloc(sizeof(*cphy), GFP_KERNEL);
 
 	if (!cphy)
 		return NULL;
-	memset(cphy, 0, sizeof(*cphy));
 	cphy_init(cphy, adapter, phy_addr, &mv88x201x_ops, mdio_ops);
 
 	/* Commands the PHY to enable XFP's clock. */
--- linux-2.6.16-rc5-mm1/drivers/net/mipsnet.c.orig	2006-03-02 14:39:19.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/mipsnet.c	2006-03-02 14:39:28.000000000 +0100
@@ -323,12 +323,11 @@ static int __init mipsnet_init_module(vo
 		goto out;
 	}
 
-        if (!(pldev = kmalloc (sizeof (*pldev), GFP_KERNEL))) {
+        if (!(pldev = kzalloc (sizeof (*pldev), GFP_KERNEL))) {
 		err = -ENOMEM;
 		goto out_unregister_driver;
 	}
 
-	memset (pldev, 0, sizeof (*pldev));
 	pldev->name		= mipsnet_string;
 	pldev->id		= 0;
 	pldev->dev.release	= mipsnet_platform_release;
--- linux-2.6.16-rc5-mm1/drivers/net/wan/hdlc_fr.c.orig	2006-03-02 14:40:08.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/hdlc_fr.c	2006-03-02 14:40:23.000000000 +0100
@@ -159,11 +159,10 @@ static inline pvc_device* add_pvc(struct
 		pvc_p = &(*pvc_p)->next;
 	}
 
-	pvc = kmalloc(sizeof(pvc_device), GFP_ATOMIC);
+	pvc = kzalloc(sizeof(pvc_device), GFP_ATOMIC);
 	if (!pvc)
 		return NULL;
 
-	memset(pvc, 0, sizeof(pvc_device));
 	pvc->dlci = dlci;
 	pvc->master = dev;
 	pvc->next = *pvc_p;	/* Put it in the chain */
--- linux-2.6.16-rc5-mm1/drivers/net/wan/sdla_chdlc.c.orig	2006-03-02 14:40:32.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/sdla_chdlc.c	2006-03-02 14:40:52.000000000 +0100
@@ -679,13 +679,11 @@ static int new_if(struct wan_device* wan
 	}
 		
 	/* allocate and initialize private data */
-	chdlc_priv_area = kmalloc(sizeof(chdlc_private_area_t), GFP_KERNEL);
+	chdlc_priv_area = kzalloc(sizeof(chdlc_private_area_t), GFP_KERNEL);
 	
 	if(chdlc_priv_area == NULL) 
 		return -ENOMEM;
 
-	memset(chdlc_priv_area, 0, sizeof(chdlc_private_area_t));
-
 	chdlc_priv_area->card = card; 
 	chdlc_priv_area->common.sk = NULL;
 	chdlc_priv_area->common.func = NULL;	
--- linux-2.6.16-rc5-mm1/drivers/net/wan/hostess_sv11.c.orig	2006-03-02 14:41:05.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/hostess_sv11.c	2006-03-02 14:41:27.000000000 +0100
@@ -231,11 +231,10 @@ static struct sv11_device *sv11_init(int
 		return NULL;
 	}
 	
-	sv=(struct sv11_device *)kmalloc(sizeof(struct sv11_device), GFP_KERNEL);
+	sv=kzalloc(sizeof(struct sv11_device), GFP_KERNEL);
 	if(!sv)
 		goto fail3;
 			
-	memset(sv, 0, sizeof(*sv));
 	sv->if_ptr=&sv->netdev;
 	
 	sv->netdev.dev = alloc_netdev(0, "hdlc%d", sv11_setup);
--- linux-2.6.16-rc5-mm1/drivers/net/wan/sealevel.c.orig	2006-03-02 14:41:34.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/sealevel.c	2006-03-02 14:41:45.000000000 +0100
@@ -270,11 +270,10 @@ static __init struct slvl_board *slvl_in
 		return NULL;
 	}
 	
-	b = kmalloc(sizeof(struct slvl_board), GFP_KERNEL);
+	b = kzalloc(sizeof(struct slvl_board), GFP_KERNEL);
 	if(!b)
 		goto fail3;
 
-	memset(b, 0, sizeof(*b));
 	if (!(b->dev[0]= slvl_alloc(iobase, irq)))
 		goto fail2;
 
--- linux-2.6.16-rc5-mm1/drivers/net/wan/sdla_x25.c.orig	2006-03-02 14:41:55.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/sdla_x25.c	2006-03-02 14:42:43.000000000 +0100
@@ -926,13 +926,11 @@ static int new_if(struct wan_device* wan
 	}
 
 	/* allocate and initialize private data */
-	chan = kmalloc(sizeof(x25_channel_t), GFP_ATOMIC);
+	chan = kzalloc(sizeof(x25_channel_t), GFP_ATOMIC);
 	if (chan == NULL){
 		return -ENOMEM;
 	}
 	
-	memset(chan, 0, sizeof(x25_channel_t));
-
 	/* Bug Fix: Seg Err on PVC startup
 	 * It must be here since bind_lcn_to_dev expects 
 	 * it bellow */
@@ -1194,7 +1192,7 @@ static int if_open(struct net_device* de
 
 	/* Allocate and initialize BH circular buffer */
 	/* Add 1 to MAX_BH_BUFF so we don't have test with (MAX_BH_BUFF-1) */
-	chan->bh_head = kmalloc((sizeof(bh_data_t)*(MAX_BH_BUFF+1)),GFP_ATOMIC);
+	chan->bh_head = kzalloc((sizeof(bh_data_t)*(MAX_BH_BUFF+1)),GFP_ATOMIC);
 
 	if (chan->bh_head == NULL){
 		printk(KERN_INFO "%s: ERROR, failed to allocate memory ! BH_BUFFERS !\n",
@@ -1202,7 +1200,6 @@ static int if_open(struct net_device* de
 
 		return -ENOBUFS;
 	}
-	memset(chan->bh_head,0,(sizeof(bh_data_t)*(MAX_BH_BUFF+1)));
 	atomic_set(&chan->bh_buff_used, 0);
 
 	/* Increment the number of interfaces */
--- linux-2.6.16-rc5-mm1/drivers/net/wan/sdla.c.orig	2006-03-02 14:42:53.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/sdla.c	2006-03-02 14:43:21.000000000 +0100
@@ -1203,10 +1203,9 @@ static int sdla_xfer(struct net_device *
 		
 	if (read)
 	{	
-		temp = kmalloc(mem.len, GFP_KERNEL);
+		temp = kzalloc(mem.len, GFP_KERNEL);
 		if (!temp)
 			return(-ENOMEM);
-		memset(temp, 0, mem.len);
 		sdla_read(dev, mem.addr, temp, mem.len);
 		if(copy_to_user(mem.data, temp, mem.len))
 		{
--- linux-2.6.16-rc5-mm1/drivers/net/wan/cycx_x25.c.orig	2006-03-02 14:43:41.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/cycx_x25.c	2006-03-02 14:44:01.000000000 +0100
@@ -376,11 +376,10 @@ static int cycx_wan_new_if(struct wan_de
 	}
 
 	/* allocate and initialize private data */
-	chan = kmalloc(sizeof(struct cycx_x25_channel), GFP_KERNEL);
+	chan = kzalloc(sizeof(struct cycx_x25_channel), GFP_KERNEL);
 	if (!chan)
 		return -ENOMEM;
 
-	memset(chan, 0, sizeof(*chan));
 	strcpy(chan->name, conf->name);
 	chan->card = card;
 	chan->link = conf->port;
--- linux-2.6.16-rc5-mm1/drivers/net/wan/c101.c.orig	2006-03-02 14:44:08.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/c101.c	2006-03-02 14:44:17.000000000 +0100
@@ -309,12 +309,11 @@ static int __init c101_run(unsigned long
 		return -ENODEV;
 	}
 
-	card = kmalloc(sizeof(card_t), GFP_KERNEL);
+	card = kzalloc(sizeof(card_t), GFP_KERNEL);
 	if (card == NULL) {
 		printk(KERN_ERR "c101: unable to allocate memory\n");
 		return -ENOBUFS;
 	}
-	memset(card, 0, sizeof(card_t));
 
 	card->dev = alloc_hdlcdev(card);
 	if (!card->dev) {
--- linux-2.6.16-rc5-mm1/drivers/net/wan/wanpipe_multppp.c.orig	2006-03-02 14:44:24.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/wanpipe_multppp.c	2006-03-02 14:44:36.000000000 +0100
@@ -539,13 +539,11 @@ static int new_if(struct wan_device* wan
 	}
 		
 	/* allocate and initialize private data */
-	chdlc_priv_area = kmalloc(sizeof(chdlc_private_area_t), GFP_KERNEL);
+	chdlc_priv_area = kzalloc(sizeof(chdlc_private_area_t), GFP_KERNEL);
 	
 	if(chdlc_priv_area == NULL) 
 		return -ENOMEM;
 
-	memset(chdlc_priv_area, 0, sizeof(chdlc_private_area_t));
-
 	chdlc_priv_area->card = card; 
 
 	/* initialize data */
--- linux-2.6.16-rc5-mm1/drivers/net/wan/sdla_ppp.c.orig	2006-03-02 14:44:51.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/sdla_ppp.c	2006-03-02 14:45:02.000000000 +0100
@@ -528,13 +528,11 @@ static int new_if(struct wan_device *wan
 	}
 
 	/* allocate and initialize private data */
-	ppp_priv_area = kmalloc(sizeof(ppp_private_area_t), GFP_KERNEL);
+	ppp_priv_area = kzalloc(sizeof(ppp_private_area_t), GFP_KERNEL);
 	
 	if( ppp_priv_area == NULL )
 		return	-ENOMEM;
 	
-	memset(ppp_priv_area, 0, sizeof(ppp_private_area_t));
-	
 	ppp_priv_area->card = card; 
 	
 	/* initialize data */
--- linux-2.6.16-rc5-mm1/drivers/net/wan/cycx_main.c.orig	2006-03-02 14:45:12.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/cycx_main.c	2006-03-02 14:45:35.000000000 +0100
@@ -114,13 +114,11 @@ static int __init cycx_init(void)
 	/* Verify number of cards and allocate adapter data space */
 	cycx_ncards = min_t(int, cycx_ncards, CYCX_MAX_CARDS);
 	cycx_ncards = max_t(int, cycx_ncards, 1);
-	cycx_card_array = kmalloc(sizeof(struct cycx_device) * cycx_ncards,
+	cycx_card_array = kcalloc(cycx_ncards, sizeof(struct cycx_device),
 				  GFP_KERNEL);
 	if (!cycx_card_array)
 		goto out;
 
-	memset(cycx_card_array, 0, sizeof(struct cycx_device) * cycx_ncards);
-
 	/* Register adapters with WAN router */
 	for (cnt = 0; cnt < cycx_ncards; ++cnt) {
 		struct cycx_device *card = &cycx_card_array[cnt];
--- linux-2.6.16-rc5-mm1/drivers/net/wan/dscc4.c.orig	2006-03-02 14:45:45.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/dscc4.c	2006-03-02 14:46:12.000000000 +0100
@@ -890,12 +890,11 @@ static int dscc4_found1(struct pci_dev *
 	struct dscc4_dev_priv *root;
 	int i, ret = -ENOMEM;
 
-	root = kmalloc(dev_per_card*sizeof(*root), GFP_KERNEL);
+	root = kcalloc(dev_per_card, sizeof(*root), GFP_KERNEL);
 	if (!root) {
 		printk(KERN_ERR "%s: can't allocate data\n", DRV_NAME);
 		goto err_out;
 	}
-	memset(root, 0, dev_per_card*sizeof(*root));
 
 	for (i = 0; i < dev_per_card; i++) {
 		root[i].dev = alloc_hdlcdev(root + i);
@@ -903,12 +902,11 @@ static int dscc4_found1(struct pci_dev *
 			goto err_free_dev;
 	}
 
-	ppriv = kmalloc(sizeof(*ppriv), GFP_KERNEL);
+	ppriv = kzalloc(sizeof(*ppriv), GFP_KERNEL);
 	if (!ppriv) {
 		printk(KERN_ERR "%s: can't allocate private data\n", DRV_NAME);
 		goto err_free_dev;
 	}
-	memset(ppriv, 0, sizeof(struct dscc4_pci_priv));
 
 	ppriv->root = root;
 	spin_lock_init(&ppriv->lock);
--- linux-2.6.16-rc5-mm1/drivers/net/wan/n2.c.orig	2006-03-02 14:46:20.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/n2.c	2006-03-02 14:46:27.000000000 +0100
@@ -351,12 +351,11 @@ static int __init n2_run(unsigned long i
 		return -ENODEV;
 	}
 
-	card = kmalloc(sizeof(card_t), GFP_KERNEL);
+	card = kzalloc(sizeof(card_t), GFP_KERNEL);
 	if (card == NULL) {
 		printk(KERN_ERR "n2: unable to allocate memory\n");
 		return -ENOBUFS;
 	}
-	memset(card, 0, sizeof(card_t));
 
 	card->ports[0].dev = alloc_hdlcdev(&card->ports[0]);
 	card->ports[1].dev = alloc_hdlcdev(&card->ports[1]);
--- linux-2.6.16-rc5-mm1/drivers/net/wan/sdla_fr.c.orig	2006-03-02 14:46:37.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/sdla_fr.c	2006-03-02 14:47:11.000000000 +0100
@@ -812,12 +812,11 @@ static int new_if(struct wan_device* wan
 	}
 
 	/* allocate and initialize private data */
-	chan = kmalloc(sizeof(fr_channel_t), GFP_KERNEL);
+	chan = kzalloc(sizeof(fr_channel_t), GFP_KERNEL);
 
 	if (chan == NULL)
 		return -ENOMEM;
 
-	memset(chan, 0, sizeof(fr_channel_t));
 	strcpy(chan->name, conf->name);
 	chan->card = card;
 
@@ -1214,8 +1213,7 @@ static int if_open(struct net_device* de
 	INIT_WORK(&chan->common.wanpipe_work, (void *)fr_bh, dev);
 
 	/* Allocate and initialize BH circular buffer */
-	chan->bh_head = kmalloc((sizeof(bh_data_t)*MAX_BH_BUFF),GFP_ATOMIC);
-	memset(chan->bh_head,0,(sizeof(bh_data_t)*MAX_BH_BUFF));
+	chan->bh_head = kzalloc((sizeof(bh_data_t)*MAX_BH_BUFF),GFP_ATOMIC);
 	atomic_set(&chan->bh_buff_used, 0);
 
 	netif_start_queue(dev);
--- linux-2.6.16-rc5-mm1/drivers/net/shaper.c.orig	2006-03-02 14:47:27.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/shaper.c	2006-03-02 14:47:44.000000000 +0100
@@ -601,10 +601,9 @@ static int __init shaper_init(void)
 		return -ENODEV;
 
 	alloc_size = sizeof(*dev) * shapers;
-	devs = kmalloc(alloc_size, GFP_KERNEL);
+	devs = kzalloc(alloc_size, GFP_KERNEL);
 	if (!devs)
 		return -ENOMEM;
-	memset(devs, 0, alloc_size);
 
 	for (i = 0; i < shapers; i++) {
 
--- linux-2.6.16-rc5-mm1/drivers/net/ppp_generic.c.orig	2006-03-02 14:47:52.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/ppp_generic.c	2006-03-02 14:48:22.000000000 +0100
@@ -2006,10 +2006,9 @@ ppp_register_channel(struct ppp_channel 
 {
 	struct channel *pch;
 
-	pch = kmalloc(sizeof(struct channel), GFP_KERNEL);
+	pch = kzalloc(sizeof(struct channel), GFP_KERNEL);
 	if (pch == 0)
 		return -ENOMEM;
-	memset(pch, 0, sizeof(struct channel));
 	pch->ppp = NULL;
 	pch->chan = chan;
 	chan->ppp = pch;
@@ -2717,8 +2716,7 @@ static void cardmap_set(struct cardmap *
 	if (p == NULL || (nr >> p->shift) >= CARDMAP_WIDTH) {
 		do {
 			/* need a new top level */
-			struct cardmap *np = kmalloc(sizeof(*np), GFP_KERNEL);
-			memset(np, 0, sizeof(*np));
+			struct cardmap *np = kzalloc(sizeof(*np), GFP_KERNEL);
 			np->ptr[0] = p;
 			if (p != NULL) {
 				np->shift = p->shift + CARDMAP_ORDER;
@@ -2732,8 +2730,7 @@ static void cardmap_set(struct cardmap *
 	while (p->shift > 0) {
 		i = (nr >> p->shift) & CARDMAP_MASK;
 		if (p->ptr[i] == NULL) {
-			struct cardmap *np = kmalloc(sizeof(*np), GFP_KERNEL);
-			memset(np, 0, sizeof(*np));
+			struct cardmap *np = kzalloc(sizeof(*np), GFP_KERNEL);
 			np->shift = p->shift - CARDMAP_ORDER;
 			np->parent = p;
 			p->ptr[i] = np;
--- linux-2.6.16-rc5-mm1/drivers/net/lance.c.orig	2006-03-02 14:48:31.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/lance.c	2006-03-02 14:48:47.000000000 +0100
@@ -532,11 +532,10 @@ static int __init lance_probe1(struct ne
 	dev->base_addr = ioaddr;
 	/* Make certain the data structures used by the LANCE are aligned and DMAble. */
 		
-	lp = kmalloc(sizeof(*lp), GFP_DMA | GFP_KERNEL);
+	lp = kzalloc(sizeof(*lp), GFP_DMA | GFP_KERNEL);
 	if(lp==NULL)
 		return -ENODEV;
 	if (lance_debug > 6) printk(" (#0x%05lx)", (unsigned long)lp);
-	memset(lp, 0, sizeof(*lp));
 	dev->priv = lp;
 	lp->name = chipname;
 	lp->rx_buffs = (unsigned long)kmalloc(PKT_BUF_SZ*RX_RING_SIZE,
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/prism54/oid_mgt.c.orig	2006-03-02 14:49:34.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/prism54/oid_mgt.c	2006-03-02 14:50:29.000000000 +0100
@@ -235,12 +235,10 @@ mgt_init(islpci_private *priv)
 {
 	int i;
 
-	priv->mib = kmalloc(OID_NUM_LAST * sizeof (void *), GFP_KERNEL);
+	priv->mib = kzalloc(OID_NUM_LAST * sizeof(void *), GFP_KERNEL);
 	if (!priv->mib)
 		return -ENOMEM;
 
-	memset(priv->mib, 0, OID_NUM_LAST * sizeof (void *));
-
 	/* Alloc the cache */
 	for (i = 0; i < OID_NUM_LAST; i++) {
 		if (isl_oid[i].flags & OID_FLAG_CACHED) {
@@ -564,11 +562,9 @@ mgt_get_request(islpci_private *priv, en
 	if ((isl_oid[n].flags & OID_FLAG_TYPE) == OID_TYPE_U32)
 		res->u = ret ? 0 : le32_to_cpu(*(u32 *) _res);
 	else {
-		res->ptr = kmalloc(reslen, GFP_KERNEL);
+		res->ptr = kzalloc(reslen, GFP_KERNEL);
 		BUG_ON(res->ptr == NULL);
-		if (ret)
-			memset(res->ptr, 0, reslen);
-		else {
+		if (!ret) {
 			memcpy(res->ptr, _res, reslen);
 			mgt_le_to_cpu(isl_oid[n].flags & OID_FLAG_TYPE,
 				      res->ptr);
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/prism54/isl_ioctl.c.orig	2006-03-02 14:50:39.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/prism54/isl_ioctl.c	2006-03-02 14:51:16.000000000 +0100
@@ -1621,11 +1621,9 @@ prism54_wpa_ie_add(islpci_private *priv,
 					 struct islpci_bss_wpa_ie, list);
 			list_del(&bss->list);
 		} else {
-			bss = kmalloc(sizeof (*bss), GFP_ATOMIC);
-			if (bss != NULL) {
+			bss = kzalloc(sizeof (*bss), GFP_ATOMIC);
+			if (bss != NULL)
 				priv->num_bss_wpa++;
-				memset(bss, 0, sizeof (*bss));
-			}
 		}
 		if (bss != NULL) {
 			memcpy(bss->bssid, bssid, ETH_ALEN);
@@ -2165,11 +2163,10 @@ prism2_ioctl_set_generic_element(struct 
                return -EINVAL;
 
        alen = sizeof(*attach) + len;
-       attach = kmalloc(alen, GFP_KERNEL);
+       attach = kzalloc(alen, GFP_KERNEL);
        if (attach == NULL)
                return -ENOMEM;
 
-       memset(attach, 0, alen);
 #define WLAN_FC_TYPE_MGMT 0
 #define WLAN_FC_STYPE_ASSOC_REQ 0
 #define WLAN_FC_STYPE_REASSOC_REQ 2
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_ioctl.c.orig	2006-03-02 14:51:35.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_ioctl.c	2006-03-02 14:53:22.000000000 +0100
@@ -181,12 +181,10 @@ static int prism2_ioctl_siwencode(struct
 		struct ieee80211_crypt_data *new_crypt;
 
 		/* take WEP into use */
-		new_crypt = (struct ieee80211_crypt_data *)
-			kmalloc(sizeof(struct ieee80211_crypt_data),
+		new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
 				GFP_KERNEL);
 		if (new_crypt == NULL)
 			return -ENOMEM;
-		memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
 		new_crypt->ops = ieee80211_get_crypto_ops("WEP");
 		if (!new_crypt->ops) {
 			request_module("ieee80211_crypt_wep");
@@ -3320,14 +3318,12 @@ static int prism2_ioctl_siwencodeext(str
 
 		prism2_crypt_delayed_deinit(local, crypt);
 
-		new_crypt = (struct ieee80211_crypt_data *)
-			kmalloc(sizeof(struct ieee80211_crypt_data),
+		new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
 				GFP_KERNEL);
 		if (new_crypt == NULL) {
 			ret = -ENOMEM;
 			goto done;
 		}
-		memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
 		new_crypt->ops = ops;
 		new_crypt->priv = new_crypt->ops->init(i);
 		if (new_crypt->priv == NULL) {
@@ -3542,14 +3538,12 @@ static int prism2_ioctl_set_encryption(l
 
 		prism2_crypt_delayed_deinit(local, crypt);
 
-		new_crypt = (struct ieee80211_crypt_data *)
-			kmalloc(sizeof(struct ieee80211_crypt_data),
+		new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
 				GFP_KERNEL);
 		if (new_crypt == NULL) {
 			ret = -ENOMEM;
 			goto done;
 		}
-		memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
 		new_crypt->ops = ops;
 		new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx);
 		if (new_crypt->priv == NULL) {
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_ap.c.orig	2006-03-02 14:53:34.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_ap.c	2006-03-02 14:54:13.000000000 +0100
@@ -1099,15 +1099,13 @@ static struct sta_info * ap_add_sta(stru
 {
 	struct sta_info *sta;
 
-	sta = (struct sta_info *)
-		kmalloc(sizeof(struct sta_info), GFP_ATOMIC);
+	sta = kzalloc(sizeof(struct sta_info), GFP_ATOMIC);
 	if (sta == NULL) {
 		PDEBUG(DEBUG_AP, "AP: kmalloc failed\n");
 		return NULL;
 	}
 
 	/* initialize STA info data */
-	memset(sta, 0, sizeof(struct sta_info));
 	sta->local = ap->local;
 	skb_queue_head_init(&sta->tx_buf);
 	memcpy(sta->addr, addr, ETH_ALEN);
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_cs.c.orig	2006-03-02 14:54:19.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_cs.c	2006-03-02 14:54:35.000000000 +0100
@@ -567,14 +567,13 @@ static int prism2_config(struct pcmcia_d
 	PDEBUG(DEBUG_FLOW, "prism2_config()\n");
 
 	parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
-	hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
+	hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
 	if (parse == NULL || hw_priv == NULL) {
 		kfree(parse);
 		kfree(hw_priv);
 		ret = -ENOMEM;
 		goto failed;
 	}
-	memset(hw_priv, 0, sizeof(*hw_priv));
 
 	tuple.DesiredTuple = CISTPL_CONFIG;
 	tuple.Attributes = 0;
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_info.c.orig	2006-03-02 14:54:42.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_info.c	2006-03-02 14:54:59.000000000 +0100
@@ -327,11 +327,10 @@ static void prism2_info_hostscanresults(
 	ptr = (u8 *) pos;
 
 	new_count = left / result_size;
-	results = kmalloc(new_count * sizeof(struct hfa384x_hostscan_result),
+	results = kcalloc(new_count, sizeof(struct hfa384x_hostscan_result),
 			  GFP_ATOMIC);
 	if (results == NULL)
 		return;
-	memset(results, 0, new_count * sizeof(struct hfa384x_hostscan_result));
 
 	for (i = 0; i < new_count; i++) {
 		memcpy(&results[i], ptr, copy_len);
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_pci.c.orig	2006-03-02 14:55:47.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_pci.c	2006-03-02 14:55:58.000000000 +0100
@@ -301,10 +301,9 @@ static int prism2_pci_probe(struct pci_d
 	struct hostap_interface *iface;
 	struct hostap_pci_priv *hw_priv;
 
-	hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
+	hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
 	if (hw_priv == NULL)
 		return -ENOMEM;
-	memset(hw_priv, 0, sizeof(*hw_priv));
 
 	if (pci_enable_device(pdev))
 		return -EIO;
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_hw.c.orig	2006-03-02 14:56:05.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_hw.c	2006-03-02 14:56:54.000000000 +0100
@@ -348,14 +348,12 @@ static int hfa384x_cmd(struct net_device
 	if (signal_pending(current))
 		return -EINTR;
 
-	entry = (struct hostap_cmd_queue *)
-		kmalloc(sizeof(*entry), GFP_ATOMIC);
+	entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
 	if (entry == NULL) {
 		printk(KERN_DEBUG "%s: hfa384x_cmd - kmalloc failed\n",
 		       dev->name);
 		return -ENOMEM;
 	}
-	memset(entry, 0, sizeof(*entry));
 	atomic_set(&entry->usecnt, 1);
 	entry->type = CMD_SLEEP;
 	entry->cmd = cmd;
@@ -518,14 +516,12 @@ static int hfa384x_cmd_callback(struct n
 		return -1;
 	}
 
-	entry = (struct hostap_cmd_queue *)
-		kmalloc(sizeof(*entry), GFP_ATOMIC);
+	entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
 	if (entry == NULL) {
 		printk(KERN_DEBUG "%s: hfa384x_cmd_callback - kmalloc "
 		       "failed\n", dev->name);
 		return -ENOMEM;
 	}
-	memset(entry, 0, sizeof(*entry));
 	atomic_set(&entry->usecnt, 1);
 	entry->type = CMD_CALLBACK;
 	entry->cmd = cmd;
@@ -3013,14 +3009,12 @@ static int prism2_set_tim(struct net_dev
 	iface = netdev_priv(dev);
 	local = iface->local;
 
-	new_entry = (struct set_tim_data *)
-		kmalloc(sizeof(*new_entry), GFP_ATOMIC);
+	new_entry = kzalloc(sizeof(*new_entry), GFP_ATOMIC);
 	if (new_entry == NULL) {
 		printk(KERN_DEBUG "%s: prism2_set_tim: kmalloc failed\n",
 		       local->dev->name);
 		return -ENOMEM;
 	}
-	memset(new_entry, 0, sizeof(*new_entry));
 	new_entry->aid = aid;
 	new_entry->set = set;
 
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_plx.c.orig	2006-03-02 14:57:02.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_plx.c	2006-03-02 14:57:11.000000000 +0100
@@ -446,10 +446,9 @@ static int prism2_plx_probe(struct pci_d
 	int tmd7160;
 	struct hostap_plx_priv *hw_priv;
 
-	hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
+	hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
 	if (hw_priv == NULL)
 		return -ENOMEM;
-	memset(hw_priv, 0, sizeof(*hw_priv));
 
 	if (pci_enable_device(pdev))
 		return -EIO;
--- linux-2.6.16-rc5-mm1/drivers/net/e100.c.orig	2006-03-02 14:57:25.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/e100.c	2006-03-02 14:57:41.000000000 +0100
@@ -1882,9 +1882,8 @@ static int e100_rx_alloc_list(struct nic
 
 	nic->rx_to_use = nic->rx_to_clean = NULL;
 
-	if(!(nic->rxs = kmalloc(sizeof(struct rx) * count, GFP_ATOMIC)))
+	if(!(nic->rxs = kcalloc(count, sizeof(struct rx), GFP_ATOMIC)))
 		return -ENOMEM;
-	memset(nic->rxs, 0, sizeof(struct rx) * count);
 
 	for(rx = nic->rxs, i = 0; i < count; rx++, i++) {
 		rx->next = (i + 1 < count) ? rx + 1 : nic->rxs;
--- linux-2.6.16-rc5-mm1/drivers/net/s2io.c.orig	2006-03-02 14:57:50.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/s2io.c	2006-03-02 14:58:42.000000000 +0100
@@ -407,14 +407,13 @@ static int init_shared_mem(struct s2io_n
 	for (i = 0; i < config->tx_fifo_num; i++) {
 		int fifo_len = config->tx_cfg[i].fifo_len;
 		int list_holder_size = fifo_len * sizeof(list_info_hold_t);
-		mac_control->fifos[i].list_info = kmalloc(list_holder_size,
+		mac_control->fifos[i].list_info = kzalloc(list_holder_size,
 							  GFP_KERNEL);
 		if (!mac_control->fifos[i].list_info) {
 			DBG_PRINT(ERR_DBG,
 				  "Malloc failed for list_info\n");
 			return -ENOMEM;
 		}
-		memset(mac_control->fifos[i].list_info, 0, list_holder_size);
 	}
 	for (i = 0; i < config->tx_fifo_num; i++) {
 		int page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len,
@@ -3229,24 +3228,21 @@ static int s2io_enable_msi_x(nic_t *nic)
 	u16 msi_control; /* Temp variable */
 	int ret, i, j, msix_indx = 1;
 
-	nic->entries = kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry),
+	nic->entries = kzalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry),
 			       GFP_KERNEL);
 	if (nic->entries == NULL) {
 		DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n", __FUNCTION__);
 		return -ENOMEM;
 	}
-	memset(nic->entries, 0, MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
 
 	nic->s2io_entries =
-		kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry),
+		kzalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry),
 				   GFP_KERNEL);
 	if (nic->s2io_entries == NULL) {
 		DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n", __FUNCTION__);
 		kfree(nic->entries);
 		return -ENOMEM;
 	}
-	memset(nic->s2io_entries, 0,
-	       MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
 
 	for (i=0; i< MAX_REQUESTED_MSI_X; i++) {
 		nic->entries[i].entry = i;



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/net
@ 2006-03-04 17:56   ` Eric Sesterhenn
  0 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-04 17:56 UTC (permalink / raw)
  To: kernel-janitors; +Cc: netdev

[-- Attachment #1: Type: text/plain, Size: 42367 bytes --]

hi,

this patch converts drivers/net to kzalloc usage.
Compile tested with allyes config.

It also fixes a bug in drivers/net/chelsio/espi.c, because
it called the memset() before checking if kmalloc failed.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/net/e1000/e1000_ethtool.c.orig	2006-03-02 14:24:18.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/e1000/e1000_ethtool.c	2006-03-02 14:24:59.000000000 +0100
@@ -638,20 +638,18 @@ e1000_set_ringparam(struct net_device *n
 	tx_old = adapter->tx_ring;
 	rx_old = adapter->rx_ring;
 
-	adapter->tx_ring = kmalloc(tx_ring_size, GFP_KERNEL);
+	adapter->tx_ring = kzalloc(tx_ring_size, GFP_KERNEL);
 	if (!adapter->tx_ring) {
 		err = -ENOMEM;
 		goto err_setup_rx;
 	}
-	memset(adapter->tx_ring, 0, tx_ring_size);
 
-	adapter->rx_ring = kmalloc(rx_ring_size, GFP_KERNEL);
+	adapter->rx_ring = kzalloc(rx_ring_size, GFP_KERNEL);
 	if (!adapter->rx_ring) {
 		kfree(adapter->tx_ring);
 		err = -ENOMEM;
 		goto err_setup_rx;
 	}
-	memset(adapter->rx_ring, 0, rx_ring_size);
 
 	txdr = adapter->tx_ring;
 	rxdr = adapter->rx_ring;
@@ -1017,11 +1015,10 @@ e1000_setup_desc_rings(struct e1000_adap
 		txdr->count = E1000_DEFAULT_TXD;
 
 	size = txdr->count * sizeof(struct e1000_buffer);
-	if (!(txdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
+	if (!(txdr->buffer_info = kzalloc(size, GFP_KERNEL))) {
 		ret_val = 1;
 		goto err_nomem;
 	}
-	memset(txdr->buffer_info, 0, size);
 
 	txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
 	E1000_ROUNDUP(txdr->size, 4096);
@@ -1073,11 +1070,10 @@ e1000_setup_desc_rings(struct e1000_adap
 		rxdr->count = E1000_DEFAULT_RXD;
 
 	size = rxdr->count * sizeof(struct e1000_buffer);
-	if (!(rxdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
+	if (!(rxdr->buffer_info = kzalloc(size, GFP_KERNEL))) {
 		ret_val = 4;
 		goto err_nomem;
 	}
-	memset(rxdr->buffer_info, 0, size);
 
 	rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc);
 	if (!(rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma))) {
--- linux-2.6.16-rc5-mm1/drivers/net/e1000/e1000_main.c.orig	2006-03-02 14:25:05.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/e1000/e1000_main.c	2006-03-02 14:26:09.000000000 +0100
@@ -1114,28 +1114,25 @@ e1000_alloc_queues(struct e1000_adapter 
 	int size;
 
 	size = sizeof(struct e1000_tx_ring) * adapter->num_tx_queues;
-	adapter->tx_ring = kmalloc(size, GFP_KERNEL);
+	adapter->tx_ring = kzalloc(size, GFP_KERNEL);
 	if (!adapter->tx_ring)
 		return -ENOMEM;
-	memset(adapter->tx_ring, 0, size);
 
 	size = sizeof(struct e1000_rx_ring) * adapter->num_rx_queues;
-	adapter->rx_ring = kmalloc(size, GFP_KERNEL);
+	adapter->rx_ring = kzalloc(size, GFP_KERNEL);
 	if (!adapter->rx_ring) {
 		kfree(adapter->tx_ring);
 		return -ENOMEM;
 	}
-	memset(adapter->rx_ring, 0, size);
 
 #ifdef CONFIG_E1000_NAPI
 	size = sizeof(struct net_device) * adapter->num_rx_queues;
-	adapter->polling_netdev = kmalloc(size, GFP_KERNEL);
+	adapter->polling_netdev = kzalloc(size, GFP_KERNEL);
 	if (!adapter->polling_netdev) {
 		kfree(adapter->tx_ring);
 		kfree(adapter->rx_ring);
 		return -ENOMEM;
 	}
-	memset(adapter->polling_netdev, 0, size);
 #endif
 
 #ifdef CONFIG_E1000_MQ
@@ -1544,17 +1541,16 @@ e1000_setup_rx_resources(struct e1000_ad
 	memset(rxdr->buffer_info, 0, size);
 
 	size = sizeof(struct e1000_ps_page) * rxdr->count;
-	rxdr->ps_page = kmalloc(size, GFP_KERNEL);
+	rxdr->ps_page = kzalloc(size, GFP_KERNEL);
 	if (!rxdr->ps_page) {
 		vfree(rxdr->buffer_info);
 		DPRINTK(PROBE, ERR,
 		"Unable to allocate memory for the receive descriptor ring\n");
 		return -ENOMEM;
 	}
-	memset(rxdr->ps_page, 0, size);
 
 	size = sizeof(struct e1000_ps_page_dma) * rxdr->count;
-	rxdr->ps_page_dma = kmalloc(size, GFP_KERNEL);
+	rxdr->ps_page_dma = kzalloc(size, GFP_KERNEL);
 	if (!rxdr->ps_page_dma) {
 		vfree(rxdr->buffer_info);
 		kfree(rxdr->ps_page);
@@ -1562,7 +1558,6 @@ e1000_setup_rx_resources(struct e1000_ad
 		"Unable to allocate memory for the receive descriptor ring\n");
 		return -ENOMEM;
 	}
-	memset(rxdr->ps_page_dma, 0, size);
 
 	if (adapter->hw.mac_type <= e1000_82547_rev_2)
 		desc_len = sizeof(struct e1000_rx_desc);
--- linux-2.6.16-rc5-mm1/drivers/net/pcmcia/ibmtr_cs.c.orig	2006-03-02 14:26:19.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/pcmcia/ibmtr_cs.c	2006-03-02 14:26:28.000000000 +0100
@@ -146,9 +146,8 @@ static int ibmtr_attach(struct pcmcia_de
     DEBUG(0, "ibmtr_attach()\n");
 
     /* Create new token-ring device */
-    info = kmalloc(sizeof(*info), GFP_KERNEL); 
+    info = kzalloc(sizeof(*info), GFP_KERNEL); 
     if (!info) return -ENOMEM;
-    memset(info,0,sizeof(*info));
     dev = alloc_trdev(sizeof(struct tok_info));
     if (!dev) {
 	kfree(info);
--- linux-2.6.16-rc5-mm1/drivers/net/slhc.c.orig	2006-03-02 14:26:39.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/slhc.c	2006-03-02 14:27:11.000000000 +0100
@@ -95,27 +95,23 @@ slhc_init(int rslots, int tslots)
 	register struct cstate *ts;
 	struct slcompress *comp;
 
-	comp = (struct slcompress *)kmalloc(sizeof(struct slcompress),
-					    GFP_KERNEL);
+	comp = kzalloc(sizeof(struct slcompress), GFP_KERNEL);
 	if (! comp)
 		goto out_fail;
-	memset(comp, 0, sizeof(struct slcompress));
 
 	if ( rslots > 0  &&  rslots < 256 ) {
 		size_t rsize = rslots * sizeof(struct cstate);
-		comp->rstate = (struct cstate *) kmalloc(rsize, GFP_KERNEL);
+		comp->rstate = kzalloc(rsize, GFP_KERNEL);
 		if (! comp->rstate)
 			goto out_free;
-		memset(comp->rstate, 0, rsize);
 		comp->rslot_limit = rslots - 1;
 	}
 
 	if ( tslots > 0  &&  tslots < 256 ) {
 		size_t tsize = tslots * sizeof(struct cstate);
-		comp->tstate = (struct cstate *) kmalloc(tsize, GFP_KERNEL);
+		comp->tstate = kzalloc(tsize, GFP_KERNEL);
 		if (! comp->tstate)
 			goto out_free2;
-		memset(comp->tstate, 0, tsize);
 		comp->tslot_limit = tslots - 1;
 	}
 
--- linux-2.6.16-rc5-mm1/drivers/net/sb1250-mac.c.orig	2006-03-02 14:27:18.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/sb1250-mac.c	2006-03-02 14:27:35.000000000 +0100
@@ -743,9 +743,7 @@ static void sbdma_initctx(sbmacdma_t *d,
 	 */
 
 	d->sbdma_ctxtable = (struct sk_buff **)
-		kmalloc(d->sbdma_maxdescr*sizeof(struct sk_buff *), GFP_KERNEL);
-
-	memset(d->sbdma_ctxtable,0,d->sbdma_maxdescr*sizeof(struct sk_buff *));
+		kzalloc(d->sbdma_maxdescr*sizeof(struct sk_buff *), GFP_KERNEL);
 
 #ifdef CONFIG_SBMAC_COALESCE
 	/*
--- linux-2.6.16-rc5-mm1/drivers/net/ppp_async.c.orig	2006-03-02 14:27:44.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/ppp_async.c	2006-03-02 14:27:52.000000000 +0100
@@ -159,12 +159,11 @@ ppp_asynctty_open(struct tty_struct *tty
 	int err;
 
 	err = -ENOMEM;
-	ap = kmalloc(sizeof(*ap), GFP_KERNEL);
+	ap = kzalloc(sizeof(*ap), GFP_KERNEL);
 	if (ap == 0)
 		goto out;
 
 	/* initialize the asyncppp structure */
-	memset(ap, 0, sizeof(*ap));
 	ap->tty = tty;
 	ap->mru = PPP_MRU;
 	spin_lock_init(&ap->xmit_lock);
--- linux-2.6.16-rc5-mm1/drivers/net/loopback.c.orig	2006-03-02 14:28:00.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/loopback.c	2006-03-02 14:28:13.000000000 +0100
@@ -224,9 +224,8 @@ int __init loopback_init(void)
 	struct net_device_stats *stats;
 
 	/* Can survive without statistics */
-	stats = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
+	stats = kzalloc(sizeof(struct net_device_stats), GFP_KERNEL);
 	if (stats) {
-		memset(stats, 0, sizeof(struct net_device_stats));
 		loopback_dev.priv = stats;
 		loopback_dev.get_stats = &get_stats;
 	}
--- linux-2.6.16-rc5-mm1/drivers/net/bnx2.c.orig	2006-03-02 14:28:26.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/bnx2.c	2006-03-02 14:29:22.000000000 +0100
@@ -397,12 +397,11 @@ bnx2_alloc_mem(struct bnx2 *bp)
 {
 	int i;
 
-	bp->tx_buf_ring = kmalloc(sizeof(struct sw_bd) * TX_DESC_CNT,
+	bp->tx_buf_ring = kzalloc(sizeof(struct sw_bd) * TX_DESC_CNT,
 				     GFP_KERNEL);
 	if (bp->tx_buf_ring == NULL)
 		return -ENOMEM;
 
-	memset(bp->tx_buf_ring, 0, sizeof(struct sw_bd) * TX_DESC_CNT);
 	bp->tx_desc_ring = pci_alloc_consistent(bp->pdev,
 					        sizeof(struct tx_bd) *
 						TX_DESC_CNT,
--- linux-2.6.16-rc5-mm1/drivers/net/ppp_deflate.c.orig	2006-03-02 14:29:33.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/ppp_deflate.c	2006-03-02 14:30:00.000000000 +0100
@@ -121,12 +121,10 @@ static void *z_comp_alloc(unsigned char 
 	if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
 		return NULL;
 
-	state = (struct ppp_deflate_state *) kmalloc(sizeof(*state),
-						     GFP_KERNEL);
+	state = kzalloc(sizeof(*state), GFP_KERNEL);
 	if (state == NULL)
 		return NULL;
 
-	memset (state, 0, sizeof (struct ppp_deflate_state));
 	state->strm.next_in   = NULL;
 	state->w_size         = w_size;
 	state->strm.workspace = vmalloc(zlib_deflate_workspacesize());
@@ -341,11 +339,10 @@ static void *z_decomp_alloc(unsigned cha
 	if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
 		return NULL;
 
-	state = (struct ppp_deflate_state *) kmalloc(sizeof(*state), GFP_KERNEL);
+	state = kzalloc(sizeof(*state), GFP_KERNEL);
 	if (state == NULL)
 		return NULL;
 
-	memset (state, 0, sizeof (struct ppp_deflate_state));
 	state->w_size         = w_size;
 	state->strm.next_out  = NULL;
 	state->strm.workspace = kmalloc(zlib_inflate_workspacesize(),
--- linux-2.6.16-rc5-mm1/drivers/net/iseries_veth.c.orig	2006-03-02 14:30:09.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/iseries_veth.c	2006-03-02 14:30:43.000000000 +0100
@@ -820,10 +820,9 @@ static int veth_init_connection(u8 rlp)
 	     || ! HvLpConfig_doLpsCommunicateOnVirtualLan(this_lp, rlp) )
 		return 0;
 
-	cnx = kmalloc(sizeof(*cnx), GFP_KERNEL);
+	cnx = kzalloc(sizeof(*cnx), GFP_KERNEL);
 	if (! cnx)
 		return -ENOMEM;
-	memset(cnx, 0, sizeof(*cnx));
 
 	cnx->remote_lp = rlp;
 	spin_lock_init(&cnx->lock);
@@ -850,14 +849,13 @@ static int veth_init_connection(u8 rlp)
 	if (rc != 0)
 		return rc;
 
-	msgs = kmalloc(VETH_NUMBUFFERS * sizeof(struct veth_msg), GFP_KERNEL);
+	msgs = kzalloc(VETH_NUMBUFFERS * sizeof(struct veth_msg), GFP_KERNEL);
 	if (! msgs) {
 		veth_error("Can't allocate buffers for LPAR %d.\n", rlp);
 		return -ENOMEM;
 	}
 
 	cnx->msgs = msgs;
-	memset(msgs, 0, VETH_NUMBUFFERS * sizeof(struct veth_msg));
 
 	for (i = 0; i < VETH_NUMBUFFERS; i++) {
 		msgs[i].token = i;
--- linux-2.6.16-rc5-mm1/drivers/net/via-velocity.c.orig	2006-03-02 14:30:54.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/via-velocity.c	2006-03-02 14:31:24.000000000 +0100
@@ -1072,10 +1072,9 @@ static int velocity_init_rd_ring(struct 
 	unsigned int rsize = sizeof(struct velocity_rd_info) * 
 					vptr->options.numrx;
 
-	vptr->rd_info = kmalloc(rsize, GFP_KERNEL);
+	vptr->rd_info = kzalloc(rsize, GFP_KERNEL);
 	if(vptr->rd_info == NULL)
 		goto out;
-	memset(vptr->rd_info, 0, rsize);
 
 	vptr->rd_filled = vptr->rd_dirty = vptr->rd_curr = 0;
 
@@ -1146,14 +1145,13 @@ static int velocity_init_td_ring(struct 
 	for (j = 0; j < vptr->num_txq; j++) {
 		curr = vptr->td_pool_dma[j];
 
-		vptr->td_infos[j] = kmalloc(tsize, GFP_KERNEL);
+		vptr->td_infos[j] = kzalloc(tsize, GFP_KERNEL);
 		if(vptr->td_infos[j] == NULL)
 		{
 			while(--j >= 0)
 				kfree(vptr->td_infos[j]);
 			return -ENOMEM;
 		}
-		memset(vptr->td_infos[j], 0, tsize);
 
 		for (i = 0; i < vptr->options.numtx; i++, curr += sizeof(struct tx_desc)) {
 			td = &(vptr->td_rings[j][i]);
--- linux-2.6.16-rc5-mm1/drivers/net/pcnet32.c.orig	2006-03-02 14:31:32.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/pcnet32.c	2006-03-02 15:04:10.000000000 +0100
@@ -1480,41 +1480,37 @@ static int pcnet32_alloc_ring(struct net
 	return -ENOMEM;
     }
 
-    lp->tx_dma_addr = kmalloc(sizeof(dma_addr_t) * lp->tx_ring_size,
+    lp->tx_dma_addr = kcalloc(lp->tx_ring_size, sizeof(dma_addr_t),
 	    GFP_ATOMIC);
     if (!lp->tx_dma_addr) {
 	if (pcnet32_debug & NETIF_MSG_DRV)
 	    printk("\n" KERN_ERR PFX "%s: Memory allocation failed.\n", name);
 	return -ENOMEM;
     }
-    memset(lp->tx_dma_addr, 0, sizeof(dma_addr_t) * lp->tx_ring_size);
 
-    lp->rx_dma_addr = kmalloc(sizeof(dma_addr_t) * lp->rx_ring_size,
+    lp->rx_dma_addr = kcalloc(lp->rx_ring_size, sizeof(dma_addr_t),
 	    GFP_ATOMIC);
     if (!lp->rx_dma_addr) {
 	if (pcnet32_debug & NETIF_MSG_DRV)
 	    printk("\n" KERN_ERR PFX "%s: Memory allocation failed.\n", name);
 	return -ENOMEM;
     }
-    memset(lp->rx_dma_addr, 0, sizeof(dma_addr_t) * lp->rx_ring_size);
 
-    lp->tx_skbuff = kmalloc(sizeof(struct sk_buff *) * lp->tx_ring_size,
+    lp->tx_skbuff = kcalloc(lp->tx_ring_size, sizeof(struct sk_buff *),
 	    GFP_ATOMIC);
     if (!lp->tx_skbuff) {
 	if (pcnet32_debug & NETIF_MSG_DRV)
 	    printk("\n" KERN_ERR PFX "%s: Memory allocation failed.\n", name);
 	return -ENOMEM;
     }
-    memset(lp->tx_skbuff, 0, sizeof(struct sk_buff *) * lp->tx_ring_size);
 
-    lp->rx_skbuff = kmalloc(sizeof(struct sk_buff *) * lp->rx_ring_size,
+    lp->rx_skbuff = kcalloc(lp->rx_ring_size, sizeof(struct sk_buff *),
 	    GFP_ATOMIC);
     if (!lp->rx_skbuff) {
 	if (pcnet32_debug & NETIF_MSG_DRV)
 	    printk("\n" KERN_ERR PFX "%s: Memory allocation failed.\n", name);
 	return -ENOMEM;
     }
-    memset(lp->rx_skbuff, 0, sizeof(struct sk_buff *) * lp->rx_ring_size);
 
     return 0;
 }
--- linux-2.6.16-rc5-mm1/drivers/net/fs_enet/fs_enet-mii.c.orig	2006-03-02 14:33:53.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/fs_enet/fs_enet-mii.c	2006-03-02 14:34:01.000000000 +0100
@@ -389,12 +389,11 @@ static struct fs_enet_mii_bus *create_bu
 	struct fs_enet_mii_bus *bus;
 	int ret = 0;
 
-	bus = kmalloc(sizeof(*bus), GFP_KERNEL);
+	bus = kzalloc(sizeof(*bus), GFP_KERNEL);
 	if (bus == NULL) {
 		ret = -ENOMEM;
 		goto err;
 	}
-	memset(bus, 0, sizeof(*bus));
 	spin_lock_init(&bus->mii_lock);
 	bus->bus_info = bi;
 	bus->refs = 0;
--- linux-2.6.16-rc5-mm1/drivers/net/ppp_mppe.c.orig	2006-03-02 14:34:21.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/ppp_mppe.c	2006-03-02 14:34:35.000000000 +0100
@@ -191,12 +191,10 @@ static void *mppe_alloc(unsigned char *o
 	    || options[0] != CI_MPPE || options[1] != CILEN_MPPE)
 		goto out;
 
-	state = (struct ppp_mppe_state *) kmalloc(sizeof(*state), GFP_KERNEL);
+	state = kzalloc(sizeof(*state), GFP_KERNEL);
 	if (state == NULL)
 		goto out;
 
-	memset(state, 0, sizeof(*state));
-
 	state->arc4 = crypto_alloc_tfm("arc4", 0);
 	if (!state->arc4)
 		goto out_free;
--- linux-2.6.16-rc5-mm1/drivers/net/irda/irtty-sir.c.orig	2006-03-02 14:34:51.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/irda/irtty-sir.c	2006-03-02 14:35:01.000000000 +0100
@@ -505,10 +505,9 @@ static int irtty_open(struct tty_struct 
 	}
 
 	/* allocate private device info block */
-	priv = kmalloc(sizeof(*priv), GFP_KERNEL);
+	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		goto out_put;
-	memset(priv, 0, sizeof(*priv));
 
 	priv->magic = IRTTY_MAGIC;
 	priv->tty = tty;
--- linux-2.6.16-rc5-mm1/drivers/net/irda/irda-usb.c.orig	2006-03-02 14:35:49.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/irda/irda-usb.c	2006-03-02 14:36:12.000000000 +0100
@@ -1343,10 +1343,9 @@ static inline struct irda_class_desc *ir
 	struct irda_class_desc *desc;
 	int ret;
 
-	desc = kmalloc(sizeof (*desc), GFP_KERNEL);
+	desc = kzalloc(sizeof (*desc), GFP_KERNEL);
 	if (desc == NULL) 
 		return NULL;
-	memset(desc, 0, sizeof(*desc));
 
 	/* USB-IrDA class spec 1.0:
 	 *	6.1.3: Standard "Get Descriptor" Device Request is not
@@ -1495,12 +1494,10 @@ static int irda_usb_probe(struct usb_int
 	/* Don't change this buffer size and allocation without doing
 	 * some heavy and complete testing. Don't ask why :-(
 	 * Jean II */
-	self->speed_buff = (char *) kmalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL);
+	self->speed_buff = kzalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL);
 	if (self->speed_buff == NULL) 
 		goto err_out_3;
 
-	memset(self->speed_buff, 0, IRDA_USB_SPEED_MTU);
-
 	ret = irda_usb_open(self);
 	if (ret) 
 		goto err_out_4;
--- linux-2.6.16-rc5-mm1/drivers/net/chelsio/sge.c.orig	2006-03-02 14:36:45.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/chelsio/sge.c	2006-03-02 14:37:23.000000000 +0100
@@ -336,10 +336,9 @@ static int alloc_rx_resources(struct sge
 			goto err_no_mem;
 		memset(q->entries, 0, size);
 		size = sizeof(struct freelQ_ce) * q->size;
-		q->centries = kmalloc(size, GFP_KERNEL);
+		q->centries = kzalloc(size, GFP_KERNEL);
 		if (!q->centries)
 			goto err_no_mem;
-		memset(q->centries, 0, size);
 	}
 
 	/*
@@ -464,10 +463,9 @@ static int alloc_tx_resources(struct sge
 			goto err_no_mem;
 		memset(q->entries, 0, size);
 		size = sizeof(struct cmdQ_ce) * q->size;
-		q->centries = kmalloc(size, GFP_KERNEL);
+		q->centries = kzalloc(size, GFP_KERNEL);
 		if (!q->centries)
 			goto err_no_mem;
-		memset(q->centries, 0, size);
 	}
 
 	/*
@@ -1649,11 +1647,10 @@ static void espibug_workaround(void *dat
 struct sge * __devinit t1_sge_create(struct adapter *adapter,
 				     struct sge_params *p)
 {
-	struct sge *sge = kmalloc(sizeof(*sge), GFP_KERNEL);
+	struct sge *sge = kzalloc(sizeof(*sge), GFP_KERNEL);
 
 	if (!sge)
 		return NULL;
-	memset(sge, 0, sizeof(*sge));
 
 	sge->adapter = adapter;
 	sge->netdev = adapter->port[0].dev;
--- linux-2.6.16-rc5-mm1/drivers/net/chelsio/espi.c.orig	2006-03-02 14:37:51.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/chelsio/espi.c	2006-03-02 14:38:49.000000000 +0100
@@ -296,9 +296,7 @@ void t1_espi_destroy(struct peespi *espi
 
 struct peespi *t1_espi_create(adapter_t *adapter)
 {
-	struct peespi *espi = kmalloc(sizeof(*espi), GFP_KERNEL);
-
-	memset(espi, 0, sizeof(*espi));
+	struct peespi *espi = kzalloc(sizeof(*espi), GFP_KERNEL);
 
 	if (espi)
 		espi->adapter = adapter;
--- linux-2.6.16-rc5-mm1/drivers/net/chelsio/mv88x201x.c.orig	2006-03-02 14:38:57.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/chelsio/mv88x201x.c	2006-03-02 14:39:07.000000000 +0100
@@ -205,11 +205,10 @@ static struct cphy *mv88x201x_phy_create
 					 struct mdio_ops *mdio_ops)
 {
 	u32 val;
-	struct cphy *cphy = kmalloc(sizeof(*cphy), GFP_KERNEL);
+	struct cphy *cphy = kzalloc(sizeof(*cphy), GFP_KERNEL);
 
 	if (!cphy)
 		return NULL;
-	memset(cphy, 0, sizeof(*cphy));
 	cphy_init(cphy, adapter, phy_addr, &mv88x201x_ops, mdio_ops);
 
 	/* Commands the PHY to enable XFP's clock. */
--- linux-2.6.16-rc5-mm1/drivers/net/mipsnet.c.orig	2006-03-02 14:39:19.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/mipsnet.c	2006-03-02 14:39:28.000000000 +0100
@@ -323,12 +323,11 @@ static int __init mipsnet_init_module(vo
 		goto out;
 	}
 
-        if (!(pldev = kmalloc (sizeof (*pldev), GFP_KERNEL))) {
+        if (!(pldev = kzalloc (sizeof (*pldev), GFP_KERNEL))) {
 		err = -ENOMEM;
 		goto out_unregister_driver;
 	}
 
-	memset (pldev, 0, sizeof (*pldev));
 	pldev->name		= mipsnet_string;
 	pldev->id		= 0;
 	pldev->dev.release	= mipsnet_platform_release;
--- linux-2.6.16-rc5-mm1/drivers/net/wan/hdlc_fr.c.orig	2006-03-02 14:40:08.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/hdlc_fr.c	2006-03-02 14:40:23.000000000 +0100
@@ -159,11 +159,10 @@ static inline pvc_device* add_pvc(struct
 		pvc_p = &(*pvc_p)->next;
 	}
 
-	pvc = kmalloc(sizeof(pvc_device), GFP_ATOMIC);
+	pvc = kzalloc(sizeof(pvc_device), GFP_ATOMIC);
 	if (!pvc)
 		return NULL;
 
-	memset(pvc, 0, sizeof(pvc_device));
 	pvc->dlci = dlci;
 	pvc->master = dev;
 	pvc->next = *pvc_p;	/* Put it in the chain */
--- linux-2.6.16-rc5-mm1/drivers/net/wan/sdla_chdlc.c.orig	2006-03-02 14:40:32.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/sdla_chdlc.c	2006-03-02 14:40:52.000000000 +0100
@@ -679,13 +679,11 @@ static int new_if(struct wan_device* wan
 	}
 		
 	/* allocate and initialize private data */
-	chdlc_priv_area = kmalloc(sizeof(chdlc_private_area_t), GFP_KERNEL);
+	chdlc_priv_area = kzalloc(sizeof(chdlc_private_area_t), GFP_KERNEL);
 	
 	if(chdlc_priv_area == NULL) 
 		return -ENOMEM;
 
-	memset(chdlc_priv_area, 0, sizeof(chdlc_private_area_t));
-
 	chdlc_priv_area->card = card; 
 	chdlc_priv_area->common.sk = NULL;
 	chdlc_priv_area->common.func = NULL;	
--- linux-2.6.16-rc5-mm1/drivers/net/wan/hostess_sv11.c.orig	2006-03-02 14:41:05.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/hostess_sv11.c	2006-03-02 14:41:27.000000000 +0100
@@ -231,11 +231,10 @@ static struct sv11_device *sv11_init(int
 		return NULL;
 	}
 	
-	sv=(struct sv11_device *)kmalloc(sizeof(struct sv11_device), GFP_KERNEL);
+	sv=kzalloc(sizeof(struct sv11_device), GFP_KERNEL);
 	if(!sv)
 		goto fail3;
 			
-	memset(sv, 0, sizeof(*sv));
 	sv->if_ptr=&sv->netdev;
 	
 	sv->netdev.dev = alloc_netdev(0, "hdlc%d", sv11_setup);
--- linux-2.6.16-rc5-mm1/drivers/net/wan/sealevel.c.orig	2006-03-02 14:41:34.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/sealevel.c	2006-03-02 14:41:45.000000000 +0100
@@ -270,11 +270,10 @@ static __init struct slvl_board *slvl_in
 		return NULL;
 	}
 	
-	b = kmalloc(sizeof(struct slvl_board), GFP_KERNEL);
+	b = kzalloc(sizeof(struct slvl_board), GFP_KERNEL);
 	if(!b)
 		goto fail3;
 
-	memset(b, 0, sizeof(*b));
 	if (!(b->dev[0]= slvl_alloc(iobase, irq)))
 		goto fail2;
 
--- linux-2.6.16-rc5-mm1/drivers/net/wan/sdla_x25.c.orig	2006-03-02 14:41:55.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/sdla_x25.c	2006-03-02 14:42:43.000000000 +0100
@@ -926,13 +926,11 @@ static int new_if(struct wan_device* wan
 	}
 
 	/* allocate and initialize private data */
-	chan = kmalloc(sizeof(x25_channel_t), GFP_ATOMIC);
+	chan = kzalloc(sizeof(x25_channel_t), GFP_ATOMIC);
 	if (chan == NULL){
 		return -ENOMEM;
 	}
 	
-	memset(chan, 0, sizeof(x25_channel_t));
-
 	/* Bug Fix: Seg Err on PVC startup
 	 * It must be here since bind_lcn_to_dev expects 
 	 * it bellow */
@@ -1194,7 +1192,7 @@ static int if_open(struct net_device* de
 
 	/* Allocate and initialize BH circular buffer */
 	/* Add 1 to MAX_BH_BUFF so we don't have test with (MAX_BH_BUFF-1) */
-	chan->bh_head = kmalloc((sizeof(bh_data_t)*(MAX_BH_BUFF+1)),GFP_ATOMIC);
+	chan->bh_head = kzalloc((sizeof(bh_data_t)*(MAX_BH_BUFF+1)),GFP_ATOMIC);
 
 	if (chan->bh_head == NULL){
 		printk(KERN_INFO "%s: ERROR, failed to allocate memory ! BH_BUFFERS !\n",
@@ -1202,7 +1200,6 @@ static int if_open(struct net_device* de
 
 		return -ENOBUFS;
 	}
-	memset(chan->bh_head,0,(sizeof(bh_data_t)*(MAX_BH_BUFF+1)));
 	atomic_set(&chan->bh_buff_used, 0);
 
 	/* Increment the number of interfaces */
--- linux-2.6.16-rc5-mm1/drivers/net/wan/sdla.c.orig	2006-03-02 14:42:53.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/sdla.c	2006-03-02 14:43:21.000000000 +0100
@@ -1203,10 +1203,9 @@ static int sdla_xfer(struct net_device *
 		
 	if (read)
 	{	
-		temp = kmalloc(mem.len, GFP_KERNEL);
+		temp = kzalloc(mem.len, GFP_KERNEL);
 		if (!temp)
 			return(-ENOMEM);
-		memset(temp, 0, mem.len);
 		sdla_read(dev, mem.addr, temp, mem.len);
 		if(copy_to_user(mem.data, temp, mem.len))
 		{
--- linux-2.6.16-rc5-mm1/drivers/net/wan/cycx_x25.c.orig	2006-03-02 14:43:41.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/cycx_x25.c	2006-03-02 14:44:01.000000000 +0100
@@ -376,11 +376,10 @@ static int cycx_wan_new_if(struct wan_de
 	}
 
 	/* allocate and initialize private data */
-	chan = kmalloc(sizeof(struct cycx_x25_channel), GFP_KERNEL);
+	chan = kzalloc(sizeof(struct cycx_x25_channel), GFP_KERNEL);
 	if (!chan)
 		return -ENOMEM;
 
-	memset(chan, 0, sizeof(*chan));
 	strcpy(chan->name, conf->name);
 	chan->card = card;
 	chan->link = conf->port;
--- linux-2.6.16-rc5-mm1/drivers/net/wan/c101.c.orig	2006-03-02 14:44:08.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/c101.c	2006-03-02 14:44:17.000000000 +0100
@@ -309,12 +309,11 @@ static int __init c101_run(unsigned long
 		return -ENODEV;
 	}
 
-	card = kmalloc(sizeof(card_t), GFP_KERNEL);
+	card = kzalloc(sizeof(card_t), GFP_KERNEL);
 	if (card == NULL) {
 		printk(KERN_ERR "c101: unable to allocate memory\n");
 		return -ENOBUFS;
 	}
-	memset(card, 0, sizeof(card_t));
 
 	card->dev = alloc_hdlcdev(card);
 	if (!card->dev) {
--- linux-2.6.16-rc5-mm1/drivers/net/wan/wanpipe_multppp.c.orig	2006-03-02 14:44:24.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/wanpipe_multppp.c	2006-03-02 14:44:36.000000000 +0100
@@ -539,13 +539,11 @@ static int new_if(struct wan_device* wan
 	}
 		
 	/* allocate and initialize private data */
-	chdlc_priv_area = kmalloc(sizeof(chdlc_private_area_t), GFP_KERNEL);
+	chdlc_priv_area = kzalloc(sizeof(chdlc_private_area_t), GFP_KERNEL);
 	
 	if(chdlc_priv_area == NULL) 
 		return -ENOMEM;
 
-	memset(chdlc_priv_area, 0, sizeof(chdlc_private_area_t));
-
 	chdlc_priv_area->card = card; 
 
 	/* initialize data */
--- linux-2.6.16-rc5-mm1/drivers/net/wan/sdla_ppp.c.orig	2006-03-02 14:44:51.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/sdla_ppp.c	2006-03-02 14:45:02.000000000 +0100
@@ -528,13 +528,11 @@ static int new_if(struct wan_device *wan
 	}
 
 	/* allocate and initialize private data */
-	ppp_priv_area = kmalloc(sizeof(ppp_private_area_t), GFP_KERNEL);
+	ppp_priv_area = kzalloc(sizeof(ppp_private_area_t), GFP_KERNEL);
 	
 	if( ppp_priv_area == NULL )
 		return	-ENOMEM;
 	
-	memset(ppp_priv_area, 0, sizeof(ppp_private_area_t));
-	
 	ppp_priv_area->card = card; 
 	
 	/* initialize data */
--- linux-2.6.16-rc5-mm1/drivers/net/wan/cycx_main.c.orig	2006-03-02 14:45:12.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/cycx_main.c	2006-03-02 14:45:35.000000000 +0100
@@ -114,13 +114,11 @@ static int __init cycx_init(void)
 	/* Verify number of cards and allocate adapter data space */
 	cycx_ncards = min_t(int, cycx_ncards, CYCX_MAX_CARDS);
 	cycx_ncards = max_t(int, cycx_ncards, 1);
-	cycx_card_array = kmalloc(sizeof(struct cycx_device) * cycx_ncards,
+	cycx_card_array = kcalloc(cycx_ncards, sizeof(struct cycx_device),
 				  GFP_KERNEL);
 	if (!cycx_card_array)
 		goto out;
 
-	memset(cycx_card_array, 0, sizeof(struct cycx_device) * cycx_ncards);
-
 	/* Register adapters with WAN router */
 	for (cnt = 0; cnt < cycx_ncards; ++cnt) {
 		struct cycx_device *card = &cycx_card_array[cnt];
--- linux-2.6.16-rc5-mm1/drivers/net/wan/dscc4.c.orig	2006-03-02 14:45:45.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/dscc4.c	2006-03-02 14:46:12.000000000 +0100
@@ -890,12 +890,11 @@ static int dscc4_found1(struct pci_dev *
 	struct dscc4_dev_priv *root;
 	int i, ret = -ENOMEM;
 
-	root = kmalloc(dev_per_card*sizeof(*root), GFP_KERNEL);
+	root = kcalloc(dev_per_card, sizeof(*root), GFP_KERNEL);
 	if (!root) {
 		printk(KERN_ERR "%s: can't allocate data\n", DRV_NAME);
 		goto err_out;
 	}
-	memset(root, 0, dev_per_card*sizeof(*root));
 
 	for (i = 0; i < dev_per_card; i++) {
 		root[i].dev = alloc_hdlcdev(root + i);
@@ -903,12 +902,11 @@ static int dscc4_found1(struct pci_dev *
 			goto err_free_dev;
 	}
 
-	ppriv = kmalloc(sizeof(*ppriv), GFP_KERNEL);
+	ppriv = kzalloc(sizeof(*ppriv), GFP_KERNEL);
 	if (!ppriv) {
 		printk(KERN_ERR "%s: can't allocate private data\n", DRV_NAME);
 		goto err_free_dev;
 	}
-	memset(ppriv, 0, sizeof(struct dscc4_pci_priv));
 
 	ppriv->root = root;
 	spin_lock_init(&ppriv->lock);
--- linux-2.6.16-rc5-mm1/drivers/net/wan/n2.c.orig	2006-03-02 14:46:20.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/n2.c	2006-03-02 14:46:27.000000000 +0100
@@ -351,12 +351,11 @@ static int __init n2_run(unsigned long i
 		return -ENODEV;
 	}
 
-	card = kmalloc(sizeof(card_t), GFP_KERNEL);
+	card = kzalloc(sizeof(card_t), GFP_KERNEL);
 	if (card == NULL) {
 		printk(KERN_ERR "n2: unable to allocate memory\n");
 		return -ENOBUFS;
 	}
-	memset(card, 0, sizeof(card_t));
 
 	card->ports[0].dev = alloc_hdlcdev(&card->ports[0]);
 	card->ports[1].dev = alloc_hdlcdev(&card->ports[1]);
--- linux-2.6.16-rc5-mm1/drivers/net/wan/sdla_fr.c.orig	2006-03-02 14:46:37.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wan/sdla_fr.c	2006-03-02 14:47:11.000000000 +0100
@@ -812,12 +812,11 @@ static int new_if(struct wan_device* wan
 	}
 
 	/* allocate and initialize private data */
-	chan = kmalloc(sizeof(fr_channel_t), GFP_KERNEL);
+	chan = kzalloc(sizeof(fr_channel_t), GFP_KERNEL);
 
 	if (chan == NULL)
 		return -ENOMEM;
 
-	memset(chan, 0, sizeof(fr_channel_t));
 	strcpy(chan->name, conf->name);
 	chan->card = card;
 
@@ -1214,8 +1213,7 @@ static int if_open(struct net_device* de
 	INIT_WORK(&chan->common.wanpipe_work, (void *)fr_bh, dev);
 
 	/* Allocate and initialize BH circular buffer */
-	chan->bh_head = kmalloc((sizeof(bh_data_t)*MAX_BH_BUFF),GFP_ATOMIC);
-	memset(chan->bh_head,0,(sizeof(bh_data_t)*MAX_BH_BUFF));
+	chan->bh_head = kzalloc((sizeof(bh_data_t)*MAX_BH_BUFF),GFP_ATOMIC);
 	atomic_set(&chan->bh_buff_used, 0);
 
 	netif_start_queue(dev);
--- linux-2.6.16-rc5-mm1/drivers/net/shaper.c.orig	2006-03-02 14:47:27.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/shaper.c	2006-03-02 14:47:44.000000000 +0100
@@ -601,10 +601,9 @@ static int __init shaper_init(void)
 		return -ENODEV;
 
 	alloc_size = sizeof(*dev) * shapers;
-	devs = kmalloc(alloc_size, GFP_KERNEL);
+	devs = kzalloc(alloc_size, GFP_KERNEL);
 	if (!devs)
 		return -ENOMEM;
-	memset(devs, 0, alloc_size);
 
 	for (i = 0; i < shapers; i++) {
 
--- linux-2.6.16-rc5-mm1/drivers/net/ppp_generic.c.orig	2006-03-02 14:47:52.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/ppp_generic.c	2006-03-02 14:48:22.000000000 +0100
@@ -2006,10 +2006,9 @@ ppp_register_channel(struct ppp_channel 
 {
 	struct channel *pch;
 
-	pch = kmalloc(sizeof(struct channel), GFP_KERNEL);
+	pch = kzalloc(sizeof(struct channel), GFP_KERNEL);
 	if (pch == 0)
 		return -ENOMEM;
-	memset(pch, 0, sizeof(struct channel));
 	pch->ppp = NULL;
 	pch->chan = chan;
 	chan->ppp = pch;
@@ -2717,8 +2716,7 @@ static void cardmap_set(struct cardmap *
 	if (p == NULL || (nr >> p->shift) >= CARDMAP_WIDTH) {
 		do {
 			/* need a new top level */
-			struct cardmap *np = kmalloc(sizeof(*np), GFP_KERNEL);
-			memset(np, 0, sizeof(*np));
+			struct cardmap *np = kzalloc(sizeof(*np), GFP_KERNEL);
 			np->ptr[0] = p;
 			if (p != NULL) {
 				np->shift = p->shift + CARDMAP_ORDER;
@@ -2732,8 +2730,7 @@ static void cardmap_set(struct cardmap *
 	while (p->shift > 0) {
 		i = (nr >> p->shift) & CARDMAP_MASK;
 		if (p->ptr[i] == NULL) {
-			struct cardmap *np = kmalloc(sizeof(*np), GFP_KERNEL);
-			memset(np, 0, sizeof(*np));
+			struct cardmap *np = kzalloc(sizeof(*np), GFP_KERNEL);
 			np->shift = p->shift - CARDMAP_ORDER;
 			np->parent = p;
 			p->ptr[i] = np;
--- linux-2.6.16-rc5-mm1/drivers/net/lance.c.orig	2006-03-02 14:48:31.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/lance.c	2006-03-02 14:48:47.000000000 +0100
@@ -532,11 +532,10 @@ static int __init lance_probe1(struct ne
 	dev->base_addr = ioaddr;
 	/* Make certain the data structures used by the LANCE are aligned and DMAble. */
 		
-	lp = kmalloc(sizeof(*lp), GFP_DMA | GFP_KERNEL);
+	lp = kzalloc(sizeof(*lp), GFP_DMA | GFP_KERNEL);
 	if(lp==NULL)
 		return -ENODEV;
 	if (lance_debug > 6) printk(" (#0x%05lx)", (unsigned long)lp);
-	memset(lp, 0, sizeof(*lp));
 	dev->priv = lp;
 	lp->name = chipname;
 	lp->rx_buffs = (unsigned long)kmalloc(PKT_BUF_SZ*RX_RING_SIZE,
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/prism54/oid_mgt.c.orig	2006-03-02 14:49:34.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/prism54/oid_mgt.c	2006-03-02 14:50:29.000000000 +0100
@@ -235,12 +235,10 @@ mgt_init(islpci_private *priv)
 {
 	int i;
 
-	priv->mib = kmalloc(OID_NUM_LAST * sizeof (void *), GFP_KERNEL);
+	priv->mib = kzalloc(OID_NUM_LAST * sizeof(void *), GFP_KERNEL);
 	if (!priv->mib)
 		return -ENOMEM;
 
-	memset(priv->mib, 0, OID_NUM_LAST * sizeof (void *));
-
 	/* Alloc the cache */
 	for (i = 0; i < OID_NUM_LAST; i++) {
 		if (isl_oid[i].flags & OID_FLAG_CACHED) {
@@ -564,11 +562,9 @@ mgt_get_request(islpci_private *priv, en
 	if ((isl_oid[n].flags & OID_FLAG_TYPE) == OID_TYPE_U32)
 		res->u = ret ? 0 : le32_to_cpu(*(u32 *) _res);
 	else {
-		res->ptr = kmalloc(reslen, GFP_KERNEL);
+		res->ptr = kzalloc(reslen, GFP_KERNEL);
 		BUG_ON(res->ptr == NULL);
-		if (ret)
-			memset(res->ptr, 0, reslen);
-		else {
+		if (!ret) {
 			memcpy(res->ptr, _res, reslen);
 			mgt_le_to_cpu(isl_oid[n].flags & OID_FLAG_TYPE,
 				      res->ptr);
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/prism54/isl_ioctl.c.orig	2006-03-02 14:50:39.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/prism54/isl_ioctl.c	2006-03-02 14:51:16.000000000 +0100
@@ -1621,11 +1621,9 @@ prism54_wpa_ie_add(islpci_private *priv,
 					 struct islpci_bss_wpa_ie, list);
 			list_del(&bss->list);
 		} else {
-			bss = kmalloc(sizeof (*bss), GFP_ATOMIC);
-			if (bss != NULL) {
+			bss = kzalloc(sizeof (*bss), GFP_ATOMIC);
+			if (bss != NULL)
 				priv->num_bss_wpa++;
-				memset(bss, 0, sizeof (*bss));
-			}
 		}
 		if (bss != NULL) {
 			memcpy(bss->bssid, bssid, ETH_ALEN);
@@ -2165,11 +2163,10 @@ prism2_ioctl_set_generic_element(struct 
                return -EINVAL;
 
        alen = sizeof(*attach) + len;
-       attach = kmalloc(alen, GFP_KERNEL);
+       attach = kzalloc(alen, GFP_KERNEL);
        if (attach == NULL)
                return -ENOMEM;
 
-       memset(attach, 0, alen);
 #define WLAN_FC_TYPE_MGMT 0
 #define WLAN_FC_STYPE_ASSOC_REQ 0
 #define WLAN_FC_STYPE_REASSOC_REQ 2
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_ioctl.c.orig	2006-03-02 14:51:35.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_ioctl.c	2006-03-02 14:53:22.000000000 +0100
@@ -181,12 +181,10 @@ static int prism2_ioctl_siwencode(struct
 		struct ieee80211_crypt_data *new_crypt;
 
 		/* take WEP into use */
-		new_crypt = (struct ieee80211_crypt_data *)
-			kmalloc(sizeof(struct ieee80211_crypt_data),
+		new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
 				GFP_KERNEL);
 		if (new_crypt == NULL)
 			return -ENOMEM;
-		memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
 		new_crypt->ops = ieee80211_get_crypto_ops("WEP");
 		if (!new_crypt->ops) {
 			request_module("ieee80211_crypt_wep");
@@ -3320,14 +3318,12 @@ static int prism2_ioctl_siwencodeext(str
 
 		prism2_crypt_delayed_deinit(local, crypt);
 
-		new_crypt = (struct ieee80211_crypt_data *)
-			kmalloc(sizeof(struct ieee80211_crypt_data),
+		new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
 				GFP_KERNEL);
 		if (new_crypt == NULL) {
 			ret = -ENOMEM;
 			goto done;
 		}
-		memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
 		new_crypt->ops = ops;
 		new_crypt->priv = new_crypt->ops->init(i);
 		if (new_crypt->priv == NULL) {
@@ -3542,14 +3538,12 @@ static int prism2_ioctl_set_encryption(l
 
 		prism2_crypt_delayed_deinit(local, crypt);
 
-		new_crypt = (struct ieee80211_crypt_data *)
-			kmalloc(sizeof(struct ieee80211_crypt_data),
+		new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
 				GFP_KERNEL);
 		if (new_crypt == NULL) {
 			ret = -ENOMEM;
 			goto done;
 		}
-		memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
 		new_crypt->ops = ops;
 		new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx);
 		if (new_crypt->priv == NULL) {
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_ap.c.orig	2006-03-02 14:53:34.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_ap.c	2006-03-02 14:54:13.000000000 +0100
@@ -1099,15 +1099,13 @@ static struct sta_info * ap_add_sta(stru
 {
 	struct sta_info *sta;
 
-	sta = (struct sta_info *)
-		kmalloc(sizeof(struct sta_info), GFP_ATOMIC);
+	sta = kzalloc(sizeof(struct sta_info), GFP_ATOMIC);
 	if (sta == NULL) {
 		PDEBUG(DEBUG_AP, "AP: kmalloc failed\n");
 		return NULL;
 	}
 
 	/* initialize STA info data */
-	memset(sta, 0, sizeof(struct sta_info));
 	sta->local = ap->local;
 	skb_queue_head_init(&sta->tx_buf);
 	memcpy(sta->addr, addr, ETH_ALEN);
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_cs.c.orig	2006-03-02 14:54:19.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_cs.c	2006-03-02 14:54:35.000000000 +0100
@@ -567,14 +567,13 @@ static int prism2_config(struct pcmcia_d
 	PDEBUG(DEBUG_FLOW, "prism2_config()\n");
 
 	parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
-	hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
+	hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
 	if (parse == NULL || hw_priv == NULL) {
 		kfree(parse);
 		kfree(hw_priv);
 		ret = -ENOMEM;
 		goto failed;
 	}
-	memset(hw_priv, 0, sizeof(*hw_priv));
 
 	tuple.DesiredTuple = CISTPL_CONFIG;
 	tuple.Attributes = 0;
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_info.c.orig	2006-03-02 14:54:42.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_info.c	2006-03-02 14:54:59.000000000 +0100
@@ -327,11 +327,10 @@ static void prism2_info_hostscanresults(
 	ptr = (u8 *) pos;
 
 	new_count = left / result_size;
-	results = kmalloc(new_count * sizeof(struct hfa384x_hostscan_result),
+	results = kcalloc(new_count, sizeof(struct hfa384x_hostscan_result),
 			  GFP_ATOMIC);
 	if (results == NULL)
 		return;
-	memset(results, 0, new_count * sizeof(struct hfa384x_hostscan_result));
 
 	for (i = 0; i < new_count; i++) {
 		memcpy(&results[i], ptr, copy_len);
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_pci.c.orig	2006-03-02 14:55:47.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_pci.c	2006-03-02 14:55:58.000000000 +0100
@@ -301,10 +301,9 @@ static int prism2_pci_probe(struct pci_d
 	struct hostap_interface *iface;
 	struct hostap_pci_priv *hw_priv;
 
-	hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
+	hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
 	if (hw_priv == NULL)
 		return -ENOMEM;
-	memset(hw_priv, 0, sizeof(*hw_priv));
 
 	if (pci_enable_device(pdev))
 		return -EIO;
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_hw.c.orig	2006-03-02 14:56:05.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_hw.c	2006-03-02 14:56:54.000000000 +0100
@@ -348,14 +348,12 @@ static int hfa384x_cmd(struct net_device
 	if (signal_pending(current))
 		return -EINTR;
 
-	entry = (struct hostap_cmd_queue *)
-		kmalloc(sizeof(*entry), GFP_ATOMIC);
+	entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
 	if (entry == NULL) {
 		printk(KERN_DEBUG "%s: hfa384x_cmd - kmalloc failed\n",
 		       dev->name);
 		return -ENOMEM;
 	}
-	memset(entry, 0, sizeof(*entry));
 	atomic_set(&entry->usecnt, 1);
 	entry->type = CMD_SLEEP;
 	entry->cmd = cmd;
@@ -518,14 +516,12 @@ static int hfa384x_cmd_callback(struct n
 		return -1;
 	}
 
-	entry = (struct hostap_cmd_queue *)
-		kmalloc(sizeof(*entry), GFP_ATOMIC);
+	entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
 	if (entry == NULL) {
 		printk(KERN_DEBUG "%s: hfa384x_cmd_callback - kmalloc "
 		       "failed\n", dev->name);
 		return -ENOMEM;
 	}
-	memset(entry, 0, sizeof(*entry));
 	atomic_set(&entry->usecnt, 1);
 	entry->type = CMD_CALLBACK;
 	entry->cmd = cmd;
@@ -3013,14 +3009,12 @@ static int prism2_set_tim(struct net_dev
 	iface = netdev_priv(dev);
 	local = iface->local;
 
-	new_entry = (struct set_tim_data *)
-		kmalloc(sizeof(*new_entry), GFP_ATOMIC);
+	new_entry = kzalloc(sizeof(*new_entry), GFP_ATOMIC);
 	if (new_entry == NULL) {
 		printk(KERN_DEBUG "%s: prism2_set_tim: kmalloc failed\n",
 		       local->dev->name);
 		return -ENOMEM;
 	}
-	memset(new_entry, 0, sizeof(*new_entry));
 	new_entry->aid = aid;
 	new_entry->set = set;
 
--- linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_plx.c.orig	2006-03-02 14:57:02.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/wireless/hostap/hostap_plx.c	2006-03-02 14:57:11.000000000 +0100
@@ -446,10 +446,9 @@ static int prism2_plx_probe(struct pci_d
 	int tmd7160;
 	struct hostap_plx_priv *hw_priv;
 
-	hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
+	hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
 	if (hw_priv == NULL)
 		return -ENOMEM;
-	memset(hw_priv, 0, sizeof(*hw_priv));
 
 	if (pci_enable_device(pdev))
 		return -EIO;
--- linux-2.6.16-rc5-mm1/drivers/net/e100.c.orig	2006-03-02 14:57:25.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/e100.c	2006-03-02 14:57:41.000000000 +0100
@@ -1882,9 +1882,8 @@ static int e100_rx_alloc_list(struct nic
 
 	nic->rx_to_use = nic->rx_to_clean = NULL;
 
-	if(!(nic->rxs = kmalloc(sizeof(struct rx) * count, GFP_ATOMIC)))
+	if(!(nic->rxs = kcalloc(count, sizeof(struct rx), GFP_ATOMIC)))
 		return -ENOMEM;
-	memset(nic->rxs, 0, sizeof(struct rx) * count);
 
 	for(rx = nic->rxs, i = 0; i < count; rx++, i++) {
 		rx->next = (i + 1 < count) ? rx + 1 : nic->rxs;
--- linux-2.6.16-rc5-mm1/drivers/net/s2io.c.orig	2006-03-02 14:57:50.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/net/s2io.c	2006-03-02 14:58:42.000000000 +0100
@@ -407,14 +407,13 @@ static int init_shared_mem(struct s2io_n
 	for (i = 0; i < config->tx_fifo_num; i++) {
 		int fifo_len = config->tx_cfg[i].fifo_len;
 		int list_holder_size = fifo_len * sizeof(list_info_hold_t);
-		mac_control->fifos[i].list_info = kmalloc(list_holder_size,
+		mac_control->fifos[i].list_info = kzalloc(list_holder_size,
 							  GFP_KERNEL);
 		if (!mac_control->fifos[i].list_info) {
 			DBG_PRINT(ERR_DBG,
 				  "Malloc failed for list_info\n");
 			return -ENOMEM;
 		}
-		memset(mac_control->fifos[i].list_info, 0, list_holder_size);
 	}
 	for (i = 0; i < config->tx_fifo_num; i++) {
 		int page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len,
@@ -3229,24 +3228,21 @@ static int s2io_enable_msi_x(nic_t *nic)
 	u16 msi_control; /* Temp variable */
 	int ret, i, j, msix_indx = 1;
 
-	nic->entries = kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry),
+	nic->entries = kzalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry),
 			       GFP_KERNEL);
 	if (nic->entries == NULL) {
 		DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n", __FUNCTION__);
 		return -ENOMEM;
 	}
-	memset(nic->entries, 0, MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
 
 	nic->s2io_entries =
-		kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry),
+		kzalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry),
 				   GFP_KERNEL);
 	if (nic->s2io_entries == NULL) {
 		DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n", __FUNCTION__);
 		kfree(nic->entries);
 		return -ENOMEM;
 	}
-	memset(nic->s2io_entries, 0,
-	       MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
 
 	for (i=0; i< MAX_REQUESTED_MSI_X; i++) {
 		nic->entries[i].entry = i;



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/md
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (14 preceding siblings ...)
  2006-03-04 17:56   ` Eric Sesterhenn
@ 2006-03-04 19:09 ` Eric Sesterhenn
  2006-03-04 19:09 ` [KJ] [Patch] kzalloc() conversion in drivers/macintosh Eric Sesterhenn
                   ` (15 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-04 19:09 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 3901 bytes --]

hi,

this patch converts drivers/md to kzalloc usage.
Compile tested with allyes config.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/md/dm-path-selector.c.orig	2006-03-04 19:25:41.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/md/dm-path-selector.c	2006-03-04 19:26:08.000000000 +0100
@@ -95,12 +95,10 @@ out:
 
 static struct ps_internal *_alloc_path_selector(struct path_selector_type *pst)
 {
-	struct ps_internal *psi = kmalloc(sizeof(*psi), GFP_KERNEL);
+	struct ps_internal *psi = kzalloc(sizeof(*psi), GFP_KERNEL);
 
-	if (psi) {
-		memset(psi, 0, sizeof(*psi));
+	if (psi) 
 		psi->pst = *pst;
-	}
 
 	return psi;
 }
--- linux-2.6.16-rc5-mm1/drivers/md/dm-hw-handler.c.orig	2006-03-04 19:26:17.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/md/dm-hw-handler.c	2006-03-04 19:26:30.000000000 +0100
@@ -92,12 +92,10 @@ void dm_put_hw_handler(struct hw_handler
 
 static struct hwh_internal *_alloc_hw_handler(struct hw_handler_type *hwht)
 {
-	struct hwh_internal *hwhi = kmalloc(sizeof(*hwhi), GFP_KERNEL);
+	struct hwh_internal *hwhi = kzalloc(sizeof(*hwhi), GFP_KERNEL);
 
-	if (hwhi) {
-		memset(hwhi, 0, sizeof(*hwhi));
+	if (hwhi)
 		hwhi->hwht = *hwht;
-	}
 
 	return hwhi;
 }
--- linux-2.6.16-rc5-mm1/drivers/md/dm-emc.c.orig	2006-03-04 19:26:38.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/md/dm-emc.c	2006-03-04 19:27:01.000000000 +0100
@@ -221,12 +221,10 @@ fail_path:
 
 static struct emc_handler *alloc_emc_handler(void)
 {
-	struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL);
+	struct emc_handler *h = kzalloc(sizeof(*h), GFP_KERNEL);
 
-	if (h) {
-		memset(h, 0, sizeof(*h));
+	if (h) 
 		spin_lock_init(&h->lock);
-	}
 
 	return h;
 }
--- linux-2.6.16-rc5-mm1/drivers/md/dm-target.c.orig	2006-03-04 19:27:09.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/md/dm-target.c	2006-03-04 19:27:22.000000000 +0100
@@ -87,12 +87,10 @@ void dm_put_target_type(struct target_ty
 
 static struct tt_internal *alloc_target(struct target_type *t)
 {
-	struct tt_internal *ti = kmalloc(sizeof(*ti), GFP_KERNEL);
+	struct tt_internal *ti = kzalloc(sizeof(*ti), GFP_KERNEL);
 
-	if (ti) {
-		memset(ti, 0, sizeof(*ti));
+	if (ti)
 		ti->tt = *t;
-	}
 
 	return ti;
 }
--- linux-2.6.16-rc5-mm1/drivers/md/dm-mpath.c.orig	2006-03-04 19:27:28.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/md/dm-mpath.c	2006-03-04 19:28:36.000000000 +0100
@@ -113,12 +113,10 @@ static void trigger_event(void *data);
 
 static struct pgpath *alloc_pgpath(void)
 {
-	struct pgpath *pgpath = kmalloc(sizeof(*pgpath), GFP_KERNEL);
+	struct pgpath *pgpath = kzalloc(sizeof(*pgpath), GFP_KERNEL);
 
-	if (pgpath) {
-		memset(pgpath, 0, sizeof(*pgpath));
+	if (pgpath)
 		pgpath->path.is_active = 1;
-	}
 
 	return pgpath;
 }
@@ -132,11 +130,10 @@ static struct priority_group *alloc_prio
 {
 	struct priority_group *pg;
 
-	pg = kmalloc(sizeof(*pg), GFP_KERNEL);
+	pg = kzalloc(sizeof(*pg), GFP_KERNEL);
 	if (!pg)
 		return NULL;
 
-	memset(pg, 0, sizeof(*pg));
 	INIT_LIST_HEAD(&pg->pgpaths);
 
 	return pg;
@@ -171,9 +168,8 @@ static struct multipath *alloc_multipath
 {
 	struct multipath *m;
 
-	m = kmalloc(sizeof(*m), GFP_KERNEL);
+	m = kzalloc(sizeof(*m), GFP_KERNEL);
 	if (m) {
-		memset(m, 0, sizeof(*m));
 		INIT_LIST_HEAD(&m->priority_groups);
 		spin_lock_init(&m->lock);
 		m->queue_io = 1;
--- linux-2.6.16-rc5-mm1/drivers/md/dm-table.c.orig	2006-03-04 19:28:01.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/md/dm-table.c	2006-03-04 19:28:15.000000000 +0100
@@ -209,12 +209,11 @@ static int alloc_targets(struct dm_table
 
 int dm_table_create(struct dm_table **result, int mode, unsigned num_targets)
 {
-	struct dm_table *t = kmalloc(sizeof(*t), GFP_KERNEL);
+	struct dm_table *t = kzalloc(sizeof(*t), GFP_KERNEL);
 
 	if (!t)
 		return -ENOMEM;
 
-	memset(t, 0, sizeof(*t));
 	INIT_LIST_HEAD(&t->devices);
 	atomic_set(&t->holders, 1);
 



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/macintosh
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (15 preceding siblings ...)
  2006-03-04 19:09 ` [KJ] [Patch] kzalloc() conversion in drivers/md Eric Sesterhenn
@ 2006-03-04 19:09 ` Eric Sesterhenn
  2006-03-04 19:09 ` [KJ] [Patch] kzalloc() conversion in drivers/block Eric Sesterhenn
                   ` (14 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-04 19:09 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 3506 bytes --]

hi,

this patch converts drivers/macintosh to kzalloc usage.
Not tested.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/macintosh/therm_pm72.c.orig	2006-03-04 19:30:49.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/macintosh/therm_pm72.c	2006-03-04 19:31:03.000000000 +0100
@@ -306,10 +306,9 @@ static struct i2c_client *attach_i2c_chi
 	if (adap == NULL)
 		return NULL;
 
-	clt = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
+	clt = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
 	if (clt == NULL)
 		return NULL;
-	memset(clt, 0, sizeof(struct i2c_client));
 
 	clt->addr = (id >> 1) & 0x7f;
 	clt->adapter = adap;
--- linux-2.6.16-rc5-mm1/drivers/macintosh/windfarm_lm75_sensor.c.orig	2006-03-04 19:31:15.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/macintosh/windfarm_lm75_sensor.c	2006-03-04 19:31:25.000000000 +0100
@@ -116,10 +116,9 @@ static struct wf_lm75_sensor *wf_lm75_cr
 	DBG("wf_lm75: creating  %s device at address 0x%02x\n",
 	    ds1775 ? "ds1775" : "lm75", addr);
 
-	lm = kmalloc(sizeof(struct wf_lm75_sensor), GFP_KERNEL);
+	lm = kzalloc(sizeof(struct wf_lm75_sensor), GFP_KERNEL);
 	if (lm == NULL)
 		return NULL;
-	memset(lm, 0, sizeof(struct wf_lm75_sensor));
 
 	/* Usual rant about sensor names not beeing very consistent in
 	 * the device-tree, oh well ...
--- linux-2.6.16-rc5-mm1/drivers/macintosh/smu.c.orig	2006-03-04 19:31:33.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/macintosh/smu.c	2006-03-04 19:31:49.000000000 +0100
@@ -1035,10 +1035,9 @@ static int smu_open(struct inode *inode,
 	struct smu_private *pp;
 	unsigned long flags;
 
-	pp = kmalloc(sizeof(struct smu_private), GFP_KERNEL);
+	pp = kzalloc(sizeof(struct smu_private), GFP_KERNEL);
 	if (pp == 0)
 		return -ENOMEM;
-	memset(pp, 0, sizeof(struct smu_private));
 	spin_lock_init(&pp->lock);
 	pp->mode = smu_file_commands;
 	init_waitqueue_head(&pp->wait);
--- linux-2.6.16-rc5-mm1/drivers/macintosh/therm_windtunnel.c.orig	2006-03-04 19:31:57.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/macintosh/therm_windtunnel.c	2006-03-04 19:32:11.000000000 +0100
@@ -431,9 +431,8 @@ do_probe( struct i2c_adapter *adapter, i
 				     | I2C_FUNC_SMBUS_WRITE_BYTE) )
 		return 0;
 
-	if( !(cl=kmalloc(sizeof(*cl), GFP_KERNEL)) )
+	if( !(cl=kzalloc(sizeof(*cl), GFP_KERNEL)) )
 		return -ENOMEM;
-	memset( cl, 0, sizeof(struct i2c_client) );
 
 	cl->addr = addr;
 	cl->adapter = adapter;
--- linux-2.6.16-rc5-mm1/drivers/macintosh/therm_adt746x.c.orig	2006-03-04 19:32:19.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/macintosh/therm_adt746x.c	2006-03-04 19:32:35.000000000 +0100
@@ -379,13 +379,11 @@ static int attach_one_thermostat(struct 
 	if (thermostat)
 		return 0;
 
-	th = (struct thermostat *)
-		kmalloc(sizeof(struct thermostat), GFP_KERNEL);
+	th = kzalloc(sizeof(struct thermostat), GFP_KERNEL);
 
 	if (!th)
 		return -ENOMEM;
 
-	memset(th, 0, sizeof(*th));
 	th->clt.addr = addr;
 	th->clt.adapter = adapter;
 	th->clt.driver = &thermostat_driver;
--- linux-2.6.16-rc5-mm1/drivers/macintosh/macio_asic.c.orig	2006-03-04 19:32:45.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/macintosh/macio_asic.c	2006-03-04 19:33:09.000000000 +0100
@@ -407,10 +407,9 @@ static struct macio_dev * macio_add_one_
 	if (np == NULL)
 		return NULL;
 
-	dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
 		return NULL;
-	memset(dev, 0, sizeof(*dev));
 
 	dev->bus = &chip->lbus;
 	dev->media_bay = in_bay;



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/block
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (16 preceding siblings ...)
  2006-03-04 19:09 ` [KJ] [Patch] kzalloc() conversion in drivers/macintosh Eric Sesterhenn
@ 2006-03-04 19:09 ` Eric Sesterhenn
  2006-03-05  8:41 ` [KJ] [Patch] kzalloc() conversion in drivers/sbus Eric Sesterhenn
                   ` (13 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-04 19:09 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 2060 bytes --]

hi,

this patch converts drivers/block to kzalloc usage.
Compile tested with allyesconfig.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/block/ll_rw_blk.c.orig	2006-03-04 19:20:21.000000000 +0100
+++ linux-2.6.16-rc5-mm1/block/ll_rw_blk.c	2006-03-04 19:21:02.000000000 +0100
@@ -903,17 +903,15 @@ init_tag_map(request_queue_t *q, struct 
 				__FUNCTION__, depth);
 	}
 
-	tag_index = kmalloc(depth * sizeof(struct request *), GFP_ATOMIC);
+	tag_index = kcalloc(depth, sizeof(struct request *), GFP_ATOMIC);
 	if (!tag_index)
 		goto fail;
 
 	nr_ulongs = ALIGN(depth, BITS_PER_LONG) / BITS_PER_LONG;
-	tag_map = kmalloc(nr_ulongs * sizeof(unsigned long), GFP_ATOMIC);
+	tag_map = kcalloc(nr_ulongs, sizeof(unsigned long), GFP_ATOMIC);
 	if (!tag_map)
 		goto fail;
 
-	memset(tag_index, 0, depth * sizeof(struct request *));
-	memset(tag_map, 0, nr_ulongs * sizeof(unsigned long));
 	tags->real_max_depth = depth;
 	tags->max_depth = depth;
 	tags->tag_index = tag_index;
--- linux-2.6.16-rc5-mm1/block/scsi_ioctl.c.orig	2006-03-04 19:21:09.000000000 +0100
+++ linux-2.6.16-rc5-mm1/block/scsi_ioctl.c	2006-03-04 19:21:52.000000000 +0100
@@ -378,11 +378,9 @@ static int sg_scsi_ioctl(struct file *fi
 
 	bytes = max(in_len, out_len);
 	if (bytes) {
-		buffer = kmalloc(bytes, q->bounce_gfp | GFP_USER| __GFP_NOWARN);
+		buffer = kzalloc(bytes, q->bounce_gfp | GFP_USER| __GFP_NOWARN);
 		if (!buffer)
 			return -ENOMEM;
-
-		memset(buffer, 0, bytes);
 	}
 
 	rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT);
--- linux-2.6.16-rc5-mm1/block/cfq-iosched.c.orig	2006-03-04 19:22:27.000000000 +0100
+++ linux-2.6.16-rc5-mm1/block/cfq-iosched.c	2006-03-04 19:22:39.000000000 +0100
@@ -2158,12 +2158,10 @@ static int cfq_init_queue(request_queue_
 	struct cfq_data *cfqd;
 	int i;
 
-	cfqd = kmalloc(sizeof(*cfqd), GFP_KERNEL);
+	cfqd = kzalloc(sizeof(*cfqd), GFP_KERNEL);
 	if (!cfqd)
 		return -ENOMEM;
 
-	memset(cfqd, 0, sizeof(*cfqd));
-
 	for (i = 0; i < CFQ_PRIO_LISTS; i++)
 		INIT_LIST_HEAD(&cfqd->rr_list[i]);
 



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/sbus
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (17 preceding siblings ...)
  2006-03-04 19:09 ` [KJ] [Patch] kzalloc() conversion in drivers/block Eric Sesterhenn
@ 2006-03-05  8:41 ` Eric Sesterhenn
  2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/telephony/ Eric Sesterhenn
                   ` (12 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-05  8:41 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 4116 bytes --]

hi,  

this patch converts drivers/sbus to kzalloc usage.
Not tested

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/sbus/char/bbc_envctrl.c.orig	2006-03-04 21:59:51.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/sbus/char/bbc_envctrl.c	2006-03-04 22:00:20.000000000 +0100
@@ -485,11 +485,10 @@ static int kenvctrld(void *__unused)
 
 static void attach_one_temp(struct linux_ebus_child *echild, int temp_idx)
 {
-	struct bbc_cpu_temperature *tp = kmalloc(sizeof(*tp), GFP_KERNEL);
+	struct bbc_cpu_temperature *tp = kzalloc(sizeof(*tp), GFP_KERNEL);
 
 	if (!tp)
 		return;
-	memset(tp, 0, sizeof(*tp));
 	tp->client = bbc_i2c_attach(echild);
 	if (!tp->client) {
 		kfree(tp);
@@ -531,11 +530,10 @@ static void attach_one_temp(struct linux
 
 static void attach_one_fan(struct linux_ebus_child *echild, int fan_idx)
 {
-	struct bbc_fan_control *fp = kmalloc(sizeof(*fp), GFP_KERNEL);
+	struct bbc_fan_control *fp = kzalloc(sizeof(*fp), GFP_KERNEL);
 
 	if (!fp)
 		return;
-	memset(fp, 0, sizeof(*fp));
 	fp->client = bbc_i2c_attach(echild);
 	if (!fp->client) {
 		kfree(fp);
--- linux-2.6.16-rc5-mm1/drivers/sbus/char/openprom.c.orig	2006-03-04 22:00:31.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/sbus/char/openprom.c	2006-03-04 22:01:41.000000000 +0100
@@ -87,9 +87,8 @@ static int copyin(struct openpromio __us
 	if (bufsize > OPROMMAXPARAM)
 		bufsize = OPROMMAXPARAM;
 
-	if (!(*opp_p = kmalloc(sizeof(int) + bufsize + 1, GFP_KERNEL)))
+	if (!(*opp_p = kzalloc(sizeof(int) + bufsize + 1, GFP_KERNEL)))
 		return -ENOMEM;
-	memset(*opp_p, 0, sizeof(int) + bufsize + 1);
 
 	if (copy_from_user(&(*opp_p)->oprom_array,
 			   &info->oprom_array, bufsize)) {
@@ -107,10 +106,9 @@ static int getstrings(struct openpromio 
 	if (!info || !opp_p)
 		return -EFAULT;
 
-	if (!(*opp_p = kmalloc(sizeof(int) + OPROMMAXPARAM + 1, GFP_KERNEL)))
+	if (!(*opp_p = kzalloc(sizeof(int) + OPROMMAXPARAM + 1, GFP_KERNEL)))
 		return -ENOMEM;
 
-	memset(*opp_p, 0, sizeof(int) + OPROMMAXPARAM + 1);
 	(*opp_p)->oprom_size = 0;
 
 	n = bufsize = 0;
--- linux-2.6.16-rc5-mm1/drivers/sbus/char/bbc_i2c.c.orig	2006-03-04 22:02:02.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/sbus/char/bbc_i2c.c	2006-03-04 22:02:33.000000000 +0100
@@ -155,10 +155,9 @@ struct bbc_i2c_client *bbc_i2c_attach(st
 
 	if (!bp)
 		return NULL;
-	client = kmalloc(sizeof(*client), GFP_KERNEL);
+	client = kzalloc(sizeof(*client), GFP_KERNEL);
 	if (!client)
 		return NULL;
-	memset(client, 0, sizeof(*client));
 	client->bp = bp;
 	client->echild = echild;
 	client->bus = echild->resource[0].start;
@@ -356,13 +355,12 @@ static void __init reset_one_i2c(struct 
 
 static int __init attach_one_i2c(struct linux_ebus_device *edev, int index)
 {
-	struct bbc_i2c_bus *bp = kmalloc(sizeof(*bp), GFP_KERNEL);
+	struct bbc_i2c_bus *bp = kzalloc(sizeof(*bp), GFP_KERNEL);
 	struct linux_ebus_child *echild;
 	int entry;
 
 	if (!bp)
 		return -ENOMEM;
-	memset(bp, 0, sizeof(*bp));
 
 	bp->i2c_control_regs = ioremap(edev->resource[0].start, 0x2);
 	if (!bp->i2c_control_regs)
--- linux-2.6.16-rc5-mm1/drivers/sbus/char/vfc_dev.c.orig	2006-03-04 22:02:42.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/sbus/char/vfc_dev.c	2006-03-04 22:03:31.000000000 +0100
@@ -264,11 +264,10 @@ static int vfc_debug(struct vfc_dev *dev
 		if (copy_from_user(&inout, argp, sizeof(inout)))
 			return -EFAULT;
 
-		buffer = kmalloc(inout.len, GFP_KERNEL);
+		buffer = kzalloc(inout.len, GFP_KERNEL);
 		if (buffer == NULL)
 			return -ENOMEM;
 
-		memset(buffer,0,inout.len);
 		vfc_lock_device(dev);
 		inout.ret=
 			vfc_i2c_recvbuf(dev,inout.addr & 0xff
@@ -663,12 +662,9 @@ static int vfc_probe(void)
 	if (!cards)
 		return -ENODEV;
 
-	vfc_dev_lst = (struct vfc_dev **)kmalloc(sizeof(struct vfc_dev *) *
-						 (cards+1),
-						 GFP_KERNEL);
+	vfc_dev_lst = kcalloc((cards+1), sizeof(struct vfc_dev *), GFP_KERNEL);
 	if (vfc_dev_lst == NULL)
 		return -ENOMEM;
-	memset(vfc_dev_lst, 0, sizeof(struct vfc_dev *) * (cards + 1));
 	vfc_dev_lst[cards] = NULL;
 
 	ret = register_chrdev(VFC_MAJOR, vfcstr, &vfc_fops);



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/telephony/
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (18 preceding siblings ...)
  2006-03-05  8:41 ` [KJ] [Patch] kzalloc() conversion in drivers/sbus Eric Sesterhenn
@ 2006-03-05 15:02 ` Eric Sesterhenn
  2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/rapidio Eric Sesterhenn
                   ` (11 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-05 15:02 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 777 bytes --]

hi, 

this patch converts drivers/rapidio to kzalloc usage.
Compile tested with allyesconfig.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/telephony/ixj_pcmcia.c.orig	2006-03-05 09:45:52.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/telephony/ixj_pcmcia.c	2006-03-05 09:46:16.000000000 +0100
@@ -46,11 +46,10 @@ static int ixj_probe(struct pcmcia_devic
 	p_dev->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
 	p_dev->io.IOAddrLines = 3;
 	p_dev->conf.IntType = INT_MEMORY_AND_IO;
-	p_dev->priv = kmalloc(sizeof(struct ixj_info_t), GFP_KERNEL);
+	p_dev->priv = kzalloc(sizeof(struct ixj_info_t), GFP_KERNEL);
 	if (!p_dev->priv) {
 		return -ENOMEM;
 	}
-	memset(p_dev->priv, 0, sizeof(struct ixj_info_t));
 
 	return ixj_config(p_dev);
 }



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/rapidio
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (19 preceding siblings ...)
  2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/telephony/ Eric Sesterhenn
@ 2006-03-05 15:02 ` Eric Sesterhenn
  2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/misc/ Eric Sesterhenn
                   ` (10 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-05 15:02 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1051 bytes --]

hi,

this patch converts drivers/rapidio to kzalloc usage.
Not tested.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/rapidio/rio-scan.c.orig	2006-03-05 11:22:20.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/rapidio/rio-scan.c	2006-03-05 11:22:35.000000000 +0100
@@ -298,11 +298,10 @@ static struct rio_dev *rio_setup_device(
 	struct rio_switch *rswitch;
 	int result, rdid;
 
-	rdev = kmalloc(sizeof(struct rio_dev), GFP_KERNEL);
+	rdev = kzalloc(sizeof(struct rio_dev), GFP_KERNEL);
 	if (!rdev)
 		goto out;
 
-	memset(rdev, 0, sizeof(struct rio_dev));
 	rdev->net = net;
 	rio_mport_read_config_32(port, destid, hopcount, RIO_DEV_ID_CAR,
 				 &result);
@@ -785,9 +784,8 @@ static struct rio_net __devinit *rio_all
 {
 	struct rio_net *net;
 
-	net = kmalloc(sizeof(struct rio_net), GFP_KERNEL);
+	net = kzalloc(sizeof(struct rio_net), GFP_KERNEL);
 	if (net) {
-		memset(net, 0, sizeof(struct rio_net));
 		INIT_LIST_HEAD(&net->node);
 		INIT_LIST_HEAD(&net->devices);
 		INIT_LIST_HEAD(&net->mports);



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/misc/
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (20 preceding siblings ...)
  2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/rapidio Eric Sesterhenn
@ 2006-03-05 15:02 ` Eric Sesterhenn
  2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/mfd/ Eric Sesterhenn
                   ` (9 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-05 15:02 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 2116 bytes --]

hi,

this patch converts drivers/misc/ to kzalloc usage.
Compile tested with allyesconfig.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/misc/ibmasm/command.c.orig	2006-03-05 11:26:22.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/misc/ibmasm/command.c	2006-03-05 11:26:40.000000000 +0100
@@ -41,18 +41,15 @@ struct command *ibmasm_new_command(struc
 	if (buffer_size > IBMASM_CMD_MAX_BUFFER_SIZE)
 		return NULL;
 
-	cmd = kmalloc(sizeof(struct command), GFP_KERNEL);
+	cmd = kzalloc(sizeof(struct command), GFP_KERNEL);
 	if (cmd == NULL)
 		return NULL;
 
-	memset(cmd, 0, sizeof(*cmd));
-
-	cmd->buffer = kmalloc(buffer_size, GFP_KERNEL);
+	cmd->buffer = kzalloc(buffer_size, GFP_KERNEL);
 	if (cmd->buffer == NULL) {
 		kfree(cmd);
 		return NULL;
 	}
-	memset(cmd->buffer, 0, buffer_size);
 	cmd->buffer_size = buffer_size;
 
 	kobject_init(&cmd->kobj);
--- linux-2.6.16-rc5-mm1/drivers/misc/ibmasm/ibmasmfs.c.orig	2006-03-05 11:26:51.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/misc/ibmasm/ibmasmfs.c	2006-03-05 11:26:59.000000000 +0100
@@ -563,12 +563,10 @@ static ssize_t remote_settings_file_writ
 	if (*offset != 0)
 		return 0;
 
-	buff = kmalloc (count + 1, GFP_KERNEL);
+	buff = kzalloc (count + 1, GFP_KERNEL);
 	if (!buff)
 		return -ENOMEM;
 
-	memset(buff, 0x0, count + 1);
-
 	if (copy_from_user(buff, ubuff, count)) {
 		kfree(buff);
 		return -EFAULT;
--- linux-2.6.16-rc5-mm1/drivers/misc/ibmasm/module.c.orig	2006-03-05 11:27:07.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/misc/ibmasm/module.c	2006-03-05 11:27:15.000000000 +0100
@@ -77,13 +77,12 @@ static int __devinit ibmasm_init_one(str
 	/* vnc client won't work without bus-mastering */
 	pci_set_master(pdev);
 
-	sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL);
+	sp = kzalloc(sizeof(struct service_processor), GFP_KERNEL);
 	if (sp == NULL) {
 		dev_err(&pdev->dev, "Failed to allocate memory\n");
 		result = -ENOMEM;
 		goto error_kmalloc;
 	}
-	memset(sp, 0, sizeof(struct service_processor));
 
 	sp->lock = SPIN_LOCK_UNLOCKED;
 	INIT_LIST_HEAD(&sp->command_queue);



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/mfd/
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (21 preceding siblings ...)
  2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/misc/ Eric Sesterhenn
@ 2006-03-05 15:02 ` Eric Sesterhenn
  2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/media/ Eric Sesterhenn
                   ` (8 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-05 15:02 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1312 bytes --]

hi,  

this patch converts drivers/mfd/ to kzalloc usage.
Compile tested with allyesconfig.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/mfd/ucb1x00-core.c.orig	2006-03-05 09:47:31.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/mfd/ucb1x00-core.c	2006-03-05 09:47:41.000000000 +0100
@@ -483,13 +483,11 @@ static int ucb1x00_probe(struct mcp *mcp
 		goto err_disable;
 	}
 
-	ucb = kmalloc(sizeof(struct ucb1x00), GFP_KERNEL);
+	ucb = kzalloc(sizeof(struct ucb1x00), GFP_KERNEL);
 	ret = -ENOMEM;
 	if (!ucb)
 		goto err_disable;
 
-	memset(ucb, 0, sizeof(struct ucb1x00));
-
 	ucb->cdev.class = &ucb1x00_class;
 	ucb->cdev.dev = &mcp->attached_device;
 	strlcpy(ucb->cdev.class_id, "ucb1x00", sizeof(ucb->cdev.class_id));
--- linux-2.6.16-rc5-mm1/drivers/mfd/mcp-core.c.orig	2006-03-05 09:47:50.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/mfd/mcp-core.c	2006-03-05 09:47:59.000000000 +0100
@@ -200,9 +200,8 @@ struct mcp *mcp_host_alloc(struct device
 {
 	struct mcp *mcp;
 
-	mcp = kmalloc(sizeof(struct mcp) + size, GFP_KERNEL);
+	mcp = kzalloc(sizeof(struct mcp) + size, GFP_KERNEL);
 	if (mcp) {
-		memset(mcp, 0, sizeof(struct mcp) + size);
 		spin_lock_init(&mcp->lock);
 		mcp->attached_device.parent = parent;
 		mcp->attached_device.bus = &mcp_bus_type;



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/media/
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (22 preceding siblings ...)
  2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/mfd/ Eric Sesterhenn
@ 2006-03-05 15:02 ` Eric Sesterhenn
  2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/block Eric Sesterhenn
                   ` (7 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-05 15:02 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 3074 bytes --]

hi,  

this patch converts drivers/media/ to kzalloc usage.
Compile tested with allyesconfig.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/media/dvb/cinergyT2/cinergyT2.c.orig	2006-03-05 09:48:34.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/media/dvb/cinergyT2/cinergyT2.c	2006-03-05 09:48:53.000000000 +0100
@@ -877,12 +877,11 @@ static int cinergyt2_probe (struct usb_i
 	struct cinergyt2 *cinergyt2;
 	int err;
 
-	if (!(cinergyt2 = kmalloc (sizeof(struct cinergyt2), GFP_KERNEL))) {
+	if (!(cinergyt2 = kzalloc(sizeof(struct cinergyt2), GFP_KERNEL))) {
 		dprintk(1, "out of memory?!?\n");
 		return -ENOMEM;
 	}
 
-	memset (cinergyt2, 0, sizeof (struct cinergyt2));
 	usb_set_intfdata (intf, (void *) cinergyt2);
 
 	init_MUTEX(&cinergyt2->sem);
--- linux-2.6.16-rc5-mm1/drivers/media/video/cx88/cx88-alsa.c.orig	2006-03-05 09:50:04.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/media/video/cx88/cx88-alsa.c	2006-03-05 09:50:14.000000000 +0100
@@ -413,11 +413,9 @@ static int snd_cx88_hw_params(struct snd
 
 	dprintk(1,"Setting buffer\n");
 
-	buf = kmalloc(sizeof(*buf),GFP_KERNEL);
+	buf = kzalloc(sizeof(*buf),GFP_KERNEL);
 	if (NULL == buf)
 		return -ENOMEM;
-	memset(buf,0,sizeof(*buf));
-
 
 	buf->vb.memory = V4L2_MEMORY_MMAP;
 	buf->vb.width  = chip->period_size;
--- linux-2.6.16-rc5-mm1/drivers/media/video/msp3400-driver.c.orig	2006-03-05 09:50:27.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/media/video/msp3400-driver.c	2006-03-05 09:50:54.000000000 +0100
@@ -1070,10 +1070,9 @@ static int msp_attach(struct i2c_adapter
 	int msp_product, msp_prod_hi, msp_prod_lo;
 	int msp_rom;
 
-	client = kmalloc(sizeof(*client), GFP_KERNEL);
+	client = kzalloc(sizeof(*client), GFP_KERNEL);
 	if (client == NULL)
 		return -ENOMEM;
-	memset(client, 0, sizeof(*client));
 	client->addr = address;
 	client->adapter = adapter;
 	client->driver = &i2c_driver;
@@ -1085,14 +1084,13 @@ static int msp_attach(struct i2c_adapter
 		return -1;
 	}
 
-	state = kmalloc(sizeof(*state), GFP_KERNEL);
+	state = kzalloc(sizeof(*state), GFP_KERNEL);
 	if (state == NULL) {
 		kfree(client);
 		return -ENOMEM;
 	}
 	i2c_set_clientdata(client, state);
 
-	memset(state, 0, sizeof(*state));
 	state->v4l2_std = V4L2_STD_NTSC;
 	state->volume = 58880;	/* 0db gain */
 	state->balance = 32768;	/* 0db gain */
--- linux-2.6.16-rc5-mm1/drivers/media/video/planb.c.orig	2006-03-05 09:51:03.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/media/video/planb.c	2006-03-05 09:51:39.000000000 +0100
@@ -352,9 +352,8 @@ static int planb_prepare_open(struct pla
 		* PLANB_DUMMY)*sizeof(struct dbdma_cmd)
 		+(PLANB_MAXLINES*((PLANB_MAXPIXELS+7)& ~7))/8
 		+MAX_GBUFFERS*sizeof(unsigned int);
-	if ((pb->priv_space = kmalloc (size, GFP_KERNEL)) == 0)
+	if ((pb->priv_space = kzalloc(size, GFP_KERNEL)) == 0)
 		return -ENOMEM;
-	memset ((void *) pb->priv_space, 0, size);
 	pb->overlay_last1 = pb->ch1_cmd = (volatile struct dbdma_cmd *)
 						DBDMA_ALIGN (pb->priv_space);
 	pb->overlay_last2 = pb->ch2_cmd = pb->ch1_cmd + pb->tab_size;



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/block
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (23 preceding siblings ...)
  2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/media/ Eric Sesterhenn
@ 2006-03-05 15:02 ` Eric Sesterhenn
  2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/sh Eric Sesterhenn
                   ` (6 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-05 15:02 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 4213 bytes --]

hi, 

this patch converts drivers/block to kzalloc usage.
Compile tested with allyesconfig.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/block/paride/bpck6.c.orig	2006-03-05 11:07:13.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/block/paride/bpck6.c	2006-03-05 11:07:29.000000000 +0100
@@ -224,10 +224,9 @@ static void bpck6_log_adapter( PIA *pi, 
 
 static int bpck6_init_proto(PIA *pi)
 {
-	Interface *p = kmalloc(sizeof(Interface), GFP_KERNEL);
+	Interface *p = kzalloc(sizeof(Interface), GFP_KERNEL);
 
 	if (p) {
-		memset(p, 0, sizeof(Interface));
 		pi->private = (unsigned long)p;
 		return 0;
 	}
--- linux-2.6.16-rc5-mm1/drivers/block/cciss_scsi.c.orig	2006-03-05 11:07:44.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/block/cciss_scsi.c	2006-03-05 11:08:09.000000000 +0100
@@ -1027,12 +1027,11 @@ cciss_update_non_disk_devices(int cntl_n
 	int i;
 
 	c = (ctlr_info_t *) hba[cntl_num];	
-	ld_buff = kmalloc(reportlunsize, GFP_KERNEL);
+	ld_buff = kzalloc(reportlunsize, GFP_KERNEL);
 	if (ld_buff == NULL) {
 		printk(KERN_ERR "cciss: out of memory\n");
 		return;
 	}
-	memset(ld_buff, 0, reportlunsize);
 	inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL);
         if (inq_buff == NULL) {
                 printk(KERN_ERR "cciss: out of memory\n");
--- linux-2.6.16-rc5-mm1/drivers/block/cciss.c.orig	2006-03-05 11:09:08.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/block/cciss.c	2006-03-05 11:10:40.000000000 +0100
@@ -996,13 +996,11 @@ static int cciss_ioctl(struct inode *ino
 			status = -EINVAL;
 			goto cleanup1;
 		}
-		buff = (unsigned char **) kmalloc(MAXSGENTRIES * 
-				sizeof(char *), GFP_KERNEL);
+		buff = kzalloc(MAXSGENTRIES * sizeof(char *), GFP_KERNEL);
 		if (!buff) {
 			status = -ENOMEM;
 			goto cleanup1;
 		}
-		memset(buff, 0, MAXSGENTRIES);
 		buff_size = (int *) kmalloc(MAXSGENTRIES * sizeof(int), 
 					GFP_KERNEL);
 		if (!buff_size) {
@@ -2941,13 +2939,12 @@ static void cciss_getgeometry(int cntl_n
 	int block_size;
 	int total_size; 
 
-	ld_buff = kmalloc(sizeof(ReportLunData_struct), GFP_KERNEL);
+	ld_buff = kzalloc(sizeof(ReportLunData_struct), GFP_KERNEL);
 	if (ld_buff == NULL)
 	{
 		printk(KERN_ERR "cciss: out of memory\n");
 		return;
 	}
-	memset(ld_buff, 0, sizeof(ReportLunData_struct));
 	size_buff = kmalloc(sizeof( ReadCapdata_struct), GFP_KERNEL);
         if (size_buff == NULL)
         {
@@ -3061,10 +3058,9 @@ static int alloc_cciss_hba(void)
 	for(i=0; i< MAX_CTLR; i++) {
 		if (!hba[i]) {
 			ctlr_info_t *p;
-			p = kmalloc(sizeof(ctlr_info_t), GFP_KERNEL);
+			p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
 			if (!p)
 				goto Enomem;
-			memset(p, 0, sizeof(ctlr_info_t));
 			for (n = 0; n < NWD; n++)
 				p->gendisk[n] = disk[n];
 			hba[i] = p;
--- linux-2.6.16-rc5-mm1/drivers/block/DAC960.c.orig	2006-03-05 11:10:48.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/block/DAC960.c	2006-03-05 11:12:05.000000000 +0100
@@ -312,11 +312,10 @@ static boolean DAC960_CreateAuxiliaryStr
 		CommandsRemaining = CommandAllocationGroupSize;
 	  CommandGroupByteCount =
 		CommandsRemaining * CommandAllocationLength;
-	  AllocationPointer = kmalloc(CommandGroupByteCount, GFP_ATOMIC);
+	  AllocationPointer = kzalloc(CommandGroupByteCount, GFP_ATOMIC);
 	  if (AllocationPointer == NULL)
 		return DAC960_Failure(Controller,
 					"AUXILIARY STRUCTURE CREATION");
-	  memset(AllocationPointer, 0, CommandGroupByteCount);
 	 }
       Command = (DAC960_Command_T *) AllocationPointer;
       AllocationPointer += CommandAllocationLength;
@@ -2710,14 +2709,12 @@ DAC960_DetectController(struct pci_dev *
   void __iomem *BaseAddress;
   int i;
 
-  Controller = (DAC960_Controller_T *)
-	kmalloc(sizeof(DAC960_Controller_T), GFP_ATOMIC);
+  Controller = kzalloc(sizeof(DAC960_Controller_T), GFP_ATOMIC);
   if (Controller == NULL) {
 	DAC960_Error("Unable to allocate Controller structure for "
                        "Controller at\n", NULL);
 	return NULL;
   }
-  memset(Controller, 0, sizeof(DAC960_Controller_T));
   Controller->ControllerNumber = DAC960_ControllerCount;
   DAC960_Controllers[DAC960_ControllerCount++] = Controller;
   Controller->Bus = PCI_Device->bus->number;



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/sh
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (24 preceding siblings ...)
  2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/block Eric Sesterhenn
@ 2006-03-05 21:02 ` Eric Sesterhenn
  2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/pnp Eric Sesterhenn
                   ` (5 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-05 21:02 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 697 bytes --]

hi, 

this patch converts drivers/sh/ to kzalloc usage.
Compile tested with allyesconfig.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/sh/superhyway/superhyway.c.orig	2006-03-05 16:05:44.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/sh/superhyway/superhyway.c	2006-03-05 16:05:54.000000000 +0100
@@ -56,11 +56,9 @@ int superhyway_add_device(unsigned long 
 	struct superhyway_device *dev = sdev;
 
 	if (!dev) {
-		dev = kmalloc(sizeof(struct superhyway_device), GFP_KERNEL);
+		dev = kzalloc(sizeof(struct superhyway_device), GFP_KERNEL);
 		if (!dev)
 			return -ENOMEM;
-
-		memset(dev, 0, sizeof(struct superhyway_device));
 	}
 
 	dev->bus = bus;



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/pnp
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (25 preceding siblings ...)
  2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/sh Eric Sesterhenn
@ 2006-03-05 21:02 ` Eric Sesterhenn
  2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/nubus Eric Sesterhenn
                   ` (4 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-05 21:02 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 583 bytes --]

hi, 

this patch converts drivers/pnp/ to kzalloc usage.
Compile tested with allyesconfig.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/pnp/core.c.orig	2006-03-05 16:06:10.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/pnp/core.c	2006-03-05 16:06:32.000000000 +0100
@@ -26,12 +26,11 @@ void *pnp_alloc(long size)
 {
 	void *result;
 
-	result = kmalloc(size, GFP_KERNEL);
+	result = kzalloc(size, GFP_KERNEL);
 	if (!result){
 		printk(KERN_ERR "pnp: Out of Memory\n");
 		return NULL;
 	}
-	memset(result, 0, size);
 	return result;
 }
 



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/nubus
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (26 preceding siblings ...)
  2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/pnp Eric Sesterhenn
@ 2006-03-05 21:02 ` Eric Sesterhenn
  2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/mca Eric Sesterhenn
                   ` (3 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-05 21:02 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1106 bytes --]

hi, 

this patch converts drivers/nubus/ to kzalloc usage.
Not tested.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/nubus/nubus.c.orig	2006-03-05 16:04:52.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/nubus/nubus.c	2006-03-05 16:05:10.000000000 +0100
@@ -467,9 +467,8 @@ static struct nubus_dev* __init
 		       parent->base, dir.base);
 
 	/* Actually we should probably panic if this fails */
-	if ((dev = kmalloc(sizeof(*dev), GFP_ATOMIC)) == NULL)
+	if ((dev = kzalloc(sizeof(*dev), GFP_ATOMIC)) == NULL)
 		return NULL;	
-	memset(dev, 0, sizeof(*dev));
 	dev->resid = parent->type;
 	dev->directory = dir.base;
 	dev->board = board;
@@ -801,9 +800,8 @@ static struct nubus_board* __init nubus_
 	nubus_rewind(&rp, FORMAT_BLOCK_SIZE, bytelanes);
 
 	/* Actually we should probably panic if this fails */
-	if ((board = kmalloc(sizeof(*board), GFP_ATOMIC)) == NULL)
+	if ((board = kzalloc(sizeof(*board), GFP_ATOMIC)) == NULL)
 		return NULL;	
-	memset(board, 0, sizeof(*board));
 	board->fblock = rp;
 
 	/* Dump the format block for debugging purposes */



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/mca
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (27 preceding siblings ...)
  2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/nubus Eric Sesterhenn
@ 2006-03-05 21:02 ` Eric Sesterhenn
  2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/message Eric Sesterhenn
                   ` (2 subsequent siblings)
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-05 21:02 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 747 bytes --]

hi,

this patch converts drivers/mca/ to kzalloc usage.
Compile tested with allyesconfig.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/mca/mca-bus.c.orig	2006-03-05 16:09:32.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/mca/mca-bus.c	2006-03-05 16:09:41.000000000 +0100
@@ -157,10 +157,9 @@ struct mca_bus * __devinit mca_attach_bu
 		return NULL;
 	}
 
-	mca_bus = kmalloc(sizeof(struct mca_bus), GFP_KERNEL);
+	mca_bus = kzalloc(sizeof(struct mca_bus), GFP_KERNEL);
 	if (!mca_bus)
 		return NULL;
-	memset(mca_bus, 0, sizeof(struct mca_bus));
 	sprintf(mca_bus->dev.bus_id,"mca%d",bus);
 	sprintf(mca_bus->name,"Host %s MCA Bridge", bus ? "Secondary" : "Primary");
 	device_register(&mca_bus->dev);



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/message
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (28 preceding siblings ...)
  2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/mca Eric Sesterhenn
@ 2006-03-05 21:02 ` Eric Sesterhenn
  2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/acorn/ Eric Sesterhenn
  2006-03-06 20:13 ` [KJ] [Patch] kzalloc() conversion in drivers/parport/ Eric Sesterhenn
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-05 21:02 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 2006 bytes --]

hi, 

this patch converts drivers/message/ to kzalloc usage.
Compile tested with allyesconfig.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/message/fusion/mptctl.c.orig	2006-03-05 16:03:30.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/message/fusion/mptctl.c	2006-03-05 16:04:18.000000000 +0100
@@ -962,10 +962,9 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, i
 	 * structures for the SG elements.
 	 */
 	i = MAX_SGL_BYTES / 8;
-	buflist = kmalloc(i, GFP_USER);
+	buflist = kzalloc(i, GFP_USER);
 	if (buflist == NULL)
 		return NULL;
-	memset(buflist, 0, i);
 	buflist_ent = 0;
 
 	/* Allocate a single block of memory to store the sg elements and
@@ -1377,13 +1376,12 @@ mptctl_gettargetinfo (unsigned long arg)
 	 *      15- 8: Bus Number
 	 *       7- 0: Target ID
 	 */
-	pmem = kmalloc(numBytes, GFP_KERNEL);
+	pmem = kzalloc(numBytes, GFP_KERNEL);
 	if (pmem == NULL) {
 		printk(KERN_ERR "%s::mptctl_gettargetinfo() @%d - no memory available!\n",
 				__FILE__, __LINE__);
 		return -ENOMEM;
 	}
-	memset(pmem, 0, numBytes);
 	pdata =  (int *) pmem;
 
 	/* Get number of devices
@@ -1617,12 +1615,11 @@ mptctl_eventenable (unsigned long arg)
 		/* Have not yet allocated memory - do so now.
 		 */
 		int sz = MPTCTL_EVENT_LOG_SIZE * sizeof(MPT_IOCTL_EVENTS);
-		ioc->events = kmalloc(sz, GFP_KERNEL);
+		ioc->events = kzalloc(sz, GFP_KERNEL);
 		if (ioc->events == NULL) {
 			printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n");
 			return -ENOMEM;
 		}
-		memset(ioc->events, 0, sz);
 		ioc->alloc_total += sz;
 
 		ioc->eventContext = 0;
@@ -2888,13 +2885,12 @@ mptctl_probe(struct pci_dev *pdev, const
 	 * Allocate and inite a MPT_IOCTL structure
 	*/
 	sz = sizeof (MPT_IOCTL);
-	mem = kmalloc(sz, GFP_KERNEL);
+	mem = kzalloc(sz, GFP_KERNEL);
 	if (mem == NULL) {
 		err = -ENOMEM;
 		goto out_fail;
 	}
 
-	memset(mem, 0, sz);
 	ioc->ioctl = (MPT_IOCTL *) mem;
 	ioc->ioctl->ioc = ioc;
 	mutex_init(&ioc->ioctl->ioctl_mutex);



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/acorn/
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (29 preceding siblings ...)
  2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/message Eric Sesterhenn
@ 2006-03-05 21:02 ` Eric Sesterhenn
  2006-03-06 20:13 ` [KJ] [Patch] kzalloc() conversion in drivers/parport/ Eric Sesterhenn
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-05 21:02 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 612 bytes --]

hi,

this patch converts drivers/acorn/ to kzalloc usage.
Compile tested with allyesconfig.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/acorn/char/pcf8583.c.orig	2006-03-05 16:07:42.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/acorn/char/pcf8583.c	2006-03-05 16:07:51.000000000 +0100
@@ -55,11 +55,10 @@ pcf8583_attach(struct i2c_adapter *adap,
 		}
 	};
 
-	c = kmalloc(sizeof(*c), GFP_KERNEL);
+	c = kzalloc(sizeof(*c), GFP_KERNEL);
 	if (!c)
 		return -ENOMEM;
 
-	memset(c, 0, sizeof(*c));
 	c->addr		= addr;
 	c->adapter	= adap;
 	c->driver	= &pcf8583_driver;



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [KJ] [Patch] kzalloc() conversion in drivers/parport/
  2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
                   ` (30 preceding siblings ...)
  2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/acorn/ Eric Sesterhenn
@ 2006-03-06 20:13 ` Eric Sesterhenn
  31 siblings, 0 replies; 34+ messages in thread
From: Eric Sesterhenn @ 2006-03-06 20:13 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1231 bytes --]

hi, 

this patch converts crypto/ to kzalloc usage.
Compile tested with allyesconfig.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/drivers/parport/parport_serial.c.orig	2006-03-05 16:08:07.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/parport/parport_serial.c	2006-03-05 16:08:17.000000000 +0100
@@ -368,10 +368,9 @@ static int __devinit parport_serial_pci_
 	struct parport_serial_private *priv;
 	int err;
 
-	priv = kmalloc (sizeof *priv, GFP_KERNEL);
+	priv = kzalloc (sizeof *priv, GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
-	memset(priv, 0, sizeof(struct parport_serial_private));
 	pci_set_drvdata (dev, priv);
 
 	err = pci_enable_device (dev);
--- linux-2.6.16-rc5-mm1/drivers/parport/parport_cs.c.orig	2006-03-05 16:08:23.000000000 +0100
+++ linux-2.6.16-rc5-mm1/drivers/parport/parport_cs.c	2006-03-05 16:08:32.000000000 +0100
@@ -106,9 +106,8 @@ static int parport_probe(struct pcmcia_d
     DEBUG(0, "parport_attach()\n");
 
     /* Create new parport device */
-    info = kmalloc(sizeof(*info), GFP_KERNEL);
+    info = kzalloc(sizeof(*info), GFP_KERNEL);
     if (!info) return -ENOMEM;
-    memset(info, 0, sizeof(*info));
     link->priv = info;
     info->p_dev = link;
 



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2006-03-06 20:13 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-24 21:17 [KJ] [Patch] kzalloc() conversion in drivers/video Eric Sesterhenn
2006-02-27  9:22 ` [KJ] [Patch] kzalloc() conversion in drivers/atm Eric Sesterhenn
2006-02-27  9:43 ` Tobias Klauser
2006-02-27 11:16 ` Eric Sesterhenn
2006-02-27 16:22 ` [KJ] [Patch] kzalloc() conversion in drivers/usb Eric Sesterhenn
2006-02-27 20:36 ` [KJ] [Patch] kzalloc() conversion in drivers/usb/gadget Eric Sesterhenn
2006-02-27 20:51 ` Jesper Juhl
2006-02-28 13:54 ` [KJ] [Patch] kzalloc() conversion in drivers/acpi Eric Sesterhenn
2006-02-28 13:54 ` [KJ] [Patch] kzalloc() conversion in drivers/s390 Eric Sesterhenn
2006-02-28 14:34 ` [KJ] [Patch] kzalloc() conversion in drivers/pci Eric Sesterhenn
2006-02-28 21:39 ` [KJ] [Patch] kzalloc() conversion in drivers/usb/gadget Alexey Dobriyan
2006-02-28 21:49 ` Jesper Juhl
2006-03-01  9:00 ` [KJ] [Patch] kzalloc() conversion in drivers/char Eric Sesterhenn
2006-03-01 23:29 ` [KJ] [Patch] kzalloc() conversion in drivers/mtd Eric Sesterhenn
2006-03-02 11:58 ` [KJ] [Patch] kzalloc() conversion in drivers/serial Eric Sesterhenn
2006-03-04 17:56 ` [KJ] [Patch] kzalloc() conversion in drivers/net Eric Sesterhenn
2006-03-04 17:56   ` Eric Sesterhenn
2006-03-04 19:09 ` [KJ] [Patch] kzalloc() conversion in drivers/md Eric Sesterhenn
2006-03-04 19:09 ` [KJ] [Patch] kzalloc() conversion in drivers/macintosh Eric Sesterhenn
2006-03-04 19:09 ` [KJ] [Patch] kzalloc() conversion in drivers/block Eric Sesterhenn
2006-03-05  8:41 ` [KJ] [Patch] kzalloc() conversion in drivers/sbus Eric Sesterhenn
2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/telephony/ Eric Sesterhenn
2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/rapidio Eric Sesterhenn
2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/misc/ Eric Sesterhenn
2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/mfd/ Eric Sesterhenn
2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/media/ Eric Sesterhenn
2006-03-05 15:02 ` [KJ] [Patch] kzalloc() conversion in drivers/block Eric Sesterhenn
2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/sh Eric Sesterhenn
2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/pnp Eric Sesterhenn
2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/nubus Eric Sesterhenn
2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/mca Eric Sesterhenn
2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/message Eric Sesterhenn
2006-03-05 21:02 ` [KJ] [Patch] kzalloc() conversion in drivers/acorn/ Eric Sesterhenn
2006-03-06 20:13 ` [KJ] [Patch] kzalloc() conversion in drivers/parport/ Eric Sesterhenn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.