aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorYoann Padioleau <padator@wanadoo.fr>2007-07-19 04:49:03 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-19 13:04:50 -0400
commitdd00cc486ab1c17049a535413d1751ef3482141c (patch)
treed90ff69ea06792b9284f2f2665c96624f121b88a /arch
parent3b5ad0797c0e4049001f961a8b58f1d0ce532072 (diff)
some kmalloc/memset ->kzalloc (tree wide)
Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc). Here is a short excerpt of the semantic patch performing this transformation: @@ type T2; expression x; identifier f,fld; expression E; expression E1,E2; expression e1,e2,e3,y; statement S; @@ x = - kmalloc + kzalloc (E1,E2) ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\) - memset((T2)x,0,E1); @@ expression E1,E2,E3; @@ - kzalloc(E1 * E2,E3) + kcalloc(E1,E2,E3) [akpm@linux-foundation.org: get kcalloc args the right way around] Signed-off-by: Yoann Padioleau <padator@wanadoo.fr> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Acked-by: Russell King <rmk@arm.linux.org.uk> Cc: Bryan Wu <bryan.wu@analog.com> Acked-by: Jiri Slaby <jirislaby@gmail.com> Cc: Dave Airlie <airlied@linux.ie> Acked-by: Roland Dreier <rolandd@cisco.com> Cc: Jiri Kosina <jkosina@suse.cz> Acked-by: Dmitry Torokhov <dtor@mail.ru> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: Mauro Carvalho Chehab <mchehab@infradead.org> Acked-by: Pierre Ossman <drzeus-list@drzeus.cx> Cc: Jeff Garzik <jeff@garzik.org> Cc: "David S. Miller" <davem@davemloft.net> Acked-by: Greg KH <greg@kroah.com> Cc: James Bottomley <James.Bottomley@steeleye.com> Cc: "Antonino A. Daplas" <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/alpha/kernel/module.c3
-rw-r--r--arch/arm/mach-iop13xx/pci.c3
-rw-r--r--arch/blackfin/mm/blackfin_sram.c3
-rw-r--r--arch/cris/arch-v32/drivers/pci/dma.c6
-rw-r--r--arch/powerpc/kernel/lparcfg.c3
-rw-r--r--arch/powerpc/kernel/of_platform.c3
6 files changed, 7 insertions, 14 deletions
diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
index bd03dc94c72b..026ba9af6d6a 100644
--- a/arch/alpha/kernel/module.c
+++ b/arch/alpha/kernel/module.c
@@ -119,8 +119,7 @@ module_frob_arch_sections(Elf64_Ehdr *hdr, Elf64_Shdr *sechdrs,
119 } 119 }
120 120
121 nsyms = symtab->sh_size / sizeof(Elf64_Sym); 121 nsyms = symtab->sh_size / sizeof(Elf64_Sym);
122 chains = kmalloc(nsyms * sizeof(struct got_entry), GFP_KERNEL); 122 chains = kcalloc(nsyms, sizeof(struct got_entry), GFP_KERNEL);
123 memset(chains, 0, nsyms * sizeof(struct got_entry));
124 123
125 got->sh_size = 0; 124 got->sh_size = 0;
126 got->sh_addralign = 8; 125 got->sh_addralign = 8;
diff --git a/arch/arm/mach-iop13xx/pci.c b/arch/arm/mach-iop13xx/pci.c
index 9d63d7f260ca..99d94cb1bafd 100644
--- a/arch/arm/mach-iop13xx/pci.c
+++ b/arch/arm/mach-iop13xx/pci.c
@@ -1002,11 +1002,10 @@ int iop13xx_pci_setup(int nr, struct pci_sys_data *sys)
1002 if (nr > 1) 1002 if (nr > 1)
1003 return 0; 1003 return 0;
1004 1004
1005 res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL); 1005 res = kcalloc(2, sizeof(struct resource), GFP_KERNEL);
1006 if (!res) 1006 if (!res)
1007 panic("PCI: unable to alloc resources"); 1007 panic("PCI: unable to alloc resources");
1008 1008
1009 memset(res, 0, sizeof(struct resource) * 2);
1010 1009
1011 /* 'nr' assumptions: 1010 /* 'nr' assumptions:
1012 * ATUX is always 0 1011 * ATUX is always 0
diff --git a/arch/blackfin/mm/blackfin_sram.c b/arch/blackfin/mm/blackfin_sram.c
index 16c6169ed01b..b99ea883cd22 100644
--- a/arch/blackfin/mm/blackfin_sram.c
+++ b/arch/blackfin/mm/blackfin_sram.c
@@ -521,10 +521,9 @@ void *sram_alloc_with_lsl(size_t size, unsigned long flags)
521 struct sram_list_struct *lsl = NULL; 521 struct sram_list_struct *lsl = NULL;
522 struct mm_struct *mm = current->mm; 522 struct mm_struct *mm = current->mm;
523 523
524 lsl = kmalloc(sizeof(struct sram_list_struct), GFP_KERNEL); 524 lsl = kzalloc(sizeof(struct sram_list_struct), GFP_KERNEL);
525 if (!lsl) 525 if (!lsl)
526 return NULL; 526 return NULL;
527 memset(lsl, 0, sizeof(*lsl));
528 527
529 if (flags & L1_INST_SRAM) 528 if (flags & L1_INST_SRAM)
530 addr = l1_inst_sram_alloc(size); 529 addr = l1_inst_sram_alloc(size);
diff --git a/arch/cris/arch-v32/drivers/pci/dma.c b/arch/cris/arch-v32/drivers/pci/dma.c
index 832fc63504d4..66f9500fbc02 100644
--- a/arch/cris/arch-v32/drivers/pci/dma.c
+++ b/arch/cris/arch-v32/drivers/pci/dma.c
@@ -91,14 +91,12 @@ int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
91 if (!mem_base) 91 if (!mem_base)
92 goto out; 92 goto out;
93 93
94 dev->dma_mem = kmalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL); 94 dev->dma_mem = kzalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL);
95 if (!dev->dma_mem) 95 if (!dev->dma_mem)
96 goto out; 96 goto out;
97 memset(dev->dma_mem, 0, sizeof(struct dma_coherent_mem)); 97 dev->dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
98 dev->dma_mem->bitmap = kmalloc(bitmap_size, GFP_KERNEL);
99 if (!dev->dma_mem->bitmap) 98 if (!dev->dma_mem->bitmap)
100 goto free1_out; 99 goto free1_out;
101 memset(dev->dma_mem->bitmap, 0, bitmap_size);
102 100
103 dev->dma_mem->virt_base = mem_base; 101 dev->dma_mem->virt_base = mem_base;
104 dev->dma_mem->device_base = device_addr; 102 dev->dma_mem->device_base = device_addr;
diff --git a/arch/powerpc/kernel/lparcfg.c b/arch/powerpc/kernel/lparcfg.c
index c492cee90e0f..6444eaa30a2f 100644
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -248,7 +248,7 @@ static void parse_system_parameter_string(struct seq_file *m)
248 } else { 248 } else {
249 int splpar_strlen; 249 int splpar_strlen;
250 int idx, w_idx; 250 int idx, w_idx;
251 char *workbuffer = kmalloc(SPLPAR_MAXLENGTH, GFP_KERNEL); 251 char *workbuffer = kzalloc(SPLPAR_MAXLENGTH, GFP_KERNEL);
252 if (!workbuffer) { 252 if (!workbuffer) {
253 printk(KERN_ERR "%s %s kmalloc failure at line %d \n", 253 printk(KERN_ERR "%s %s kmalloc failure at line %d \n",
254 __FILE__, __FUNCTION__, __LINE__); 254 __FILE__, __FUNCTION__, __LINE__);
@@ -261,7 +261,6 @@ static void parse_system_parameter_string(struct seq_file *m)
261 splpar_strlen = local_buffer[0] * 256 + local_buffer[1]; 261 splpar_strlen = local_buffer[0] * 256 + local_buffer[1];
262 local_buffer += 2; /* step over strlen value */ 262 local_buffer += 2; /* step over strlen value */
263 263
264 memset(workbuffer, 0, SPLPAR_MAXLENGTH);
265 w_idx = 0; 264 w_idx = 0;
266 idx = 0; 265 idx = 0;
267 while ((*local_buffer) && (idx < splpar_strlen)) { 266 while ((*local_buffer) && (idx < splpar_strlen)) {
diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c
index 9536ed7f247c..8ded4e7dc87e 100644
--- a/arch/powerpc/kernel/of_platform.c
+++ b/arch/powerpc/kernel/of_platform.c
@@ -222,10 +222,9 @@ struct of_device* of_platform_device_create(struct device_node *np,
222{ 222{
223 struct of_device *dev; 223 struct of_device *dev;
224 224
225 dev = kmalloc(sizeof(*dev), GFP_KERNEL); 225 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
226 if (!dev) 226 if (!dev)
227 return NULL; 227 return NULL;
228 memset(dev, 0, sizeof(*dev));
229 228
230 dev->node = of_node_get(np); 229 dev->node = of_node_get(np);
231 dev->dma_mask = 0xffffffffUL; 230 dev->dma_mask = 0xffffffffUL;