Skip to contentSkip to conversation

scsi: lpfc: Simplify minimum value calculations in lpfc_init and lpfc_nvme

PATCH In review Prabhakar Pujeri 3 participants 4 messages Jun 25, 2024 – Jun 26, 2024 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: lpfc: Simplify minimum value calculations in lpfc_init and lpfc_nvme

This patch simplifies the calculation of minimum values in the lpfc_sli4_driver_resource_setup and lpfc_nvme_prep_io_cmd functions by using the min macro. This change improves code readability and maintainability.

---
 drivers/scsi/lpfc/lpfc_init.c | 5 +----
 drivers/scsi/lpfc/lpfc_nvme.c | 8 ++------
 2 files changed, 3 insertions(+), 10 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +1 -4
index e1dfa96c2a55..663ce30621aa 100644
@@ -8301,10 +8301,7 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
 			phba->cfg_total_seg_cnt,  phba->cfg_scsi_seg_cnt,
 			phba->cfg_nvme_seg_cnt);
 
-	if (phba->cfg_sg_dma_buf_size < SLI4_PAGE_SIZE)
-		i = phba->cfg_sg_dma_buf_size;
-	else
-		i = SLI4_PAGE_SIZE;
+	i = min(phba->cfg_sg_dma_buf_size, SLI4_PAGE_SIZE);
 
 	phba->lpfc_sg_dma_buf_pool =
 			dma_pool_create("lpfc_sg_dma_buf_pool",
drivers/scsi/lpfc/lpfc_nvme.c +2 -6
index d70da2736c94..d22347318b4d 100644
@@ -1234,12 +1234,8 @@ lpfc_nvme_prep_io_cmd(struct lpfc_vport *vport,
 			if ((phba->cfg_nvme_enable_fb) &&
 			    (pnode->nlp_flag & NLP_FIRSTBURST)) {
 				req_len = lpfc_ncmd->nvmeCmd->payload_length;
-				if (req_len < pnode->nvme_fb_size)
-					wqe->fcp_iwrite.initial_xfer_len =
-						req_len;
-				else
-					wqe->fcp_iwrite.initial_xfer_len =
-						pnode->nvme_fb_size;
+				wqe->fcp_iwrite.initial_xfer_len = min(req_len,
+						pnode->nvme_fb_size);
 			} else {
 				wqe->fcp_iwrite.initial_xfer_len = 0;
 			}
Signature · 1 line
2.45.2
#1 lore raw

Hi Prabhakar,

I’m afraid I’m going to have to echo similar comments made in the initio email thread here as well.

How is this a critical fix in code paths that have been in place for years with no complaints from users of Emulex HBAs?

I am reluctant to stamp a Reviewed-by on this patch, which alters code that has already withstood the test of time.

Regards,
Justin Tee

#2 lore raw
In reply to Prabhakar Pujeri
Quoted 4 lines · Prabhakar Pujeri

This patch simplifies the calculation of minimum values in the lpfc_sli4_driver_resource_setup and lpfc_nvme_prep_io_cmd functions by using the min macro. This change improves code readability and maintainability.

How has this patch been generated? If it has been generated with a Coccinelle script, please include that script in the patch description.

Bart.

A message that is not in the archive (sent off-list or not yet received): CAB=RiWAJyrywUhYo9yQ_qbaiokf_HnJkRmLHCQw5f61Fn4m5Bg@mail.gmail.com

#4 lore raw
Quoted 8 lines · Bart Van Assche
Quoted 4 lines · Prabhakar Pujeri

This patch simplifies the calculation of minimum values in the lpfc_sli4_driver_resource_setup and lpfc_nvme_prep_io_cmd functions by using the min macro. This change improves code readability and maintainability.

Quoted 4 lines

How has this patch been generated? If it has been generated with a Coccinelle script, please include that script in the patch description.

Bart.

Yes, I am using Coccinelle for these patches. I will include the
Coccinelle scripts in my upcoming patches.