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

staging: ks7010: refactor ks_wlan_set_sleep_mode function

This commit refactors ks_wlan_set_sleep_mode function
avoiding to use switch-case statement ans using simple
if logic to handle invalid values first. This simplifies
data paths as well as improves readability.
Signed-off-by: default avatarSergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 97d173c6
...@@ -2028,22 +2028,20 @@ static int ks_wlan_set_sleep_mode(struct net_device *dev, ...@@ -2028,22 +2028,20 @@ static int ks_wlan_set_sleep_mode(struct net_device *dev,
{ {
struct ks_wlan_private *priv = netdev_priv(dev); struct ks_wlan_private *priv = netdev_priv(dev);
if (*uwrq == SLP_SLEEP) { if (*uwrq != SLP_SLEEP &&
priv->sleep_mode = *uwrq; *uwrq != SLP_ACTIVE) {
netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode);
hostif_sme_enqueue(priv, SME_STOP_REQUEST);
hostif_sme_enqueue(priv, SME_SLEEP_REQUEST);
} else if (*uwrq == SLP_ACTIVE) {
priv->sleep_mode = *uwrq;
netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode);
hostif_sme_enqueue(priv, SME_SLEEP_REQUEST);
} else {
netdev_err(dev, "SET_SLEEP_MODE %d error\n", *uwrq); netdev_err(dev, "SET_SLEEP_MODE %d error\n", *uwrq);
return -EINVAL; return -EINVAL;
} }
priv->sleep_mode = *uwrq;
netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode);
if (*uwrq == SLP_SLEEP)
hostif_sme_enqueue(priv, SME_STOP_REQUEST);
hostif_sme_enqueue(priv, SME_SLEEP_REQUEST);
return 0; 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