staging: ks7010: clean SME_MIC_FAILURE_REQUEST case in hostif_sme_execute
authorSergio Paracuellos <sergio.paracuellos@gmail.com>
Fri, 4 May 2018 04:16:19 +0000 (06:16 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 7 May 2018 01:58:38 +0000 (18:58 -0700)
This commit cleans code for the event SME_MIC_FAILURE_REQUEST
changing if logic to handle invalid value first and using a
local variable.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ks7010/ks_hostif.c

index 965a23d8218ef9a616d80962cf3b83f589f03af6..5dceadcc4f0b412b8a58f03578821f33343cee78 100644 (file)
@@ -2070,10 +2070,10 @@ void hostif_sme_set_pmksa(struct ks_wlan_private *priv)
 }
 
 /* execute sme */
-static
-void hostif_sme_execute(struct ks_wlan_private *priv, int event)
+static void hostif_sme_execute(struct ks_wlan_private *priv, int event)
 {
        __le32 val;
+       u16 failure;
 
        switch (event) {
        case SME_START:
@@ -2099,18 +2099,15 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event)
                hostif_phy_information_request(priv);
                break;
        case SME_MIC_FAILURE_REQUEST:
-               if (priv->wpa.mic_failure.failure == 1) {
-                       hostif_mic_failure_request(priv,
-                                                  priv->wpa.mic_failure.failure - 1,
-                                                  0);
-               } else if (priv->wpa.mic_failure.failure == 2) {
-                       hostif_mic_failure_request(priv,
-                                                  priv->wpa.mic_failure.failure - 1,
-                                                  priv->wpa.mic_failure.counter);
-               } else {
-                       netdev_err(priv->net_dev, "SME_MIC_FAILURE_REQUEST: failure count=%u error?\n",
-                                  priv->wpa.mic_failure.failure);
+               failure = priv->wpa.mic_failure.failure;
+               if (failure != 1 && failure != 2) {
+                       netdev_err(priv->net_dev,
+                                  "SME_MIC_FAILURE_REQUEST: failure count=%u error?\n",
+                                  failure);
+                       return;
                }
+               hostif_mic_failure_request(priv, failure - 1, (failure == 1) ?
+                                           0 : priv->wpa.mic_failure.counter);
                break;
        case SME_MIC_FAILURE_CONFIRM:
                if (priv->wpa.mic_failure.failure == 2) {