aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wan
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 /drivers/net/wan
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 'drivers/net/wan')
-rw-r--r--drivers/net/wan/c101.c3
-rw-r--r--drivers/net/wan/cosa.c4
-rw-r--r--drivers/net/wan/cycx_main.c4
-rw-r--r--drivers/net/wan/cycx_x25.c3
-rw-r--r--drivers/net/wan/dscc4.c6
-rw-r--r--drivers/net/wan/farsync.c3
-rw-r--r--drivers/net/wan/hostess_sv11.c3
-rw-r--r--drivers/net/wan/n2.c3
-rw-r--r--drivers/net/wan/pc300_drv.c3
-rw-r--r--drivers/net/wan/pc300too.c3
-rw-r--r--drivers/net/wan/pci200syn.c3
-rw-r--r--drivers/net/wan/sdla.c3
-rw-r--r--drivers/net/wan/sealevel.c3
-rw-r--r--drivers/net/wan/wanxl.c3
-rw-r--r--drivers/net/wan/x25_asy.c4
15 files changed, 16 insertions, 35 deletions
diff --git a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c
index 6b63b350cd52..8ead774d14c8 100644
--- a/drivers/net/wan/c101.c
+++ b/drivers/net/wan/c101.c
@@ -315,12 +315,11 @@ static int __init c101_run(unsigned long irq, unsigned long winbase)
315 return -ENODEV; 315 return -ENODEV;
316 } 316 }
317 317
318 card = kmalloc(sizeof(card_t), GFP_KERNEL); 318 card = kzalloc(sizeof(card_t), GFP_KERNEL);
319 if (card == NULL) { 319 if (card == NULL) {
320 printk(KERN_ERR "c101: unable to allocate memory\n"); 320 printk(KERN_ERR "c101: unable to allocate memory\n");
321 return -ENOBUFS; 321 return -ENOBUFS;
322 } 322 }
323 memset(card, 0, sizeof(card_t));
324 323
325 card->dev = alloc_hdlcdev(card); 324 card->dev = alloc_hdlcdev(card);
326 if (!card->dev) { 325 if (!card->dev) {
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index 9ef49ce148b2..26058b4f8f36 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -572,13 +572,11 @@ static int cosa_probe(int base, int irq, int dma)
572 sprintf(cosa->name, "cosa%d", cosa->num); 572 sprintf(cosa->name, "cosa%d", cosa->num);
573 573
574 /* Initialize the per-channel data */ 574 /* Initialize the per-channel data */
575 cosa->chan = kmalloc(sizeof(struct channel_data)*cosa->nchannels, 575 cosa->chan = kcalloc(cosa->nchannels, sizeof(struct channel_data), GFP_KERNEL);
576 GFP_KERNEL);
577 if (!cosa->chan) { 576 if (!cosa->chan) {
578 err = -ENOMEM; 577 err = -ENOMEM;
579 goto err_out3; 578 goto err_out3;
580 } 579 }
581 memset(cosa->chan, 0, sizeof(struct channel_data)*cosa->nchannels);
582 for (i=0; i<cosa->nchannels; i++) { 580 for (i=0; i<cosa->nchannels; i++) {
583 cosa->chan[i].cosa = cosa; 581 cosa->chan[i].cosa = cosa;
584 cosa->chan[i].num = i; 582 cosa->chan[i].num = i;
diff --git a/drivers/net/wan/cycx_main.c b/drivers/net/wan/cycx_main.c
index 6e5f1c898517..a0e8611ad8e8 100644
--- a/drivers/net/wan/cycx_main.c
+++ b/drivers/net/wan/cycx_main.c
@@ -113,12 +113,10 @@ static int __init cycx_init(void)
113 /* Verify number of cards and allocate adapter data space */ 113 /* Verify number of cards and allocate adapter data space */
114 cycx_ncards = min_t(int, cycx_ncards, CYCX_MAX_CARDS); 114 cycx_ncards = min_t(int, cycx_ncards, CYCX_MAX_CARDS);
115 cycx_ncards = max_t(int, cycx_ncards, 1); 115 cycx_ncards = max_t(int, cycx_ncards, 1);
116 cycx_card_array = kmalloc(sizeof(struct cycx_device) * cycx_ncards, 116 cycx_card_array = kcalloc(cycx_ncards, sizeof(struct cycx_device), GFP_KERNEL);
117 GFP_KERNEL);
118 if (!cycx_card_array) 117 if (!cycx_card_array)
119 goto out; 118 goto out;
120 119
121 memset(cycx_card_array, 0, sizeof(struct cycx_device) * cycx_ncards);
122 120
123 /* Register adapters with WAN router */ 121 /* Register adapters with WAN router */
124 for (cnt = 0; cnt < cycx_ncards; ++cnt) { 122 for (cnt = 0; cnt < cycx_ncards; ++cnt) {
diff --git a/drivers/net/wan/cycx_x25.c b/drivers/net/wan/cycx_x25.c
index 016b3ff3ea5e..a8af28b273d3 100644
--- a/drivers/net/wan/cycx_x25.c
+++ b/drivers/net/wan/cycx_x25.c
@@ -376,11 +376,10 @@ static int cycx_wan_new_if(struct wan_device *wandev, struct net_device *dev,
376 } 376 }
377 377
378 /* allocate and initialize private data */ 378 /* allocate and initialize private data */
379 chan = kmalloc(sizeof(struct cycx_x25_channel), GFP_KERNEL); 379 chan = kzalloc(sizeof(struct cycx_x25_channel), GFP_KERNEL);
380 if (!chan) 380 if (!chan)
381 return -ENOMEM; 381 return -ENOMEM;
382 382
383 memset(chan, 0, sizeof(*chan));
384 strcpy(chan->name, conf->name); 383 strcpy(chan->name, conf->name);
385 chan->card = card; 384 chan->card = card;
386 chan->link = conf->port; 385 chan->link = conf->port;
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index dca024471455..50d2f9108dca 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -890,12 +890,11 @@ static int dscc4_found1(struct pci_dev *pdev, void __iomem *ioaddr)
890 struct dscc4_dev_priv *root; 890 struct dscc4_dev_priv *root;
891 int i, ret = -ENOMEM; 891 int i, ret = -ENOMEM;
892 892
893 root = kmalloc(dev_per_card*sizeof(*root), GFP_KERNEL); 893 root = kcalloc(dev_per_card, sizeof(*root), GFP_KERNEL);
894 if (!root) { 894 if (!root) {
895 printk(KERN_ERR "%s: can't allocate data\n", DRV_NAME); 895 printk(KERN_ERR "%s: can't allocate data\n", DRV_NAME);
896 goto err_out; 896 goto err_out;
897 } 897 }
898 memset(root, 0, dev_per_card*sizeof(*root));
899 898
900 for (i = 0; i < dev_per_card; i++) { 899 for (i = 0; i < dev_per_card; i++) {
901 root[i].dev = alloc_hdlcdev(root + i); 900 root[i].dev = alloc_hdlcdev(root + i);
@@ -903,12 +902,11 @@ static int dscc4_found1(struct pci_dev *pdev, void __iomem *ioaddr)
903 goto err_free_dev; 902 goto err_free_dev;
904 } 903 }
905 904
906 ppriv = kmalloc(sizeof(*ppriv), GFP_KERNEL); 905 ppriv = kzalloc(sizeof(*ppriv), GFP_KERNEL);
907 if (!ppriv) { 906 if (!ppriv) {
908 printk(KERN_ERR "%s: can't allocate private data\n", DRV_NAME); 907 printk(KERN_ERR "%s: can't allocate private data\n", DRV_NAME);
909 goto err_free_dev; 908 goto err_free_dev;
910 } 909 }
911 memset(ppriv, 0, sizeof(struct dscc4_pci_priv));
912 910
913 ppriv->root = root; 911 ppriv->root = root;
914 spin_lock_init(&ppriv->lock); 912 spin_lock_init(&ppriv->lock);
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index 58a53b6d9b42..12dae8e24844 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -2476,13 +2476,12 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2476 } 2476 }
2477 2477
2478 /* Allocate driver private data */ 2478 /* Allocate driver private data */
2479 card = kmalloc(sizeof (struct fst_card_info), GFP_KERNEL); 2479 card = kzalloc(sizeof (struct fst_card_info), GFP_KERNEL);
2480 if (card == NULL) { 2480 if (card == NULL) {
2481 printk_err("FarSync card found but insufficient memory for" 2481 printk_err("FarSync card found but insufficient memory for"
2482 " driver storage\n"); 2482 " driver storage\n");
2483 return -ENOMEM; 2483 return -ENOMEM;
2484 } 2484 }
2485 memset(card, 0, sizeof (struct fst_card_info));
2486 2485
2487 /* Try to enable the device */ 2486 /* Try to enable the device */
2488 if ((err = pci_enable_device(pdev)) != 0) { 2487 if ((err = pci_enable_device(pdev)) != 0) {
diff --git a/drivers/net/wan/hostess_sv11.c b/drivers/net/wan/hostess_sv11.c
index 9ba3e4ee6ec7..bf5f8d9b5c83 100644
--- a/drivers/net/wan/hostess_sv11.c
+++ b/drivers/net/wan/hostess_sv11.c
@@ -231,11 +231,10 @@ static struct sv11_device *sv11_init(int iobase, int irq)
231 return NULL; 231 return NULL;
232 } 232 }
233 233
234 sv = kmalloc(sizeof(struct sv11_device), GFP_KERNEL); 234 sv = kzalloc(sizeof(struct sv11_device), GFP_KERNEL);
235 if(!sv) 235 if(!sv)
236 goto fail3; 236 goto fail3;
237 237
238 memset(sv, 0, sizeof(*sv));
239 sv->if_ptr=&sv->netdev; 238 sv->if_ptr=&sv->netdev;
240 239
241 sv->netdev.dev = alloc_netdev(0, "hdlc%d", sv11_setup); 240 sv->netdev.dev = alloc_netdev(0, "hdlc%d", sv11_setup);
diff --git a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c
index 5c322dfb79f6..cbdf0b748bde 100644
--- a/drivers/net/wan/n2.c
+++ b/drivers/net/wan/n2.c
@@ -351,12 +351,11 @@ static int __init n2_run(unsigned long io, unsigned long irq,
351 return -ENODEV; 351 return -ENODEV;
352 } 352 }
353 353
354 card = kmalloc(sizeof(card_t), GFP_KERNEL); 354 card = kzalloc(sizeof(card_t), GFP_KERNEL);
355 if (card == NULL) { 355 if (card == NULL) {
356 printk(KERN_ERR "n2: unable to allocate memory\n"); 356 printk(KERN_ERR "n2: unable to allocate memory\n");
357 return -ENOBUFS; 357 return -ENOBUFS;
358 } 358 }
359 memset(card, 0, sizeof(card_t));
360 359
361 card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); 360 card->ports[0].dev = alloc_hdlcdev(&card->ports[0]);
362 card->ports[1].dev = alloc_hdlcdev(&card->ports[1]); 361 card->ports[1].dev = alloc_hdlcdev(&card->ports[1]);
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index 5d8c78ee2cd9..99fee2f1d019 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -3456,7 +3456,7 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3456 if ((err = pci_enable_device(pdev)) < 0) 3456 if ((err = pci_enable_device(pdev)) < 0)
3457 return err; 3457 return err;
3458 3458
3459 card = kmalloc(sizeof(pc300_t), GFP_KERNEL); 3459 card = kzalloc(sizeof(pc300_t), GFP_KERNEL);
3460 if (card == NULL) { 3460 if (card == NULL) {
3461 printk("PC300 found at RAM 0x%016llx, " 3461 printk("PC300 found at RAM 0x%016llx, "
3462 "but could not allocate card structure.\n", 3462 "but could not allocate card structure.\n",
@@ -3464,7 +3464,6 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3464 err = -ENOMEM; 3464 err = -ENOMEM;
3465 goto err_disable_dev; 3465 goto err_disable_dev;
3466 } 3466 }
3467 memset(card, 0, sizeof(pc300_t));
3468 3467
3469 err = -ENODEV; 3468 err = -ENODEV;
3470 3469
diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c
index dfbd3b00f03b..6353cb5c658d 100644
--- a/drivers/net/wan/pc300too.c
+++ b/drivers/net/wan/pc300too.c
@@ -334,14 +334,13 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev,
334 return i; 334 return i;
335 } 335 }
336 336
337 card = kmalloc(sizeof(card_t), GFP_KERNEL); 337 card = kzalloc(sizeof(card_t), GFP_KERNEL);
338 if (card == NULL) { 338 if (card == NULL) {
339 printk(KERN_ERR "pc300: unable to allocate memory\n"); 339 printk(KERN_ERR "pc300: unable to allocate memory\n");
340 pci_release_regions(pdev); 340 pci_release_regions(pdev);
341 pci_disable_device(pdev); 341 pci_disable_device(pdev);
342 return -ENOBUFS; 342 return -ENOBUFS;
343 } 343 }
344 memset(card, 0, sizeof(card_t));
345 pci_set_drvdata(pdev, card); 344 pci_set_drvdata(pdev, card);
346 345
347 if (pdev->device == PCI_DEVICE_ID_PC300_TE_1 || 346 if (pdev->device == PCI_DEVICE_ID_PC300_TE_1 ||
diff --git a/drivers/net/wan/pci200syn.c b/drivers/net/wan/pci200syn.c
index 7f720de2e9f0..092e51d89036 100644
--- a/drivers/net/wan/pci200syn.c
+++ b/drivers/net/wan/pci200syn.c
@@ -312,14 +312,13 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
312 return i; 312 return i;
313 } 313 }
314 314
315 card = kmalloc(sizeof(card_t), GFP_KERNEL); 315 card = kzalloc(sizeof(card_t), GFP_KERNEL);
316 if (card == NULL) { 316 if (card == NULL) {
317 printk(KERN_ERR "pci200syn: unable to allocate memory\n"); 317 printk(KERN_ERR "pci200syn: unable to allocate memory\n");
318 pci_release_regions(pdev); 318 pci_release_regions(pdev);
319 pci_disable_device(pdev); 319 pci_disable_device(pdev);
320 return -ENOBUFS; 320 return -ENOBUFS;
321 } 321 }
322 memset(card, 0, sizeof(card_t));
323 pci_set_drvdata(pdev, card); 322 pci_set_drvdata(pdev, card);
324 card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); 323 card->ports[0].dev = alloc_hdlcdev(&card->ports[0]);
325 card->ports[1].dev = alloc_hdlcdev(&card->ports[1]); 324 card->ports[1].dev = alloc_hdlcdev(&card->ports[1]);
diff --git a/drivers/net/wan/sdla.c b/drivers/net/wan/sdla.c
index 6a485f0556f4..792e588d7d61 100644
--- a/drivers/net/wan/sdla.c
+++ b/drivers/net/wan/sdla.c
@@ -1196,10 +1196,9 @@ static int sdla_xfer(struct net_device *dev, struct sdla_mem __user *info, int r
1196 1196
1197 if (read) 1197 if (read)
1198 { 1198 {
1199 temp = kmalloc(mem.len, GFP_KERNEL); 1199 temp = kzalloc(mem.len, GFP_KERNEL);
1200 if (!temp) 1200 if (!temp)
1201 return(-ENOMEM); 1201 return(-ENOMEM);
1202 memset(temp, 0, mem.len);
1203 sdla_read(dev, mem.addr, temp, mem.len); 1202 sdla_read(dev, mem.addr, temp, mem.len);
1204 if(copy_to_user(mem.data, temp, mem.len)) 1203 if(copy_to_user(mem.data, temp, mem.len))
1205 { 1204 {
diff --git a/drivers/net/wan/sealevel.c b/drivers/net/wan/sealevel.c
index 131358108c5a..11276bf3149f 100644
--- a/drivers/net/wan/sealevel.c
+++ b/drivers/net/wan/sealevel.c
@@ -270,11 +270,10 @@ static __init struct slvl_board *slvl_init(int iobase, int irq,
270 return NULL; 270 return NULL;
271 } 271 }
272 272
273 b = kmalloc(sizeof(struct slvl_board), GFP_KERNEL); 273 b = kzalloc(sizeof(struct slvl_board), GFP_KERNEL);
274 if(!b) 274 if(!b)
275 goto fail3; 275 goto fail3;
276 276
277 memset(b, 0, sizeof(*b));
278 if (!(b->dev[0]= slvl_alloc(iobase, irq))) 277 if (!(b->dev[0]= slvl_alloc(iobase, irq)))
279 goto fail2; 278 goto fail2;
280 279
diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c
index c73601574334..3c78f9856380 100644
--- a/drivers/net/wan/wanxl.c
+++ b/drivers/net/wan/wanxl.c
@@ -599,7 +599,7 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev,
599 } 599 }
600 600
601 alloc_size = sizeof(card_t) + ports * sizeof(port_t); 601 alloc_size = sizeof(card_t) + ports * sizeof(port_t);
602 card = kmalloc(alloc_size, GFP_KERNEL); 602 card = kzalloc(alloc_size, GFP_KERNEL);
603 if (card == NULL) { 603 if (card == NULL) {
604 printk(KERN_ERR "wanXL %s: unable to allocate memory\n", 604 printk(KERN_ERR "wanXL %s: unable to allocate memory\n",
605 pci_name(pdev)); 605 pci_name(pdev));
@@ -607,7 +607,6 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev,
607 pci_disable_device(pdev); 607 pci_disable_device(pdev);
608 return -ENOBUFS; 608 return -ENOBUFS;
609 } 609 }
610 memset(card, 0, alloc_size);
611 610
612 pci_set_drvdata(pdev, card); 611 pci_set_drvdata(pdev, card);
613 card->pdev = pdev; 612 card->pdev = pdev;
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 1c9edd97accd..c48b1cc63fd5 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -786,14 +786,12 @@ static int __init init_x25_asy(void)
786 printk(KERN_INFO "X.25 async: version 0.00 ALPHA " 786 printk(KERN_INFO "X.25 async: version 0.00 ALPHA "
787 "(dynamic channels, max=%d).\n", x25_asy_maxdev ); 787 "(dynamic channels, max=%d).\n", x25_asy_maxdev );
788 788
789 x25_asy_devs = kmalloc(sizeof(struct net_device *)*x25_asy_maxdev, 789 x25_asy_devs = kcalloc(x25_asy_maxdev, sizeof(struct net_device*), GFP_KERNEL);
790 GFP_KERNEL);
791 if (!x25_asy_devs) { 790 if (!x25_asy_devs) {
792 printk(KERN_WARNING "X25 async: Can't allocate x25_asy_ctrls[] " 791 printk(KERN_WARNING "X25 async: Can't allocate x25_asy_ctrls[] "
793 "array! Uaargh! (-> No X.25 available)\n"); 792 "array! Uaargh! (-> No X.25 available)\n");
794 return -ENOMEM; 793 return -ENOMEM;
795 } 794 }
796 memset(x25_asy_devs, 0, sizeof(struct net_device *)*x25_asy_maxdev);
797 795
798 return tty_register_ldisc(N_X25, &x25_ldisc); 796 return tty_register_ldisc(N_X25, &x25_ldisc);
799} 797}