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: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
7a2cc8db50
commit
c871258052
@ -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
|
||||
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_ACTIVE &&
|
||||
*uwrq != POWER_MGMT_SAVE1 &&
|
||||
*uwrq != POWER_MGMT_SAVE2)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user