linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guo Zhengkui <guozhengkui@vivo.com>
To: Mustafa Ismail <mustafa.ismail@intel.com>,
	Shiraz Saleem <shiraz.saleem@intel.com>,
	Jason Gunthorpe <jgg@ziepe.ca>, Yishai Hadas <yishaih@nvidia.com>,
	linux-rdma@vger.kernel.org (open list:INTEL ETHERNET PROTOCOL
	DRIVER FOR RDMA), linux-kernel@vger.kernel.org (open list)
Cc: zhengkui_guo@outlook.com, Guo Zhengkui <guozhengkui@vivo.com>
Subject: [PATCH linux-next v2] RDMA: simplify if-if to if-else
Date: Thu, 31 Mar 2022 21:05:25 +0800	[thread overview]
Message-ID: <20220331130525.14750-1-guozhengkui@vivo.com> (raw)
In-Reply-To: <YkVu3vqjIPFRSGtM@unreal>

Replace `if (!ret)` with `else` for simplification and
fix the unbalanced curly brackets.

Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
---
 drivers/infiniband/hw/irdma/puda.c |  8 ++++----
 drivers/infiniband/hw/mlx4/mcg.c   | 29 +++++++++++++++++------------
 2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/infiniband/hw/irdma/puda.c b/drivers/infiniband/hw/irdma/puda.c
index 397f3d070f90..8dd38e1f6cf0 100644
--- a/drivers/infiniband/hw/irdma/puda.c
+++ b/drivers/infiniband/hw/irdma/puda.c
@@ -838,11 +838,11 @@ static void irdma_puda_free_qp(struct irdma_puda_rsrc *rsrc)
 	}
 
 	ret = irdma_sc_qp_destroy(&rsrc->qp, 0, false, true, true);
-	if (ret)
+	if (ret) {
 		ibdev_dbg(to_ibdev(dev),
 			  "PUDA: error puda qp destroy wqe, status = %d\n",
 			  ret);
-	if (!ret) {
+	} else {
 		ret = irdma_sc_poll_for_cqp_op_done(dev->cqp, IRDMA_CQP_OP_DESTROY_QP,
 						    &compl_info);
 		if (ret)
@@ -869,9 +869,9 @@ static void irdma_puda_free_cq(struct irdma_puda_rsrc *rsrc)
 	}
 
 	ret = irdma_sc_cq_destroy(&rsrc->cq, 0, true);
-	if (ret)
+	if (ret) {
 		ibdev_dbg(to_ibdev(dev), "PUDA: error ieq cq destroy\n");
-	if (!ret) {
+	} else {
 		ret = irdma_sc_poll_for_cqp_op_done(dev->cqp, IRDMA_CQP_OP_DESTROY_CQ,
 						    &compl_info);
 		if (ret)
diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
index 33f525b744f2..c0beb9f4030a 100644
--- a/drivers/infiniband/hw/mlx4/mcg.c
+++ b/drivers/infiniband/hw/mlx4/mcg.c
@@ -304,13 +304,11 @@ static int send_leave_to_wire(struct mcast_group *group, u8 join_state)
 	ret = send_mad_to_wire(group->demux, (struct ib_mad *)&mad);
 	if (ret)
 		group->state = MCAST_IDLE;
-
 	/* set timeout handler */
-	if (!ret) {
+	else
 		/* calls mlx4_ib_mcg_timeout_handler */
 		queue_delayed_work(group->demux->mcg_wq, &group->timeout_work,
 				msecs_to_jiffies(MAD_TIMEOUT_MS));
-	}
 
 	return ret;
 }
@@ -561,8 +559,9 @@ static void mlx4_ib_mcg_timeout_handler(struct work_struct *work)
 				return;
 			}
 			mutex_lock(&group->lock);
-		} else
+		} else {
 			mcg_warn_group(group, "DRIVER BUG\n");
+		}
 	} else if (group->state == MCAST_LEAVE_SENT) {
 		if (group->rec.scope_join_state & 0xf)
 			group->rec.scope_join_state &= 0xf0;
@@ -571,8 +570,9 @@ static void mlx4_ib_mcg_timeout_handler(struct work_struct *work)
 		if (release_group(group, 1))
 			return;
 		mutex_lock(&group->lock);
-	} else
+	} else {
 		mcg_warn_group(group, "invalid state %s\n", get_state_string(group->state));
+	}
 	group->state = MCAST_IDLE;
 	atomic_inc(&group->refcount);
 	if (!queue_work(group->demux->mcg_wq, &group->work))
@@ -632,7 +632,7 @@ static int handle_join_req(struct mcast_group *group, u8 join_mask,
 			kfree(req);
 			ref = 1;
 			group->state = group->prev_state;
-		} else
+		} else {
 			group->state = MCAST_JOIN_SENT;
 	}
 
@@ -681,10 +681,12 @@ static void mlx4_ib_mcg_work_handler(struct work_struct *work)
 						list_del(&req->func_list);
 						kfree(req);
 						++rc;
-					} else
+					} else {
 						mcg_warn_group(group, "no request for failed join\n");
-			} else if (method == IB_SA_METHOD_DELETE_RESP && group->demux->flushing)
+					}
+			} else if (method == IB_SA_METHOD_DELETE_RESP && group->demux->flushing) {
 				++rc;
+			}
 		} else {
 			u8 resp_join_state;
 			u8 cur_join_state;
@@ -697,8 +699,9 @@ static void mlx4_ib_mcg_work_handler(struct work_struct *work)
 				/* successfull join */
 				if (!cur_join_state && resp_join_state)
 					--rc;
-			} else if (!resp_join_state)
-					++rc;
+			} else if (!resp_join_state) {
+				++rc;
+			}
 			memcpy(&group->rec, group->response_sa_mad.data, sizeof group->rec);
 		}
 		group->state = MCAST_IDLE;
@@ -730,8 +733,9 @@ static void mlx4_ib_mcg_work_handler(struct work_struct *work)
 			if (send_leave_to_wire(group, req_join_state)) {
 				group->state = group->prev_state;
 				++rc;
-			} else
+			} else {
 				group->state = MCAST_LEAVE_SENT;
+			}
 		}
 	}
 
@@ -898,8 +902,9 @@ int mlx4_ib_mcg_demux_handler(struct ib_device *ibdev, int port, int slave,
 				__be64 tid = mad->mad_hdr.tid;
 				*(u8 *)(&tid) = (u8)slave; /* in group we kept the modified TID */
 				group = search_relocate_mgid0_group(ctx, tid, &rec->mgid);
-			} else
+			} else {
 				group = NULL;
+			}
 		}
 
 		if (!group)
-- 
2.20.1


  reply	other threads:[~2022-03-31 13:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-28 13:08 [PATCH linux-next] RDMA: simplify if-if to if-else Guo Zhengkui
2022-03-30 11:02 ` Leon Romanovsky
2022-03-30 11:06   ` Haakon Bugge
2022-03-30 11:32     ` Leon Romanovsky
2022-03-30 12:26       ` Haakon Bugge
2022-03-30 12:56         ` Leon Romanovsky
2022-03-31  3:03           ` Guo Zhengkui
2022-03-31  9:05             ` Leon Romanovsky
2022-03-31 13:05               ` Guo Zhengkui [this message]
2022-03-31 13:58                 ` [PATCH linux-next v2] " Saleem, Shiraz
2022-04-04 13:56                 ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220331130525.14750-1-guozhengkui@vivo.com \
    --to=guozhengkui@vivo.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mustafa.ismail@intel.com \
    --cc=shiraz.saleem@intel.com \
    --cc=yishaih@nvidia.com \
    --cc=zhengkui_guo@outlook.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).