Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e4c7fb3 authored by Sergio Paracuellos's avatar Sergio Paracuellos Committed by Greg Kroah-Hartman
Browse files

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: default avatarSergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b58e1dda
Loading
Loading
Loading
Loading
+6 −17
Original line number Diff line number Diff line
@@ -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 */
}