diff mbox series

[net-next,v0,12/15] net/mlx5: E-switch, Reuse mlx5_eswitch_set_vport_mac

Message ID 20211117043357.345072-13-saeed@kernel.org (mailing list archive)
State Accepted
Commit b22fd4381d15ae66e42a7fab6eedfbb72d714ebb
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v0,01/15] net/mlx5e: Support ethtool cq mode | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Pull request is its own cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 3 of 3 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 26 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Saeed Mahameed Nov. 17, 2021, 4:33 a.m. UTC
From: Parav Pandit <parav@nvidia.com>

mlx5_eswitch_set_vport_mac() routine already does necessary checks which
are duplicated in implementation of
mlx5_devlink_port_function_hw_addr_set().

Hence, reuse mlx5_eswitch_set_vport_mac() and cut down the code.

Signed-off-by: Parav Pandit <parav@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index b039f8b07d31..c0526fc27ad6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1732,9 +1732,7 @@  int mlx5_devlink_port_function_hw_addr_set(struct devlink_port *port,
 					   struct netlink_ext_ack *extack)
 {
 	struct mlx5_eswitch *esw;
-	struct mlx5_vport *vport;
 	u16 vport_num;
-	int err;
 
 	esw = mlx5_devlink_eswitch_get(port->devlink);
 	if (IS_ERR(esw)) {
@@ -1747,16 +1745,8 @@  int mlx5_devlink_port_function_hw_addr_set(struct devlink_port *port,
 		NL_SET_ERR_MSG_MOD(extack, "Port doesn't support set hw_addr");
 		return -EINVAL;
 	}
-	vport = mlx5_eswitch_get_vport(esw, vport_num);
-	if (IS_ERR(vport)) {
-		NL_SET_ERR_MSG_MOD(extack, "Invalid port");
-		return PTR_ERR(vport);
-	}
 
-	mutex_lock(&esw->state_lock);
-	err = mlx5_esw_set_vport_mac_locked(esw, vport, hw_addr);
-	mutex_unlock(&esw->state_lock);
-	return err;
+	return mlx5_eswitch_set_vport_mac(esw, vport_num, hw_addr);
 }
 
 int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw,