From: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Date: Tue, 24 Apr 2018 13:49:57 +0000 (+0200)
Subject: staging: ks7010: refactor ks_wlan_set_mode function
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=1e4c7fb3a54ec2b1be17c7d2d1b53c593f959a1d;p=linux.git

staging: ks7010: refactor ks_wlan_set_mode function

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>
---

diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index 58226789812fb..cb3d0a898b5f6 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -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 */
 }