aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
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/char
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/char')
-rw-r--r--drivers/char/amiserial.c3
-rw-r--r--drivers/char/drm/via_dmablit.c3
-rw-r--r--drivers/char/esp.c6
-rw-r--r--drivers/char/hvcs.c4
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c3
-rw-r--r--drivers/char/pcmcia/synclink_cs.c3
-rw-r--r--drivers/char/rio/rio_linux.c4
-rw-r--r--drivers/char/rio/riocmd.c4
-rw-r--r--drivers/char/rio/riotable.c3
-rw-r--r--drivers/char/rocket.c3
-rw-r--r--drivers/char/synclink.c3
-rw-r--r--drivers/char/synclink_gt.c3
-rw-r--r--drivers/char/synclinkmp.c3
-rw-r--r--drivers/char/watchdog/mpcore_wdt.c3
-rw-r--r--drivers/char/watchdog/pcwd_usb.c3
15 files changed, 16 insertions, 35 deletions
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index 7b02bf1289a2..3d468f502d2d 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -1721,12 +1721,11 @@ static int get_async_struct(int line, struct async_struct **ret_info)
1721 *ret_info = sstate->info; 1721 *ret_info = sstate->info;
1722 return 0; 1722 return 0;
1723 } 1723 }
1724 info = kmalloc(sizeof(struct async_struct), GFP_KERNEL); 1724 info = kzalloc(sizeof(struct async_struct), GFP_KERNEL);
1725 if (!info) { 1725 if (!info) {
1726 sstate->count--; 1726 sstate->count--;
1727 return -ENOMEM; 1727 return -ENOMEM;
1728 } 1728 }
1729 memset(info, 0, sizeof(struct async_struct));
1730#ifdef DECLARE_WAITQUEUE 1729#ifdef DECLARE_WAITQUEUE
1731 init_waitqueue_head(&info->open_wait); 1730 init_waitqueue_head(&info->open_wait);
1732 init_waitqueue_head(&info->close_wait); 1731 init_waitqueue_head(&info->close_wait);
diff --git a/drivers/char/drm/via_dmablit.c b/drivers/char/drm/via_dmablit.c
index fdb8609dd76f..832de1d9ba7e 100644
--- a/drivers/char/drm/via_dmablit.c
+++ b/drivers/char/drm/via_dmablit.c
@@ -273,10 +273,9 @@ via_alloc_desc_pages(drm_via_sg_info_t *vsg)
273 vsg->num_desc_pages = (vsg->num_desc + vsg->descriptors_per_page - 1) / 273 vsg->num_desc_pages = (vsg->num_desc + vsg->descriptors_per_page - 1) /
274 vsg->descriptors_per_page; 274 vsg->descriptors_per_page;
275 275
276 if (NULL == (vsg->desc_pages = kmalloc(sizeof(void *) * vsg->num_desc_pages, GFP_KERNEL))) 276 if (NULL == (vsg->desc_pages = kcalloc(vsg->num_desc_pages, sizeof(void *), GFP_KERNEL)))
277 return DRM_ERR(ENOMEM); 277 return DRM_ERR(ENOMEM);
278 278
279 memset(vsg->desc_pages, 0, sizeof(void *) * vsg->num_desc_pages);
280 vsg->state = dr_via_desc_pages_alloc; 279 vsg->state = dr_via_desc_pages_alloc;
281 for (i=0; i<vsg->num_desc_pages; ++i) { 280 for (i=0; i<vsg->num_desc_pages; ++i) {
282 if (NULL == (vsg->desc_pages[i] = 281 if (NULL == (vsg->desc_pages[i] =
diff --git a/drivers/char/esp.c b/drivers/char/esp.c
index 74cd5118af57..2e7ae42a5503 100644
--- a/drivers/char/esp.c
+++ b/drivers/char/esp.c
@@ -2459,7 +2459,7 @@ static int __init espserial_init(void)
2459 return 1; 2459 return 1;
2460 } 2460 }
2461 2461
2462 info = kmalloc(sizeof(struct esp_struct), GFP_KERNEL); 2462 info = kzalloc(sizeof(struct esp_struct), GFP_KERNEL);
2463 2463
2464 if (!info) 2464 if (!info)
2465 { 2465 {
@@ -2469,7 +2469,6 @@ static int __init espserial_init(void)
2469 return 1; 2469 return 1;
2470 } 2470 }
2471 2471
2472 memset((void *)info, 0, sizeof(struct esp_struct));
2473 spin_lock_init(&info->lock); 2472 spin_lock_init(&info->lock);
2474 /* rx_trigger, tx_trigger are needed by autoconfig */ 2473 /* rx_trigger, tx_trigger are needed by autoconfig */
2475 info->config.rx_trigger = rx_trigger; 2474 info->config.rx_trigger = rx_trigger;
@@ -2527,7 +2526,7 @@ static int __init espserial_init(void)
2527 if (!dma) 2526 if (!dma)
2528 info->stat_flags |= ESP_STAT_NEVER_DMA; 2527 info->stat_flags |= ESP_STAT_NEVER_DMA;
2529 2528
2530 info = kmalloc(sizeof(struct esp_struct), GFP_KERNEL); 2529 info = kzalloc(sizeof(struct esp_struct), GFP_KERNEL);
2531 if (!info) 2530 if (!info)
2532 { 2531 {
2533 printk(KERN_ERR "Couldn't allocate memory for esp serial device information\n"); 2532 printk(KERN_ERR "Couldn't allocate memory for esp serial device information\n");
@@ -2536,7 +2535,6 @@ static int __init espserial_init(void)
2536 return 0; 2535 return 0;
2537 } 2536 }
2538 2537
2539 memset((void *)info, 0, sizeof(struct esp_struct));
2540 /* rx_trigger, tx_trigger are needed by autoconfig */ 2538 /* rx_trigger, tx_trigger are needed by autoconfig */
2541 info->config.rx_trigger = rx_trigger; 2539 info->config.rx_trigger = rx_trigger;
2542 info->config.tx_trigger = tx_trigger; 2540 info->config.tx_trigger = tx_trigger;
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index 207f7343ba60..17f96e04266f 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -784,12 +784,10 @@ static int __devinit hvcs_probe(
784 return -EFAULT; 784 return -EFAULT;
785 } 785 }
786 786
787 hvcsd = kmalloc(sizeof(*hvcsd), GFP_KERNEL); 787 hvcsd = kzalloc(sizeof(*hvcsd), GFP_KERNEL);
788 if (!hvcsd) 788 if (!hvcsd)
789 return -ENODEV; 789 return -ENODEV;
790 790
791 /* hvcsd->tty is zeroed out with the memset */
792 memset(hvcsd, 0x00, sizeof(*hvcsd));
793 791
794 spin_lock_init(&hvcsd->lock); 792 spin_lock_init(&hvcsd->lock);
795 /* Automatically incs the refcount the first time */ 793 /* Automatically incs the refcount the first time */
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index b5df7e61aeb2..6a01dd9e43f8 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -2639,10 +2639,9 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2639 return -ENODEV; 2639 return -ENODEV;
2640 } 2640 }
2641 2641
2642 intf = kmalloc(sizeof(*intf), GFP_KERNEL); 2642 intf = kzalloc(sizeof(*intf), GFP_KERNEL);
2643 if (!intf) 2643 if (!intf)
2644 return -ENOMEM; 2644 return -ENOMEM;
2645 memset(intf, 0, sizeof(*intf));
2646 2645
2647 intf->ipmi_version_major = ipmi_version_major(device_id); 2646 intf->ipmi_version_major = ipmi_version_major(device_id);
2648 intf->ipmi_version_minor = ipmi_version_minor(device_id); 2647 intf->ipmi_version_minor = ipmi_version_minor(device_id);
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 13808f6083a0..2b889317461e 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -540,13 +540,12 @@ static int mgslpc_probe(struct pcmcia_device *link)
540 if (debug_level >= DEBUG_LEVEL_INFO) 540 if (debug_level >= DEBUG_LEVEL_INFO)
541 printk("mgslpc_attach\n"); 541 printk("mgslpc_attach\n");
542 542
543 info = kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL); 543 info = kzalloc(sizeof(MGSLPC_INFO), GFP_KERNEL);
544 if (!info) { 544 if (!info) {
545 printk("Error can't allocate device instance data\n"); 545 printk("Error can't allocate device instance data\n");
546 return -ENOMEM; 546 return -ENOMEM;
547 } 547 }
548 548
549 memset(info, 0, sizeof(MGSLPC_INFO));
550 info->magic = MGSLPC_MAGIC; 549 info->magic = MGSLPC_MAGIC;
551 INIT_WORK(&info->task, bh_handler); 550 INIT_WORK(&info->task, bh_handler);
552 info->max_frame_size = 4096; 551 info->max_frame_size = 4096;
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index 294e9cb0c449..0ce96670f979 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -803,9 +803,7 @@ static void *ckmalloc(int size)
803{ 803{
804 void *p; 804 void *p;
805 805
806 p = kmalloc(size, GFP_KERNEL); 806 p = kzalloc(size, GFP_KERNEL);
807 if (p)
808 memset(p, 0, size);
809 return p; 807 return p;
810} 808}
811 809
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
index 8cc60b693460..7321d002c34f 100644
--- a/drivers/char/rio/riocmd.c
+++ b/drivers/char/rio/riocmd.c
@@ -556,9 +556,7 @@ struct CmdBlk *RIOGetCmdBlk(void)
556{ 556{
557 struct CmdBlk *CmdBlkP; 557 struct CmdBlk *CmdBlkP;
558 558
559 CmdBlkP = kmalloc(sizeof(struct CmdBlk), GFP_ATOMIC); 559 CmdBlkP = kzalloc(sizeof(struct CmdBlk), GFP_ATOMIC);
560 if (CmdBlkP)
561 memset(CmdBlkP, 0, sizeof(struct CmdBlk));
562 return CmdBlkP; 560 return CmdBlkP;
563} 561}
564 562
diff --git a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c
index 7e988357326e..991119c9f473 100644
--- a/drivers/char/rio/riotable.c
+++ b/drivers/char/rio/riotable.c
@@ -863,8 +863,7 @@ int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP)
863 if (PortP->TxRingBuffer) 863 if (PortP->TxRingBuffer)
864 memset(PortP->TxRingBuffer, 0, p->RIOBufferSize); 864 memset(PortP->TxRingBuffer, 0, p->RIOBufferSize);
865 else if (p->RIOBufferSize) { 865 else if (p->RIOBufferSize) {
866 PortP->TxRingBuffer = kmalloc(p->RIOBufferSize, GFP_KERNEL); 866 PortP->TxRingBuffer = kzalloc(p->RIOBufferSize, GFP_KERNEL);
867 memset(PortP->TxRingBuffer, 0, p->RIOBufferSize);
868 } 867 }
869 PortP->TxBufferOut = 0; 868 PortP->TxBufferOut = 0;
870 PortP->TxBufferIn = 0; 869 PortP->TxBufferIn = 0;
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index 0270080ff0c0..56cbba7b6ec0 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -635,12 +635,11 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
635 ctlp = sCtlNumToCtlPtr(board); 635 ctlp = sCtlNumToCtlPtr(board);
636 636
637 /* Get a r_port struct for the port, fill it in and save it globally, indexed by line number */ 637 /* Get a r_port struct for the port, fill it in and save it globally, indexed by line number */
638 info = kmalloc(sizeof (struct r_port), GFP_KERNEL); 638 info = kzalloc(sizeof (struct r_port), GFP_KERNEL);
639 if (!info) { 639 if (!info) {
640 printk(KERN_INFO "Couldn't allocate info struct for line #%d\n", line); 640 printk(KERN_INFO "Couldn't allocate info struct for line #%d\n", line);
641 return; 641 return;
642 } 642 }
643 memset(info, 0, sizeof (struct r_port));
644 643
645 info->magic = RPORT_MAGIC; 644 info->magic = RPORT_MAGIC;
646 info->line = line; 645 info->line = line;
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index f53e51ddb9d7..fdc256b380b8 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -4324,13 +4324,12 @@ static struct mgsl_struct* mgsl_allocate_device(void)
4324{ 4324{
4325 struct mgsl_struct *info; 4325 struct mgsl_struct *info;
4326 4326
4327 info = kmalloc(sizeof(struct mgsl_struct), 4327 info = kzalloc(sizeof(struct mgsl_struct),
4328 GFP_KERNEL); 4328 GFP_KERNEL);
4329 4329
4330 if (!info) { 4330 if (!info) {
4331 printk("Error can't allocate device instance data\n"); 4331 printk("Error can't allocate device instance data\n");
4332 } else { 4332 } else {
4333 memset(info, 0, sizeof(struct mgsl_struct));
4334 info->magic = MGSL_MAGIC; 4333 info->magic = MGSL_MAGIC;
4335 INIT_WORK(&info->task, mgsl_bh_handler); 4334 INIT_WORK(&info->task, mgsl_bh_handler);
4336 info->max_frame_size = 4096; 4335 info->max_frame_size = 4096;
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index 428b514201f4..372a37e25620 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -3414,13 +3414,12 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev
3414{ 3414{
3415 struct slgt_info *info; 3415 struct slgt_info *info;
3416 3416
3417 info = kmalloc(sizeof(struct slgt_info), GFP_KERNEL); 3417 info = kzalloc(sizeof(struct slgt_info), GFP_KERNEL);
3418 3418
3419 if (!info) { 3419 if (!info) {
3420 DBGERR(("%s device alloc failed adapter=%d port=%d\n", 3420 DBGERR(("%s device alloc failed adapter=%d port=%d\n",
3421 driver_name, adapter_num, port_num)); 3421 driver_name, adapter_num, port_num));
3422 } else { 3422 } else {
3423 memset(info, 0, sizeof(struct slgt_info));
3424 info->magic = MGSL_MAGIC; 3423 info->magic = MGSL_MAGIC;
3425 INIT_WORK(&info->task, bh_handler); 3424 INIT_WORK(&info->task, bh_handler);
3426 info->max_frame_size = 4096; 3425 info->max_frame_size = 4096;
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index a65407b32079..c63013b2fc36 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -3786,14 +3786,13 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev)
3786{ 3786{
3787 SLMP_INFO *info; 3787 SLMP_INFO *info;
3788 3788
3789 info = kmalloc(sizeof(SLMP_INFO), 3789 info = kzalloc(sizeof(SLMP_INFO),
3790 GFP_KERNEL); 3790 GFP_KERNEL);
3791 3791
3792 if (!info) { 3792 if (!info) {
3793 printk("%s(%d) Error can't allocate device instance data for adapter %d, port %d\n", 3793 printk("%s(%d) Error can't allocate device instance data for adapter %d, port %d\n",
3794 __FILE__,__LINE__, adapter_num, port_num); 3794 __FILE__,__LINE__, adapter_num, port_num);
3795 } else { 3795 } else {
3796 memset(info, 0, sizeof(SLMP_INFO));
3797 info->magic = MGSL_MAGIC; 3796 info->magic = MGSL_MAGIC;
3798 INIT_WORK(&info->task, bh_handler); 3797 INIT_WORK(&info->task, bh_handler);
3799 info->max_frame_size = 4096; 3798 info->max_frame_size = 4096;
diff --git a/drivers/char/watchdog/mpcore_wdt.c b/drivers/char/watchdog/mpcore_wdt.c
index e88947f8fe53..0d2b27735419 100644
--- a/drivers/char/watchdog/mpcore_wdt.c
+++ b/drivers/char/watchdog/mpcore_wdt.c
@@ -328,12 +328,11 @@ static int __devinit mpcore_wdt_probe(struct platform_device *dev)
328 goto err_out; 328 goto err_out;
329 } 329 }
330 330
331 wdt = kmalloc(sizeof(struct mpcore_wdt), GFP_KERNEL); 331 wdt = kzalloc(sizeof(struct mpcore_wdt), GFP_KERNEL);
332 if (!wdt) { 332 if (!wdt) {
333 ret = -ENOMEM; 333 ret = -ENOMEM;
334 goto err_out; 334 goto err_out;
335 } 335 }
336 memset(wdt, 0, sizeof(struct mpcore_wdt));
337 336
338 wdt->dev = &dev->dev; 337 wdt->dev = &dev->dev;
339 wdt->irq = platform_get_irq(dev, 0); 338 wdt->irq = platform_get_irq(dev, 0);
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c
index 1e7a6719d5ba..0f3fd6c9c354 100644
--- a/drivers/char/watchdog/pcwd_usb.c
+++ b/drivers/char/watchdog/pcwd_usb.c
@@ -626,12 +626,11 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
626 maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 626 maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
627 627
628 /* allocate memory for our device and initialize it */ 628 /* allocate memory for our device and initialize it */
629 usb_pcwd = kmalloc (sizeof(struct usb_pcwd_private), GFP_KERNEL); 629 usb_pcwd = kzalloc (sizeof(struct usb_pcwd_private), GFP_KERNEL);
630 if (usb_pcwd == NULL) { 630 if (usb_pcwd == NULL) {
631 printk(KERN_ERR PFX "Out of memory\n"); 631 printk(KERN_ERR PFX "Out of memory\n");
632 goto error; 632 goto error;
633 } 633 }
634 memset (usb_pcwd, 0x00, sizeof (*usb_pcwd));
635 634
636 usb_pcwd_device = usb_pcwd; 635 usb_pcwd_device = usb_pcwd;
637 636