staging: rtl8188eu: refactor SwLedControlMode1()
authorMichael Straube <straube.linux@gmail.com>
Sat, 8 Sep 2018 12:13:51 +0000 (14:13 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Sep 2018 16:35:15 +0000 (18:35 +0200)
Refactor switch cases in SwLedControlMode1() to reduce
indentation level. Also clears line over 80 characters
checkpatch warnings.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8188eu/core/rtw_led.c

index cbef871a76798cf88e88ce30794abdcd669f95a2..217a1aaab8a150ea305ae0a85347a3784325facd 100644 (file)
@@ -245,131 +245,134 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct
        case LED_CTL_POWER_ON:
        case LED_CTL_START_TO_LINK:
        case LED_CTL_NO_LINK:
-               if (!pLed->bLedNoLinkBlinkInProgress) {
-                       if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed))
-                               return;
-                       if (pLed->bLedLinkBlinkInProgress) {
-                               del_timer_sync(&pLed->BlinkTimer);
-                               pLed->bLedLinkBlinkInProgress = false;
-                       }
-                       if (pLed->bLedBlinkInProgress) {
-                               del_timer_sync(&pLed->BlinkTimer);
-                               pLed->bLedBlinkInProgress = false;
-                       }
-
-                       pLed->bLedNoLinkBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_SLOWLY;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       mod_timer(&pLed->BlinkTimer, jiffies +
-                                 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
+               if (pLed->bLedNoLinkBlinkInProgress)
+                       break;
+               if (pLed->CurrLedState == LED_BLINK_SCAN ||
+                   IS_LED_WPS_BLINKING(pLed))
+                       return;
+               if (pLed->bLedLinkBlinkInProgress) {
+                       del_timer_sync(&pLed->BlinkTimer);
+                       pLed->bLedLinkBlinkInProgress = false;
+               }
+               if (pLed->bLedBlinkInProgress) {
+                       del_timer_sync(&pLed->BlinkTimer);
+                       pLed->bLedBlinkInProgress = false;
                }
+               pLed->bLedNoLinkBlinkInProgress = true;
+               pLed->CurrLedState = LED_BLINK_SLOWLY;
+               if (pLed->bLedOn)
+                       pLed->BlinkingLedState = RTW_LED_OFF;
+               else
+                       pLed->BlinkingLedState = RTW_LED_ON;
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                break;
        case LED_CTL_LINK:
-               if (!pLed->bLedLinkBlinkInProgress) {
-                       if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed))
-                               return;
-                       if (pLed->bLedNoLinkBlinkInProgress) {
-                               del_timer_sync(&pLed->BlinkTimer);
-                               pLed->bLedNoLinkBlinkInProgress = false;
-                       }
-                       if (pLed->bLedBlinkInProgress) {
-                               del_timer_sync(&pLed->BlinkTimer);
-                               pLed->bLedBlinkInProgress = false;
-                       }
-                       pLed->bLedLinkBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_NORMAL;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       mod_timer(&pLed->BlinkTimer, jiffies +
-                                 msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA));
+               if (pLed->bLedLinkBlinkInProgress)
+                       break;
+               if (pLed->CurrLedState == LED_BLINK_SCAN ||
+                   IS_LED_WPS_BLINKING(pLed))
+                       return;
+               if (pLed->bLedNoLinkBlinkInProgress) {
+                       del_timer_sync(&pLed->BlinkTimer);
+                       pLed->bLedNoLinkBlinkInProgress = false;
+               }
+               if (pLed->bLedBlinkInProgress) {
+                       del_timer_sync(&pLed->BlinkTimer);
+                       pLed->bLedBlinkInProgress = false;
                }
+               pLed->bLedLinkBlinkInProgress = true;
+               pLed->CurrLedState = LED_BLINK_NORMAL;
+               if (pLed->bLedOn)
+                       pLed->BlinkingLedState = RTW_LED_OFF;
+               else
+                       pLed->BlinkingLedState = RTW_LED_ON;
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA));
                break;
        case LED_CTL_SITE_SURVEY:
