linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: lpfc: lpfc_init: use kcalloc for allocating memory
@ 2014-04-08 20:42 Matei Oprea
  2014-04-09  0:04 ` Joe Perches
  2014-04-09 10:48 ` Boaz Harrosh
  0 siblings, 2 replies; 12+ messages in thread
From: Matei Oprea @ 2014-04-08 20:42 UTC (permalink / raw)
  To: jbottomley; +Cc: linux-scsi, linux-kernel, Matei Oprea, ROSEdu Kernel Community

It's easier to use kcalloc for allocating arrays. While at it
also remove useless casting value.

Signed-off-by: Matei Oprea <eu@opreamatei.ro>
Cc: ROSEdu Kernel Community <firefly@lists.rosedu.org>
---
 drivers/scsi/lpfc/lpfc_init.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 635eeb3..1528f34 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -4742,12 +4742,14 @@ lpfc_sli_driver_resource_setup(struct lpfc_hba *phba)
 			phba->cfg_sg_seg_cnt = LPFC_DEFAULT_MENLO_SG_SEG_CNT;
 	}
 
-	if (!phba->sli.ring)
-		phba->sli.ring = (struct lpfc_sli_ring *)
-			kzalloc(LPFC_SLI3_MAX_RING *
-			sizeof(struct lpfc_sli_ring), GFP_KERNEL);
-	if (!phba->sli.ring)
-		return -ENOMEM;
+	if (unlikely(!phba->sli.ring)) {
+		phba->sli.ring = kcalloc(LPFC_SLI3_MAX_RING,
+				sizeof(struct lpfc_sli_ring),
+				GFP_KERNEL);
+
+		if (!phba->sli.ring)
+			return -ENOMEM;
+	}
 
 	/*
 	 * Since lpfc_sg_seg_cnt is module parameter, the sg_dma_buf_size
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [PATCH] scsi: lpfc: lpfc_init: use kcalloc for allocating memory
@ 2014-04-11  9:21 Matei Oprea
  0 siblings, 0 replies; 12+ messages in thread
From: Matei Oprea @ 2014-04-11  9:21 UTC (permalink / raw)
  To: jbottomley; +Cc: linux-scsi, linux-kernel, Matei Oprea, ROSEdu Kernel Community

It's easier to use kcalloc for allocating arrays. While at it
also remove useless casting value.

Signed-off-by: Matei Oprea <eu@opreamatei.ro>
Cc: ROSEdu Kernel Community <firefly@lists.rosedu.org>
---
 drivers/scsi/lpfc/lpfc_init.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 635eeb3..7e58c22 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -4742,12 +4742,13 @@ lpfc_sli_driver_resource_setup(struct lpfc_hba *phba)
 			phba->cfg_sg_seg_cnt = LPFC_DEFAULT_MENLO_SG_SEG_CNT;
 	}
 
-	if (!phba->sli.ring)
-		phba->sli.ring = (struct lpfc_sli_ring *)
-			kzalloc(LPFC_SLI3_MAX_RING *
-			sizeof(struct lpfc_sli_ring), GFP_KERNEL);
-	if (!phba->sli.ring)
-		return -ENOMEM;
+	if (!phba->sli.ring) {
+		phba->sli.ring = kcalloc(LPFC_SLI3_MAX_RING,
+					 sizeof(struct lpfc_sli_ring),
+					 GFP_KERNEL);
+		if (!phba->sli.ring)
+			return -ENOMEM;
+	}
 
 	/*
 	 * Since lpfc_sg_seg_cnt is module parameter, the sg_dma_buf_size
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [PATCH] scsi: lpfc: lpfc_init: use kcalloc for allocating memory
@ 2014-04-08 20:18 Matei Oprea
  2014-04-08 20:20 ` Joe Perches
  0 siblings, 1 reply; 12+ messages in thread
From: Matei Oprea @ 2014-04-08 20:18 UTC (permalink / raw)
  To: jbottomley; +Cc: linux-scsi, linux-kernel, Matei Oprea, ROSEdu Kernel Community

It's easier to use kcalloc for allocating arrays. While at it
also remove useless casting value.

Signed-off-by: Matei Oprea <eu@opreamatei.ro>
Cc: ROSEdu Kernel Community <firefly@lists.rosedu.org>
---
 drivers/scsi/lpfc/lpfc_init.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index e286909..2b1a786 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -4742,12 +4742,14 @@ lpfc_sli_driver_resource_setup(struct lpfc_hba *phba)
 			phba->cfg_sg_seg_cnt = LPFC_DEFAULT_MENLO_SG_SEG_CNT;
 	}
 
-	if (!phba->sli.ring) {
+	if (unlikely(!phba->sli.ring)) {
 		phba->sli.ring = kcalloc(LPFC_SLI3_MAX_RING,
 				sizeof(struct lpfc_sli_ring),
 				GFP_KERNEL);
-		return -ENOMEM;
 	}
+
+	if (!phba->sli.ring)
+		return -ENOMEM;
 
 	/*
 	 * Since lpfc_sg_seg_cnt is module parameter, the sg_dma_buf_size
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [PATCH] scsi: lpfc: lpfc_init: use kcalloc for allocating memory
@ 2014-04-08 19:44 Matei Oprea
  2014-04-08 19:48 ` Joe Perches
  0 siblings, 1 reply; 12+ messages in thread
From: Matei Oprea @ 2014-04-08 19:44 UTC (permalink / raw)
  To: jbottomley; +Cc: linux-scsi, linux-kernel, Matei Oprea, ROSEdu Kernel Community

It's easier to use kcalloc for allocating arrays. While at it
also remove useless casting value.

Signed-off-by: Matei Oprea <eu@opreamatei.ro>
Cc: ROSEdu Kernel Community <firefly@lists.rosedu.org>
---
 drivers/scsi/lpfc/lpfc_init.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 635eeb3..e286909 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -4742,12 +4742,12 @@ lpfc_sli_driver_resource_setup(struct lpfc_hba *phba)
 			phba->cfg_sg_seg_cnt = LPFC_DEFAULT_MENLO_SG_SEG_CNT;
 	}
 
-	if (!phba->sli.ring)
-		phba->sli.ring = (struct lpfc_sli_ring *)
-			kzalloc(LPFC_SLI3_MAX_RING *
-			sizeof(struct lpfc_sli_ring), GFP_KERNEL);
-	if (!phba->sli.ring)
+	if (!phba->sli.ring) {
+		phba->sli.ring = kcalloc(LPFC_SLI3_MAX_RING,
+				sizeof(struct lpfc_sli_ring),
+				GFP_KERNEL);
 		return -ENOMEM;
+	}
 
 	/*
 	 * Since lpfc_sg_seg_cnt is module parameter, the sg_dma_buf_size
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [PATCH] scsi: lpfc: lpfc_init: use kcalloc for allocating memory
@ 2014-03-18 20:51 Matei Oprea
  2014-04-07 12:37 ` Matei Oprea
  2014-04-08  6:36 ` Boaz Harrosh
  0 siblings, 2 replies; 12+ messages in thread
From: Matei Oprea @ 2014-03-18 20:51 UTC (permalink / raw)
  To: jbottomley
  Cc: james.smart, linux-scsi, linux-kernel, Matei Oprea,
	ROSEdu Kernel Community

It's easier to use kcalloc for allocating arrays. While at it
also remove useless casting value.

Signed-off-by: Matei Oprea <eu@opreamatei.ro>
Cc: ROSEdu Kernel Community <firefly@lists.rosedu.org>
---
 drivers/scsi/lpfc/lpfc_init.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 68c94cc..0a51ca5 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -4731,9 +4731,9 @@ lpfc_sli_driver_resource_setup(struct lpfc_hba *phba)
 	}
 
 	if (!phba->sli.ring)
-		phba->sli.ring = (struct lpfc_sli_ring *)
-			kzalloc(LPFC_SLI3_MAX_RING *
+		phba->sli.ring = kcalloc(LPFC_SLI3_MAX_RING,
 			sizeof(struct lpfc_sli_ring), GFP_KERNEL);
+
 	if (!phba->sli.ring)
 		return -ENOMEM;
 
-- 
1.7.9.5

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

end of thread, other threads:[~2014-04-11  9:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-08 20:42 [PATCH] scsi: lpfc: lpfc_init: use kcalloc for allocating memory Matei Oprea
2014-04-09  0:04 ` Joe Perches
2014-04-09 10:48 ` Boaz Harrosh
  -- strict thread matches above, loose matches on Subject: below --
2014-04-11  9:21 Matei Oprea
2014-04-08 20:18 Matei Oprea
2014-04-08 20:20 ` Joe Perches
2014-04-08 20:21   ` Matei Oprea
2014-04-08 19:44 Matei Oprea
2014-04-08 19:48 ` Joe Perches
2014-03-18 20:51 Matei Oprea
2014-04-07 12:37 ` Matei Oprea
2014-04-08  6:36 ` Boaz Harrosh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).