staging: ks7010: refactor ks_wlan_set_mode function
authorSergio Paracuellos <sergio.paracuellos@gmail.com>
Tue, 24 Apr 2018 13:49:57 +0000 (15:49 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Apr 2018 13:50:18 +0000 (15:50 +0200)
Most cases which are being handled in the switch-case of
ks_wlan_set_mode function are just returning EINVAL. Avoid
the use of switch-case stament and just use a simple if
to handle those. This decrease LOC as well as improves
readability.

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 5822678..cb3d0a8 100644 (file)
@@ -745,24 +745,13 @@ static int ks_wlan_set_mode(struct net_device *dev,
        if (priv->sleep_mode == SLP_SLEEP)
                return -EPERM;
 
-       /* for SLEEP MODE */
-       switch (uwrq->mode) {
-       case IW_MODE_ADHOC:
-               priv->reg.operation_mode = MODE_ADHOC;
-               priv->need_commit |= SME_MODE_SET;
-               break;
-       case IW_MODE_INFRA:
-               priv->reg.operation_mode = MODE_INFRASTRUCTURE;
-               priv->need_commit |= SME_MODE_SET;
-               break;
-       case IW_MODE_AUTO:
-       case IW_MODE_MASTER:
-       case IW_MODE_REPEAT:
-       case IW_MODE_SECOND:
-       case IW_MODE_MONITOR:
-       default:
+       if (uwrq->mode != IW_MODE_ADHOC &&
+           uwrq->mode != IW_MODE_INFRA)
                return -EINVAL;
-       }
+
+       priv->reg.operation_mode = (uwrq->mode == IW_MODE_ADHOC) ?
+                                   MODE_ADHOC : MODE_INFRASTRUCTURE;
+       priv->need_commit |= SME_MODE_SET;
 
        return -EINPROGRESS;    /* Call commit handler */
 }