staging: ks7010: refactor ks_wlan_set_scan_type function
authorSergio Paracuellos <sergio.paracuellos@gmail.com>
Wed, 25 Apr 2018 14:01:42 +0000 (16:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Apr 2018 07:35:03 +0000 (09:35 +0200)
This commit changes logic to handle invalid values first
and just assign valid ones afterwards.

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 e2e72cd7e457de577bce5a06b17e435927e42599..e943d372c393c3e8ca4a3d6199f326ccd884153e 100644 (file)
@@ -1940,14 +1940,11 @@ static int ks_wlan_set_scan_type(struct net_device *dev,
        if (priv->sleep_mode == SLP_SLEEP)
                return -EPERM;
        /* for SLEEP MODE */
-       if (*uwrq == ACTIVE_SCAN) {     /* 0 */
-               priv->reg.scan_type = ACTIVE_SCAN;
-       } else if (*uwrq == PASSIVE_SCAN) {     /* 1 */
-               priv->reg.scan_type = PASSIVE_SCAN;
-       } else {
+
+       if (*uwrq != ACTIVE_SCAN && *uwrq != PASSIVE_SCAN)
                return -EINVAL;
-       }
 
+       priv->reg.scan_type = *uwrq;
        return 0;
 }