diff mbox series

[net-next] net/mlx5: Use PTR_ERR_OR_ZERO() to simplify code

Message ID 20230822062312.3982963-1-ruanjinjie@huawei.com (mailing list archive)
State Not Applicable
Headers show
Series [net-next] net/mlx5: Use PTR_ERR_OR_ZERO() to simplify code | expand

Commit Message

Jinjie Ruan Aug. 22, 2023, 6:23 a.m. UTC
Return PTR_ERR_OR_ZERO() instead of return 0 or PTR_ERR() to
simplify code.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_fs.c        |  8 ++------
 drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c | 10 ++--------
 2 files changed, 4 insertions(+), 14 deletions(-)

Comments

Jacob Keller Aug. 23, 2023, 7:45 p.m. UTC | #1
On 8/21/2023 11:23 PM, Jinjie Ruan wrote:
> Return PTR_ERR_OR_ZERO() instead of return 0 or PTR_ERR() to
> simplify code.
> 
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>

> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_fs.c        |  8 ++------
>  drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c | 10 ++--------
>  2 files changed, 4 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
> index 934b0d5ce1b3..777d311d44ef 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
> @@ -1283,9 +1283,7 @@ static int mlx5e_create_inner_ttc_table(struct mlx5e_flow_steering *fs,
>  	mlx5e_set_inner_ttc_params(fs, rx_res, &ttc_params);
>  	fs->inner_ttc = mlx5_create_inner_ttc_table(fs->mdev,
>  						    &ttc_params);
> -	if (IS_ERR(fs->inner_ttc))
> -		return PTR_ERR(fs->inner_ttc);
> -	return 0;
> +	return PTR_ERR_OR_ZERO(fs->inner_ttc);
>  }
>  
>  int mlx5e_create_ttc_table(struct mlx5e_flow_steering *fs,
> @@ -1295,9 +1293,7 @@ int mlx5e_create_ttc_table(struct mlx5e_flow_steering *fs,
>  
>  	mlx5e_set_ttc_params(fs, rx_res, &ttc_params, true);
>  	fs->ttc = mlx5_create_ttc_table(fs->mdev, &ttc_params);
> -	if (IS_ERR(fs->ttc))
> -		return PTR_ERR(fs->ttc);
> -	return 0;
> +	return PTR_ERR_OR_ZERO(fs->ttc);
>  }
>  
>  int mlx5e_create_flow_steering(struct mlx5e_flow_steering *fs,
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c
> index 7d9bbb494d95..101b3bb90863 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c
> @@ -507,10 +507,7 @@ static int mlx5_lag_create_ttc_table(struct mlx5_lag *ldev)
>  
>  	mlx5_lag_set_outer_ttc_params(ldev, &ttc_params);
>  	port_sel->outer.ttc = mlx5_create_ttc_table(dev, &ttc_params);
> -	if (IS_ERR(port_sel->outer.ttc))
> -		return PTR_ERR(port_sel->outer.ttc);
> -
> -	return 0;
> +	return PTR_ERR_OR_ZERO(port_sel->outer.ttc);
>  }
>  
>  static int mlx5_lag_create_inner_ttc_table(struct mlx5_lag *ldev)
> @@ -521,10 +518,7 @@ static int mlx5_lag_create_inner_ttc_table(struct mlx5_lag *ldev)
>  
>  	mlx5_lag_set_inner_ttc_params(ldev, &ttc_params);
>  	port_sel->inner.ttc = mlx5_create_inner_ttc_table(dev, &ttc_params);
> -	if (IS_ERR(port_sel->inner.ttc))
> -		return PTR_ERR(port_sel->inner.ttc);
> -
> -	return 0;
> +	return PTR_ERR_OR_ZERO(port_sel->inner.ttc);
>  }
>  
>  int mlx5_lag_port_sel_create(struct mlx5_lag *ldev,
Saeed Mahameed Aug. 25, 2023, 6:02 p.m. UTC | #2
On 22 Aug 14:23, Jinjie Ruan wrote:
>Return PTR_ERR_OR_ZERO() instead of return 0 or PTR_ERR() to
>simplify code.
>
>Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>

Applied to net-next-mlx5
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
index 934b0d5ce1b3..777d311d44ef 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
@@ -1283,9 +1283,7 @@  static int mlx5e_create_inner_ttc_table(struct mlx5e_flow_steering *fs,
 	mlx5e_set_inner_ttc_params(fs, rx_res, &ttc_params);
 	fs->inner_ttc = mlx5_create_inner_ttc_table(fs->mdev,
 						    &ttc_params);
-	if (IS_ERR(fs->inner_ttc))
-		return PTR_ERR(fs->inner_ttc);
-	return 0;
+	return PTR_ERR_OR_ZERO(fs->inner_ttc);
 }
 
 int mlx5e_create_ttc_table(struct mlx5e_flow_steering *fs,
@@ -1295,9 +1293,7 @@  int mlx5e_create_ttc_table(struct mlx5e_flow_steering *fs,
 
 	mlx5e_set_ttc_params(fs, rx_res, &ttc_params, true);
 	fs->ttc = mlx5_create_ttc_table(fs->mdev, &ttc_params);
-	if (IS_ERR(fs->ttc))
-		return PTR_ERR(fs->ttc);
-	return 0;
+	return PTR_ERR_OR_ZERO(fs->ttc);
 }
 
 int mlx5e_create_flow_steering(struct mlx5e_flow_steering *fs,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c
index 7d9bbb494d95..101b3bb90863 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c
@@ -507,10 +507,7 @@  static int mlx5_lag_create_ttc_table(struct mlx5_lag *ldev)
 
 	mlx5_lag_set_outer_ttc_params(ldev, &ttc_params);
 	port_sel->outer.ttc = mlx5_create_ttc_table(dev, &ttc_params);
-	if (IS_ERR(port_sel->outer.ttc))
-		return PTR_ERR(port_sel->outer.ttc);
-
-	return 0;
+	return PTR_ERR_OR_ZERO(port_sel->outer.ttc);
 }
 
 static int mlx5_lag_create_inner_ttc_table(struct mlx5_lag *ldev)
@@ -521,10 +518,7 @@  static int mlx5_lag_create_inner_ttc_table(struct mlx5_lag *ldev)
 
 	mlx5_lag_set_inner_ttc_params(ldev, &ttc_params);
 	port_sel->inner.ttc = mlx5_create_inner_ttc_table(dev, &ttc_params);
-	if (IS_ERR(port_sel->inner.ttc))
-		return PTR_ERR(port_sel->inner.ttc);
-
-	return 0;
+	return PTR_ERR_OR_ZERO(port_sel->inner.ttc);
 }
 
 int mlx5_lag_port_sel_create(struct mlx5_lag *ldev,