-               if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) {
-                       ;
-               } else if (!pLed->bLedScanBlinkInProgress) {
-                       if (IS_LED_WPS_BLINKING(pLed))
-                               return;
-                       if (pLed->bLedNoLinkBlinkInProgress) {
-                               del_timer_sync(&pLed->BlinkTimer);
-                               pLed->bLedNoLinkBlinkInProgress = false;
-                       }
-                       if (pLed->bLedLinkBlinkInProgress) {
-                               del_timer_sync(&pLed->BlinkTimer);
-                                pLed->bLedLinkBlinkInProgress = false;
-                       }
-                       if (pLed->bLedBlinkInProgress) {
-                               del_timer_sync(&pLed->BlinkTimer);
-                               pLed->bLedBlinkInProgress = false;
-                       }
-                       pLed->bLedScanBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_SCAN;
-                       pLed->BlinkTimes = 24;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       mod_timer(&pLed->BlinkTimer, jiffies +
-                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
+               if (pmlmepriv->LinkDetectInfo.bBusyTraffic &&
+                   check_fwstate(pmlmepriv, _FW_LINKED))
+                       break;
+               if (pLed->bLedScanBlinkInProgress)
+                       break;
+               if (IS_LED_WPS_BLINKING(pLed))
+                       return;
+               if (pLed->bLedNoLinkBlinkInProgress) {
+                       del_timer_sync(&pLed->BlinkTimer);
+                       pLed->bLedNoLinkBlinkInProgress = false;
                }
+               if (pLed->bLedLinkBlinkInProgress) {
+                       del_timer_sync(&pLed->BlinkTimer);
+                       pLed->bLedLinkBlinkInProgress = false;
+               }
+               if (pLed->bLedBlinkInProgress) {
+                       del_timer_sync(&pLed->BlinkTimer);
+                       pLed->bLedBlinkInProgress = false;
+               }
+               pLed->bLedScanBlinkInProgress = true;
+               pLed->CurrLedState = LED_BLINK_SCAN;
+               pLed->BlinkTimes = 24;
+               if (pLed->bLedOn)
+                       pLed->BlinkingLedState = RTW_LED_OFF;
+               else
+                       pLed->BlinkingLedState = RTW_LED_ON;
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                break;
        case LED_CTL_TX:
        case LED_CTL_RX:
-               if (!pLed->bLedBlinkInProgress) {
-                       if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed))
-                               return;
-                       if (pLed->bLedNoLinkBlinkInProgress) {
-                               del_timer_sync(&pLed->BlinkTimer);
-                               pLed->bLedNoLinkBlinkInProgress = false;
-                       }
-                       if (pLed->bLedLinkBlinkInProgress) {
-                               del_timer_sync(&pLed->BlinkTimer);
-                               pLed->bLedLinkBlinkInProgress = false;
-                       }
-                       pLed->bLedBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_TXRX;
-                       pLed->BlinkTimes = 2;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       mod_timer(&pLed->BlinkTimer, jiffies +
-                                 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
+               if (pLed->bLedBlinkInProgress)
+                       break;
+               if (pLed->CurrLedState == LED_BLINK_SCAN ||
+                   IS_LED_WPS_BLINKING(pLed))
+                       return;
+               if (pLed->bLedNoLinkBlinkInProgress) {
+                       del_timer_sync(&pLed->BlinkTimer);
+                       pLed->bLedNoLinkBlinkInProgress = false;
+               }
+               if (pLed->bLedLinkBlinkInProgress) {
+                       del_timer_sync(&pLed->BlinkTimer);
+                       pLed->bLedLinkBlinkInProgress = false;
                }
+               pLed->bLedBlinkInProgress = true;
+               pLed->CurrLedState = LED_BLINK_TXRX;
+               pLed->BlinkTimes = 2;
+               if (pLed->bLedOn)
+                       pLed->BlinkingLedState = RTW_LED_OFF;
+               else
+                       pLed->BlinkingLedState = RTW_LED_ON;
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                break;
        case LED_CTL_START_WPS: /* wait until xinpin finish */
        case LED_CTL_START_WPS_BOTTON:
-               if (!pLed->bLedWPSBlinkInProgress) {
-                       if (pLed->bLedNoLinkBlinkInProgress) {
-                               del_timer_sync(&pLed->BlinkTimer);
-                               pLed->bLedNoLinkBlinkInProgress = false;
-                       }
-                       if (pLed->bLedLinkBlinkInProgress) {
-                               del_timer_sync(&pLed->BlinkTimer);
-                                pLed->bLedLinkBlinkInProgress = false;
-                       }
-                       if (pLed->bLedBlinkInProgress) {
-                               del_timer_sync(&pLed->BlinkTimer);
-                               pLed->bLedBlinkInProgress = false;
-                       }
-                       if (pLed->bLedScanBlinkInProgress) {
-                               del_timer_sync(&pLed->BlinkTimer);
-                               pLed->bLedScanBlinkInProgress = false;
-                       }
-                       pLed->bLedWPSBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_WPS;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       mod_timer(&pLed->BlinkTimer, jiffies +
-                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
+               if (pLed->bLedWPSBlinkInProgress)
+                       break;
+               if (pLed->bLedNoLinkBlinkInProgress) {
+                       del_timer_sync(&pLed->BlinkTimer);
+                       pLed->bLedNoLinkBlinkInProgress = false;
                }
+               if (pLed->bLedLinkBlinkInProgress) {
+                       del_timer_sync(&pLed->BlinkTimer);
+                        pLed->bLedLinkBlinkInProgress = false;
+               }
+               if (pLed->bLedBlinkInProgress) {
+                       del_timer_sync(&pLed->BlinkTimer);
+                       pLed->bLedBlinkInProgress = false;
+               }
+               if (pLed->bLedScanBlinkInProgress) {
+                       del_timer_sync(&pLed->BlinkTimer);
+                       pLed->bLedScanBlinkInProgress = false;
+               }
+               pLed->bLedWPSBlinkInProgress = true;
+               pLed->CurrLedState = LED_BLINK_WPS;
+               if (pLed->bLedOn)
+                       pLed->BlinkingLedState = RTW_LED_OFF;
+               else
+                       pLed->BlinkingLedState = RTW_LED_ON;
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                break;
        case LED_CTL_STOP_WPS:
                if (pLed->bLedNoLinkBlinkInProgress) {