aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/megaraid
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/scsi/megaraid
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/scsi/megaraid')
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c14
-rw-r--r--drivers/scsi/megaraid/megaraid_mm.c3
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.c4
3 files changed, 6 insertions, 15 deletions
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index c46685a03a9f..c6a53dccc16a 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -454,7 +454,7 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
454 pci_set_master(pdev); 454 pci_set_master(pdev);
455 455
456 // Allocate the per driver initialization structure 456 // Allocate the per driver initialization structure
457 adapter = kmalloc(sizeof(adapter_t), GFP_KERNEL); 457 adapter = kzalloc(sizeof(adapter_t), GFP_KERNEL);
458 458
459 if (adapter == NULL) { 459 if (adapter == NULL) {
460 con_log(CL_ANN, (KERN_WARNING 460 con_log(CL_ANN, (KERN_WARNING
@@ -462,7 +462,6 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
462 462
463 goto out_probe_one; 463 goto out_probe_one;
464 } 464 }
465 memset(adapter, 0, sizeof(adapter_t));
466 465
467 466
468 // set up PCI related soft state and other pre-known parameters 467 // set up PCI related soft state and other pre-known parameters
@@ -746,10 +745,9 @@ megaraid_init_mbox(adapter_t *adapter)
746 * Allocate and initialize the init data structure for mailbox 745 * Allocate and initialize the init data structure for mailbox
747 * controllers 746 * controllers
748 */ 747 */
749 raid_dev = kmalloc(sizeof(mraid_device_t), GFP_KERNEL); 748 raid_dev = kzalloc(sizeof(mraid_device_t), GFP_KERNEL);
750 if (raid_dev == NULL) return -1; 749 if (raid_dev == NULL) return -1;
751 750
752 memset(raid_dev, 0, sizeof(mraid_device_t));
753 751
754 /* 752 /*
755 * Attach the adapter soft state to raid device soft state 753 * Attach the adapter soft state to raid device soft state
@@ -1050,8 +1048,7 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
1050 * since the calling routine does not yet know the number of available 1048 * since the calling routine does not yet know the number of available
1051 * commands. 1049 * commands.
1052 */ 1050 */
1053 adapter->kscb_list = kmalloc(sizeof(scb_t) * MBOX_MAX_SCSI_CMDS, 1051 adapter->kscb_list = kcalloc(MBOX_MAX_SCSI_CMDS, sizeof(scb_t), GFP_KERNEL);
1054 GFP_KERNEL);
1055 1052
1056 if (adapter->kscb_list == NULL) { 1053 if (adapter->kscb_list == NULL) {
1057 con_log(CL_ANN, (KERN_WARNING 1054 con_log(CL_ANN, (KERN_WARNING
@@ -1059,7 +1056,6 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
1059 __LINE__)); 1056 __LINE__));
1060 goto out_free_ibuf; 1057 goto out_free_ibuf;
1061 } 1058 }
1062 memset(adapter->kscb_list, 0, sizeof(scb_t) * MBOX_MAX_SCSI_CMDS);
1063 1059
1064 // memory allocation for our command packets 1060 // memory allocation for our command packets
1065 if (megaraid_mbox_setup_dma_pools(adapter) != 0) { 1061 if (megaraid_mbox_setup_dma_pools(adapter) != 0) {
@@ -3495,8 +3491,7 @@ megaraid_cmm_register(adapter_t *adapter)
3495 int i; 3491 int i;
3496 3492
3497 // Allocate memory for the base list of scb for management module. 3493 // Allocate memory for the base list of scb for management module.
3498 adapter->uscb_list = kmalloc(sizeof(scb_t) * MBOX_MAX_USER_CMDS, 3494 adapter->uscb_list = kcalloc(MBOX_MAX_USER_CMDS, sizeof(scb_t), GFP_KERNEL);
3499 GFP_KERNEL);
3500 3495
3501 if (adapter->uscb_list == NULL) { 3496 if (adapter->uscb_list == NULL) {
3502 con_log(CL_ANN, (KERN_WARNING 3497 con_log(CL_ANN, (KERN_WARNING
@@ -3504,7 +3499,6 @@ megaraid_cmm_register(adapter_t *adapter)
3504 __LINE__)); 3499 __LINE__));
3505 return -1; 3500 return -1;
3506 } 3501 }
3507 memset(adapter->uscb_list, 0, sizeof(scb_t) * MBOX_MAX_USER_CMDS);
3508 3502
3509 3503
3510 // Initialize the synchronization parameters for resources for 3504 // Initialize the synchronization parameters for resources for
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index 84d9c27133d4..b6587a6d8486 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -890,12 +890,11 @@ mraid_mm_register_adp(mraid_mmadp_t *lld_adp)
890 if (lld_adp->drvr_type != DRVRTYPE_MBOX) 890 if (lld_adp->drvr_type != DRVRTYPE_MBOX)
891 return (-EINVAL); 891 return (-EINVAL);
892 892
893 adapter = kmalloc(sizeof(mraid_mmadp_t), GFP_KERNEL); 893 adapter = kzalloc(sizeof(mraid_mmadp_t), GFP_KERNEL);
894 894
895 if (!adapter) 895 if (!adapter)
896 return -ENOMEM; 896 return -ENOMEM;
897 897
898 memset(adapter, 0, sizeof(mraid_mmadp_t));
899 898
900 adapter->unique_id = lld_adp->unique_id; 899 adapter->unique_id = lld_adp->unique_id;
901 adapter->drvr_type = lld_adp->drvr_type; 900 adapter->drvr_type = lld_adp->drvr_type;
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c
index b7f2e613c903..ebb948c016bb 100644
--- a/drivers/scsi/megaraid/megaraid_sas.c
+++ b/drivers/scsi/megaraid/megaraid_sas.c
@@ -1636,15 +1636,13 @@ static int megasas_alloc_cmds(struct megasas_instance *instance)
1636 * Allocate the dynamic array first and then allocate individual 1636 * Allocate the dynamic array first and then allocate individual
1637 * commands. 1637 * commands.
1638 */ 1638 */
1639 instance->cmd_list = kmalloc(sizeof(struct megasas_cmd *) * max_cmd, 1639 instance->cmd_list = kcalloc(max_cmd, sizeof(struct megasas_cmd*), GFP_KERNEL);
1640 GFP_KERNEL);
1641 1640
1642 if (!instance->cmd_list) { 1641 if (!instance->cmd_list) {
1643 printk(KERN_DEBUG "megasas: out of memory\n"); 1642 printk(KERN_DEBUG "megasas: out of memory\n");
1644 return -ENOMEM; 1643 return -ENOMEM;
1645 } 1644 }
1646 1645
1647 memset(instance->cmd_list, 0, sizeof(struct megasas_cmd *) * max_cmd);
1648 1646
1649 for (i = 0; i < max_cmd; i++) { 1647 for (i = 0; i < max_cmd; i++) {
1650 instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd), 1648 instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd),