Skip to contentSkip to conversation

Unrelated code cleanups

PATCH Applied Leon Romanovsky 2 participants 6 messages Oct 2, 2019 – Oct 4, 2019

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

cover Unrelated code cleanups

From: Leon Romanovsky <[email protected]>

Hi,

Various code cleanups.

Thanks

Erez Alfasi (2):
IB/mlx5: Remove unnecessary return statement
IB/mlx5: Remove unnecessary else statement

Leon Romanovsky (1):
RDMA/mlx5: Group boolean parameters to take less space

Parav Pandit (1):
IB/cm: Use container_of() instead of typecast

 drivers/infiniband/core/cm.c         | 4 ++--
 drivers/infiniband/hw/mlx5/main.c    | 4 ++--
 drivers/infiniband/hw/mlx5/mlx5_ib.h | 8 ++++----
 drivers/infiniband/hw/mlx5/odp.c     | 2 --
 4 files changed, 8 insertions(+), 10 deletions(-)

--
2.20.1

#1 lore raw

PATCH 1/4 RDMA/mlx5: Group boolean parameters to take less space

From: Leon Romanovsky <[email protected]>

Clean the code to store all boolean parameters inside one variable.

---
 drivers/infiniband/hw/mlx5/mlx5_ib.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/mlx5_ib.h +4 -4
index 2ceaef3ea3fb..bf30d53d94dc 100644
@@ -958,7 +958,10 @@ struct mlx5_ib_dev {
 	/* serialize update of capability mask
 	 */
 	struct mutex			cap_mask_mutex;
-	bool				ib_active;
+	u8				ib_active:1;
+	u8				fill_delay:1;
+	u8				is_rep:1;
+	u8				lag_active:1;
 	struct umr_common		umrc;
 	/* sync used page count stats
 	 */
@@ -967,7 +970,6 @@ struct mlx5_ib_dev {
 	struct timer_list		delay_timer;
 	/* Prevents soft lock on massive reg MRs */
 	struct mutex			slow_path_mutex;
-	int				fill_delay;
 	struct ib_odp_caps	odp_caps;
 	u64			odp_max_size;
 	struct mlx5_ib_pf_eq	odp_pf_eq;
@@ -988,8 +990,6 @@ struct mlx5_ib_dev {
 	struct mlx5_sq_bfreg	fp_bfreg;
 	struct mlx5_ib_delay_drop	delay_drop;
 	const struct mlx5_ib_profile	*profile;
-	bool			is_rep;
-	int				lag_active;
 
 	struct mlx5_ib_lb_state		lb;
 	u8			umr_fence;
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/4 IB/mlx5: Remove unnecessary return statement

In reply to Leon Romanovsky

From: Erez Alfasi <[email protected]>

There is no reason to call return at the end of function which returns void. Remove this unnecessary statement.

---
 drivers/infiniband/hw/mlx5/odp.c | 2 --
 1 file changed, 2 deletions(-)
drivers/infiniband/hw/mlx5/odp.c +0 -2
index 2e9b43061797..95cf0249b015 100644
@@ -359,8 +359,6 @@ void mlx5_ib_internal_fill_odp_caps(struct mlx5_ib_dev *dev)
 	    MLX5_CAP_GEN(dev->mdev, umr_extended_translation_offset) &&
 	    !MLX5_CAP_GEN(dev->mdev, umr_indirect_mkey_disabled))
 		caps->general_caps |= IB_ODP_SUPPORT_IMPLICIT;
-
-	return;
 }
 
 static void mlx5_ib_page_fault_resume(struct mlx5_ib_dev *dev,
Signature · 1 line
2.20.1
#3 lore raw

PATCH 3/4 IB/mlx5: Remove unnecessary else statement

In reply to Leon Romanovsky

From: Erez Alfasi <[email protected]>

'else' is not generally useful after a break or
return. Remove this unnecessary statement.

---
 drivers/infiniband/hw/mlx5/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mlx5/main.c +2 -2
index 831539419c30..b95c2b05f682 100644
@@ -844,8 +844,8 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
 	resp_len = sizeof(resp.comp_mask) + sizeof(resp.response_length);
 	if (uhw->outlen && uhw->outlen < resp_len)
 		return -EINVAL;
-	else
-		resp.response_length = resp_len;
+
+	resp.response_length = resp_len;
 
 	if (uhw->inlen && !ib_is_udata_cleared(uhw, 0, uhw->inlen))
 		return -EINVAL;
Signature · 1 line
2.20.1
#4 lore raw

PATCH 4/4 IB/cm: Use container_of() instead of typecast

In reply to Leon Romanovsky

From: Parav Pandit <[email protected]>

Use container_of() macro to get to timewait info structure instead of typecasting.

---
 drivers/infiniband/core/cm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/core/cm.c +2 -2
index da10e6ccb43c..c0aa3a4b4cfd 100644
@@ -246,7 +246,7 @@ struct cm_work {
 };
 
 struct cm_timewait_info {
-	struct cm_work work;			/* Must be first. */
+	struct cm_work work;
 	struct list_head list;
 	struct rb_node remote_qp_node;
 	struct rb_node remote_id_node;
@@ -3434,7 +3434,7 @@ static int cm_timewait_handler(struct cm_work *work)
 	struct cm_id_private *cm_id_priv;
 	int ret;
 
-	timewait_info = (struct cm_timewait_info *)work;
+	timewait_info = container_of(work, struct cm_timewait_info, work);
 	spin_lock_irq(&cm.lock);
 	list_del(&timewait_info->list);
 	spin_unlock_irq(&cm.lock);
Signature · 1 line
2.20.1
#5 lore raw
In reply to Leon Romanovsky
Quoted 12 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

Hi,

Various code cleanups.

Thanks

Erez Alfasi (2):
IB/mlx5: Remove unnecessary return statement
IB/mlx5: Remove unnecessary else statement

Quoted 5 lines

Leon Romanovsky (1):
RDMA/mlx5: Group boolean parameters to take less space

Parav Pandit (1):
IB/cm: Use container_of() instead of typecast

Applied to for-next, thanks

Jason