diff options
author | Sergio Paracuellos <sergio.paracuellos@gmail.com> | 2018-05-04 06:16:41 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-05-06 18:58:40 -0700 |
commit | 7f3c8bb5bcf3a133d1eeb171cf90888bc5253a69 (patch) | |
tree | 70458264796fb2d4eb36a19c5b6c2c25b30e4c8c | |
parent | 97d173c64301427174e144eeda4cb7af756589b6 (diff) |
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: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/ks7010/ks_wlan_net.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index a5401db1d565..53288c80df51 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2028,22 +2028,20 @@ static int ks_wlan_set_sleep_mode(struct net_device *dev, { struct ks_wlan_private *priv = netdev_priv(dev); - if (*uwrq == SLP_SLEEP) { - priv->sleep_mode = *uwrq; - 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 { + if (*uwrq != SLP_SLEEP && + *uwrq != SLP_ACTIVE) { netdev_err(dev, "SET_SLEEP_MODE %d error\n", *uwrq); 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; } |