From: Sergio Paracuellos Date: Fri, 4 May 2018 04:16:19 +0000 (+0200) Subject: staging: ks7010: clean SME_MIC_FAILURE_REQUEST case in hostif_sme_execute X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=f398c5f4de79b851c1362d3ee8f4fd5e2713fab0;p=openwrt%2Fstaging%2Fblogic.git staging: ks7010: clean SME_MIC_FAILURE_REQUEST case in hostif_sme_execute 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 965a23d8218e..5dceadcc4f0b 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -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) {