[PATCH 3/6] scsi: lpfc: use min() to improve code

Qianfeng Rong posted 6 patches 1 month, 2 weeks ago
[PATCH 3/6] scsi: lpfc: use min() to improve code
Posted by Qianfeng Rong 1 month, 2 weeks ago
Use min_t() to reduce the code in lpfc_sli4_driver_resource_setup() and
lpfc_nvme_prep_io_cmd(), and improve readability.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
 drivers/scsi/lpfc/lpfc_init.c | 5 +----
 drivers/scsi/lpfc/lpfc_nvme.c | 8 ++------
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 4081d2a358ee..ad8a85c65bfd 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -8300,10 +8300,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",
diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index a6647dd360d1..e6f632521cff 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -1234,12 +1234,8 @@ lpfc_nvme_prep_io_cmd(struct lpfc_vport *vport,
 			if ((phba->cfg_nvme_enable_fb) &&
 			    test_bit(NLP_FIRSTBURST, &pnode->nlp_flag)) {
 				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;
 			}
-- 
2.34.1
Re: [PATCH 3/6] scsi: lpfc: use min() to improve code
Posted by Martin K. Petersen 1 month, 2 weeks ago
Qianfeng,

> Use min_t() to reduce the code in lpfc_sli4_driver_resource_setup()
> and lpfc_nvme_prep_io_cmd(), and improve readability.

Applied to 6.18/scsi-staging, thanks!

-- 
Martin K. Petersen
Re: [PATCH 3/6] scsi: lpfc: use min() to improve code
Posted by Justin Tee 1 month, 2 weeks ago
Reviewed-by: Justin Tee <justin.tee@broadcom.com>

Regards,
Justin