diff options
author | Sergio Paracuellos <sergio.paracuellos@gmail.com> | 2018-05-04 06:16:42 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-05-06 18:58:40 -0700 |
commit | 81255d867c7fa3e3e5c3b0000a7938466c492265 (patch) | |
tree | eaca5816958abc5d5d5a15be90bb6158d65a8231 | |
parent | 7f3c8bb5bcf3a133d1eeb171cf90888bc5253a69 (diff) | |
download | linux-81255d867c7fa3e3e5c3b0000a7938466c492265.tar.bz2 |
staging: ks7010: refactor ks_wlan_set_phy_type function
Handle invalid values first and assign good ones at the
end if it is the case. This makes code simplier.
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/ks7010/ks_wlan_net.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 53288c80df51..62a9d55e854a 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1960,17 +1960,14 @@ static int ks_wlan_set_phy_type(struct net_device *dev, if (priv->sleep_mode == SLP_SLEEP) return -EPERM; - /* for SLEEP MODE */ - if (*uwrq == D_11B_ONLY_MODE) { /* 0 */ - priv->reg.phy_type = D_11B_ONLY_MODE; - } else if (*uwrq == D_11G_ONLY_MODE) { /* 1 */ - priv->reg.phy_type = D_11G_ONLY_MODE; - } else if (*uwrq == D_11BG_COMPATIBLE_MODE) { /* 2 */ - priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; - } else { + + if (*uwrq != D_11B_ONLY_MODE && + *uwrq != D_11G_ONLY_MODE && + *uwrq != D_11BG_COMPATIBLE_MODE) return -EINVAL; - } + /* for SLEEP MODE */ + priv->reg.phy_type = *uwrq; priv->need_commit |= SME_MODE_SET; return -EINPROGRESS; /* Call commit handler */ } |