From: Sergio Paracuellos Date: Wed, 25 Apr 2018 14:01:44 +0000 (+0200) Subject: staging: ks7010: refactor ks_wlan_set_preamble function X-Git-Tag: v4.18-rc1~83^2~457 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=8521b4e65e2330e5b952d4341976fe3b98c4efa0;p=uclinux-h8%2Flinux.git staging: ks7010: refactor ks_wlan_set_preamble function 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 3c9fbb9bcd52..87c051958bf3 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -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 */ }