staging: ks7010: refactor ks_wlan_set_preamble function
authorSergio Paracuellos <sergio.paracuellos@gmail.com>
Wed, 25 Apr 2018 14:01:44 +0000 (16:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Apr 2018 07:35:03 +0000 (09:35 +0200)
Change if logic to handle invalid values first and just
assign at the end the valid one if it is the case.

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 3c9fbb9bcd52b1813be5f563e7f0f0d56107db0a..87c051958bf34323f07365236dc06c443c7c1560 100644 (file)
@@ -1860,14 +1860,10 @@ static int ks_wlan_set_preamble(struct net_device *dev,
                return -EPERM;
 
        /* for SLEEP MODE */
-       if (*uwrq == LONG_PREAMBLE) {   /* 0 */
-               priv->reg.preamble = LONG_PREAMBLE;
-       } else if (*uwrq == SHORT_PREAMBLE) {   /* 1 */
-               priv->reg.preamble = SHORT_PREAMBLE;
-       } else {
+       if (*uwrq != LONG_PREAMBLE && *uwrq != SHORT_PREAMBLE)
                return -EINVAL;
-       }
 
+       priv->reg.preamble = *uwrq;
        priv->need_commit |= SME_MODE_SET;
        return -EINPROGRESS;    /* Call commit handler */
 }