Skip to content

Commit a11e1ec

Browse files
vadimp-nvidiadavem330
authored andcommitted
mlxsw: core_env: Split module power mode setting to a separate function
Move the code that applies the module power mode to the device to a separate function. This function will be invoked by the next patch to set the power mode on transceiver modules found on a line card when the line card becomes active. Signed-off-by: Vadim Pasternak <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7b261af commit a11e1ec

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

drivers/net/ethernet/mellanox/mlxsw/core_env.c

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -648,25 +648,16 @@ static int __mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core,
648648
return err;
649649
}
650650

651-
int
652-
mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
653-
u8 module,
654-
enum ethtool_module_power_mode_policy policy,
655-
struct netlink_ext_ack *extack)
651+
static int
652+
mlxsw_env_set_module_power_mode_apply(struct mlxsw_core *mlxsw_core,
653+
u8 slot_index, u8 module,
654+
enum ethtool_module_power_mode_policy policy,
655+
struct netlink_ext_ack *extack)
656656
{
657-
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
658657
struct mlxsw_env_module_info *module_info;
659658
bool low_power;
660659
int err = 0;
661660

662-
if (policy != ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH &&
663-
policy != ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO) {
664-
NL_SET_ERR_MSG_MOD(extack, "Unsupported power mode policy");
665-
return -EOPNOTSUPP;
666-
}
667-
668-
mutex_lock(&mlxsw_env->line_cards_lock);
669-
670661
err = __mlxsw_env_validate_module_type(mlxsw_core, slot_index, module);
671662
if (err) {
672663
NL_SET_ERR_MSG_MOD(extack,
@@ -691,7 +682,29 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
691682
out_set_policy:
692683
module_info->power_mode_policy = policy;
693684
out:
685+
return err;
686+
}
687+
688+
int
689+
mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
690+
u8 module,
691+
enum ethtool_module_power_mode_policy policy,
692+
struct netlink_ext_ack *extack)
693+
{
694+
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
695+
int err;
696+
697+
if (policy != ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH &&
698+
policy != ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO) {
699+
NL_SET_ERR_MSG_MOD(extack, "Unsupported power mode policy");
700+
return -EOPNOTSUPP;
701+
}
702+
703+
mutex_lock(&mlxsw_env->line_cards_lock);
704+
err = mlxsw_env_set_module_power_mode_apply(mlxsw_core, slot_index,
705+
module, policy, extack);
694706
mutex_unlock(&mlxsw_env->line_cards_lock);
707+
695708
return err;
696709
}
697710
EXPORT_SYMBOL(mlxsw_env_set_module_power_mode);

0 commit comments

Comments
 (0)