From: wanglin wanglin137@huawei.com
driver inclusion category: cleanup bugzilla: NA CVE: NA
----------------------------------
This patch cleans up code by review advice
Reviewed-by: taojihua taojihua4@huawei.com Reviewed-by: huchunzhi huchunzhi@huawei.com Signed-off-by: wanglin wanglin137@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../infiniband/hw/hns/hns_roce_hw_sysfs_v2.c | 6 ++--- .../hw/hns/roce-customer/rdfx_entry.c | 24 +++++++++---------- .../hw/hns/roce-customer/rdfx_hw_v2.c | 9 +++---- 3 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_sysfs_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_sysfs_v2.c index 3779be213c22..dfbdfb2192f1 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_sysfs_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_sysfs_v2.c @@ -83,7 +83,7 @@ int hns_roce_v2_query_mpt_stat(struct hns_roce_dev *hr_dev, goto err_cmd;
mpt_ctx = kzalloc(sizeof(*mpt_ctx), GFP_KERNEL); - if (!mpt_ctx) { + if (ZERO_OR_NULL_PTR(mpt_ctx)) { ret = -ENOMEM; goto err_cmd; } @@ -268,7 +268,7 @@ int hns_roce_v2_query_aeqc_stat(struct hns_roce_dev *hr_dev, return PTR_ERR(mailbox);
eq_context = kzalloc(sizeof(*eq_context), GFP_KERNEL); - if (!eq_context) { + if (ZERO_OR_NULL_PTR(eq_context)) { ret = -ENOMEM; goto err_context; } @@ -436,7 +436,7 @@ int hns_roce_v2_query_ceqc_stat(struct hns_roce_dev *hr_dev, return PTR_ERR(mailbox);
eq_context = kzalloc(sizeof(*eq_context), GFP_KERNEL); - if (!eq_context) { + if (ZERO_OR_NULL_PTR(eq_context)) { ret = -ENOMEM; goto err_context; } diff --git a/drivers/infiniband/hw/hns/roce-customer/rdfx_entry.c b/drivers/infiniband/hw/hns/roce-customer/rdfx_entry.c index e717fb1019e8..a2453b31ac91 100644 --- a/drivers/infiniband/hw/hns/roce-customer/rdfx_entry.c +++ b/drivers/infiniband/hw/hns/roce-customer/rdfx_entry.c @@ -17,14 +17,14 @@ void rdfx_cp_rq_wqe_buf(struct hns_roce_dev *hr_dev, #endif { struct rdfx_info *rdfx = (struct rdfx_info *)hr_dev->dfx_priv; - struct rdfx_qp_info *rdfx_qp; - struct rdfx_rq_info *rq; - void *dfx_qp_buf; + struct rdfx_qp_info *rdfx_qp = NULL; + struct rdfx_rq_info *rq = NULL; + void *dfx_qp_buf = NULL;
spin_lock(&(rdfx->qp.qp_lock));
rdfx_qp = rdfx_find_rdfx_qp(rdfx, hr_qp->qpn); - if (!rdfx_qp) { + if (ZERO_OR_NULL_PTR(rdfx_qp)) { dev_err(hr_dev->dev, "find qp 0x%lx failed while cp sq wqe buf\n", hr_qp->qpn); spin_unlock(&(rdfx->qp.qp_lock)); @@ -109,16 +109,16 @@ void rdfx_cp_sq_wqe_buf(struct hns_roce_dev *hr_dev, struct hns_roce_qp *qp, #endif { struct rdfx_info *rdfx = (struct rdfx_info *)hr_dev->dfx_priv; - struct rdfx_qp_info *rdfx_qp; - struct rdfx_sq_info *sq; - void *dfx_qp_buf; - void *dfx_hns_wqe_sge; + struct rdfx_qp_info *rdfx_qp = NULL; + struct rdfx_sq_info *sq = NULL; + void *dfx_hns_wqe_sge = NULL; + void *dfx_qp_buf = NULL; int atomic_en = 0;
spin_lock(&(rdfx->qp.qp_lock));
rdfx_qp = rdfx_find_rdfx_qp(rdfx, qp->qpn); - if (!rdfx_qp) { + if (ZERO_OR_NULL_PTR(rdfx_qp)) { dev_err(hr_dev->dev, "find qp 0x%lx failed while cp sq wqe buf\n", qp->qpn); spin_unlock(&(rdfx->qp.qp_lock)); @@ -153,14 +153,14 @@ void rdfx_cp_cqe_buf(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq, void *cqe) { struct rdfx_info *rdfx = (struct rdfx_info *)hr_dev->dfx_priv; - struct rdfx_cq_info *rdfx_cq; - void *dfx_cq_buf; + struct rdfx_cq_info *rdfx_cq = NULL; + void *dfx_cq_buf = NULL; u32 ci;
spin_lock(&rdfx->cq.cq_lock);
rdfx_cq = rdfx_find_rdfx_cq(rdfx, hr_cq->cqn); - if (!rdfx_cq) { + if (ZERO_OR_NULL_PTR(rdfx_cq)) { dev_err(hr_dev->dev, "find cq 0x%lx failed while cp cqe buf\n", hr_cq->cqn); spin_unlock(&rdfx->cq.cq_lock); diff --git a/drivers/infiniband/hw/hns/roce-customer/rdfx_hw_v2.c b/drivers/infiniband/hw/hns/roce-customer/rdfx_hw_v2.c index 32994b0d78aa..c0ab3d2ba636 100644 --- a/drivers/infiniband/hw/hns/roce-customer/rdfx_hw_v2.c +++ b/drivers/infiniband/hw/hns/roce-customer/rdfx_hw_v2.c @@ -504,9 +504,8 @@ void rdfx_v2_qpc_store_print(u32 qpn, u64 bt0_ba, u64 bt1_ba, struct hns_roce_v2_qp_context *qp_context) { int i; - int *qpc; + int *qpc = (int *)qp_context;
- qpc = (int *)qp_context; pr_info("************** QPC INFO ***************\n"); pr_info("QPC(0x%x) BT0: 0x%llx\n", qpn, bt0_ba); pr_info("QPC(0x%x) BT1: 0x%llx\n", qpn, bt1_ba); @@ -711,9 +710,8 @@ void rdfx_v2_srqc_store_print(u32 srqn, u64 bt0_ba, u64 bt1_ba, struct hns_roce_srq_context *srq_context) { int i; - int *srqc; + int *srqc = (int *)srq_context;
- srqc = (int *)srq_context; pr_info("************** SRQC INFO ***************\n"); pr_info("SRQC(0x%x) BT0: 0x%llx\n", srqn, bt0_ba); pr_info("SRQC(0x%x) BT1: 0x%llx\n", srqn, bt1_ba); @@ -815,9 +813,8 @@ void rdfx_v2_mpt_store_print(int key, u64 bt0_ba, u64 bt1_ba, struct hns_roce_v2_mpt_entry *mpt_ctx) { int i; - int *mpt; + int *mpt = (int *)mpt_ctx;
- mpt = (int *)mpt_ctx; pr_info("************** MPT INFO ***************\n"); pr_info("MPT(0x%x) BT0: 0x%llx\n", key, bt0_ba); pr_info("MPT(0x%x) BT1: 0x%llx\n", key, bt1_ba);