staging: ks7010: refactor ks_wlan_set_cts_mode function
authorSergio Paracuellos <sergio.paracuellos@gmail.com>
Wed, 25 Apr 2018 14:01:45 +0000 (16:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Apr 2018 07:35:03 +0000 (09:35 +0200)
This commit refactors ks_wlan_set_cts_mode function to
handle invalid values first and then assign the good
one changing a bit logic to use a ternary operator.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ks7010/ks_wlan_net.c

index 87c051958bf34323f07365236dc06c443c7c1560..a398b6a2b3e31037c2440f0fb338dabf21468e54 100644 (file)
@@ -2030,18 +2030,13 @@ static int ks_wlan_set_cts_mode(struct net_device *dev,
        if (priv->sleep_mode == SLP_SLEEP)
                return -EPERM;
        /* for SLEEP MODE */
-       if (*uwrq == CTS_MODE_FALSE) {  /* 0 */
-               priv->reg.cts_mode = CTS_MODE_FALSE;
-       } else if (*uwrq == CTS_MODE_TRUE) {    /* 1 */
-               if (priv->reg.phy_type == D_11G_ONLY_MODE ||
-                   priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) {
-                       priv->reg.cts_mode = CTS_MODE_TRUE;
-               } else {
-                       priv->reg.cts_mode = CTS_MODE_FALSE;
-               }
-       } else {
+       if (*uwrq != CTS_MODE_FALSE && *uwrq != CTS_MODE_TRUE)
                return -EINVAL;
-       }
+
+       priv->reg.cts_mode = (*uwrq == CTS_MODE_FALSE) ? *uwrq :
+                             (priv->reg.phy_type == D_11G_ONLY_MODE ||
+                              priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) ?
+                              *uwrq : !*uwrq;
 
        priv->need_commit |= SME_MODE_SET;
        return -EINPROGRESS;    /* Call commit handler */