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 <vadimp@nvidia.com> Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
7b261af9f6
commit
a11e1ec141
@ -648,25 +648,16 @@ err_module_low_power_set:
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
u8 module,
|
||||
enum ethtool_module_power_mode_policy policy,
|
||||
struct netlink_ext_ack *extack)
|
||||
static int
|
||||
mlxsw_env_set_module_power_mode_apply(struct mlxsw_core *mlxsw_core,
|
||||
u8 slot_index, u8 module,
|
||||
enum ethtool_module_power_mode_policy policy,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
struct mlxsw_env_module_info *module_info;
|
||||
bool low_power;
|
||||
int err = 0;
|
||||
|
||||
if (policy != ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH &&
|
||||
policy != ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Unsupported power mode policy");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
mutex_lock(&mlxsw_env->line_cards_lock);
|
||||
|
||||
err = __mlxsw_env_validate_module_type(mlxsw_core, slot_index, module);
|
||||
if (err) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
@ -691,7 +682,29 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
out_set_policy:
|
||||
module_info->power_mode_policy = policy;
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 slot_index,
|
||||
u8 module,
|
||||
enum ethtool_module_power_mode_policy policy,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);
|
||||
int err;
|
||||
|
||||
if (policy != ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH &&
|
||||
policy != ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Unsupported power mode policy");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
mutex_lock(&mlxsw_env->line_cards_lock);
|
||||
err = mlxsw_env_set_module_power_mode_apply(mlxsw_core, slot_index,
|
||||
module, policy, extack);
|
||||
mutex_unlock(&mlxsw_env->line_cards_lock);
|
||||
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(mlxsw_env_set_module_power_mode);
|
||||
|
Loading…
Reference in New Issue
Block a user