Commit c8712580 authored by Sergio Paracuellos's avatar Sergio Paracuellos Committed by Greg Kroah-Hartman

staging: ks7010: refactor ks_wlan_set_power_mgmt function

This commit change logic to simplify conditional paths in
ks_wlan_set_power_mgmt function. It handles invalid's first
and just finally assign a valid value.
Signed-off-by: default avatarSergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7a2cc8db
......@@ -1895,23 +1895,16 @@ static int ks_wlan_set_power_mgmt(struct net_device *dev,
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
if (*uwrq == POWER_MGMT_ACTIVE) { /* 0 */
priv->reg.power_mgmt = POWER_MGMT_ACTIVE;
} else if (*uwrq == POWER_MGMT_SAVE1) { /* 1 */
if (priv->reg.operation_mode == MODE_INFRASTRUCTURE)
priv->reg.power_mgmt = POWER_MGMT_SAVE1;
else
if (*uwrq != POWER_MGMT_ACTIVE &&
*uwrq != POWER_MGMT_SAVE1 &&
*uwrq != POWER_MGMT_SAVE2)
return -EINVAL;
} else if (*uwrq == POWER_MGMT_SAVE2) { /* 2 */
if (priv->reg.operation_mode == MODE_INFRASTRUCTURE)
priv->reg.power_mgmt = POWER_MGMT_SAVE2;
else
return -EINVAL;
} else {
if ((*uwrq == POWER_MGMT_SAVE1 || *uwrq == POWER_MGMT_SAVE2) &&
(priv->reg.operation_mode != MODE_INFRASTRUCTURE))
return -EINVAL;
}
priv->reg.power_mgmt = *uwrq;
hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST);
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment