[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20251209094043.109194-1-buaajxlj@163.com>
Date: Tue, 9 Dec 2025 17:40:43 +0800
From: Liang Jie <buaajxlj@....com>
To: Nilesh Javali <njavali@...vell.com>,
GR-QLogic-Storage-Upstream@...vell.com (maintainer:QLOGIC QLA2XXX FC-SCSI DRIVER),
"James E.J. Bottomley" <James.Bottomley@...senPartnership.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
linux-scsi@...r.kernel.org (open list:QLOGIC QLA2XXX FC-SCSI DRIVER),
linux-kernel@...r.kernel.org (open list)
Cc: liangjie@...iang.com
Subject: [PATCH] scsi: qla2xxx: refactor qla2x00_free_queues()
From: Liang Jie <liangjie@...iang.com>
qla2x00_free_queues() contains two nearly identical loops for
freeing request and response queues while temporarily dropping
ha->hardware_lock. Factor these loops into helpers to reduce
code duplication and improve readability.
While touching the function, rely on kfree(NULL) being a no-op
and drop redundant NULL checks before kfree().
No functional change intended.
Signed-off-by: Liang Jie <liangjie@...iang.com>
---
drivers/scsi/qla2xxx/qla_os.c | 43 +++++++++++++++++++++++------------
1 file changed, 28 insertions(+), 15 deletions(-)
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 5ffd94586652..71140835511a 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -532,25 +532,15 @@ static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp)
kfree(rsp);
}
-static void qla2x00_free_queues(struct qla_hw_data *ha)
+static void qla2x00_free_req_queues(struct qla_hw_data *ha)
{
- struct req_que *req;
- struct rsp_que *rsp;
- int cnt;
unsigned long flags;
+ int cnt;
- if (ha->queue_pair_map) {
- kfree(ha->queue_pair_map);
- ha->queue_pair_map = NULL;
- }
- if (ha->base_qpair) {
- kfree(ha->base_qpair);
- ha->base_qpair = NULL;
- }
-
- qla_mapq_free_qp_cpu_map(ha);
spin_lock_irqsave(&ha->hardware_lock, flags);
for (cnt = 0; cnt < ha->max_req_queues; cnt++) {
+ struct req_que *req;
+
if (!test_bit(cnt, ha->req_qid_map))
continue;
@@ -566,16 +556,24 @@ static void qla2x00_free_queues(struct qla_hw_data *ha)
kfree(ha->req_q_map);
ha->req_q_map = NULL;
+}
+static void qla2x00_free_rsp_queues(struct qla_hw_data *ha)
+{
+ unsigned long flags;
+ int cnt;
spin_lock_irqsave(&ha->hardware_lock, flags);
for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) {
+ struct rsp_que *rsp;
+
if (!test_bit(cnt, ha->rsp_qid_map))
continue;
rsp = ha->rsp_q_map[cnt];
clear_bit(cnt, ha->rsp_qid_map);
- ha->rsp_q_map[cnt] = NULL;
+ ha->rsp_q_map[cnt] = NULL;
+
spin_unlock_irqrestore(&ha->hardware_lock, flags);
qla2x00_free_rsp_que(ha, rsp);
spin_lock_irqsave(&ha->hardware_lock, flags);
@@ -586,6 +584,21 @@ static void qla2x00_free_queues(struct qla_hw_data *ha)
ha->rsp_q_map = NULL;
}
+static void qla2x00_free_queues(struct qla_hw_data *ha)
+{
+
+ kfree(ha->queue_pair_map);
+ ha->queue_pair_map = NULL;
+
+ kfree(ha->base_qpair);
+ ha->base_qpair = NULL;
+
+ qla_mapq_free_qp_cpu_map(ha);
+
+ qla2x00_free_req_queues(ha);
+ qla2x00_free_rsp_queues(ha);
+}
+
static char *
qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str, size_t str_len)
{
--
2.25.1
Powered by blists - more mailing lists