staging: r8188eu: don't restart "no link" blinking unnecessarily
authorMartin Kaiser <martin@kaiser.cx>
Mon, 22 Aug 2022 20:13:27 +0000 (22:13 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Aug 2022 13:43:40 +0000 (15:43 +0200)
Simplify one of the cases in rtw_led_control. If we're already blinking
because we have no link, we don't have to restart this blinking when the
caller requests it again. We can simply return and keep on blinking.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220822201329.95559-2-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/core/rtw_led.c

index d5c6c5e..d3299fd 100644 (file)
@@ -217,26 +217,27 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction)
        switch (LedAction) {
        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) {
-                               cancel_delayed_work(&pLed->blink_work);
-                               pLed->bLedLinkBlinkInProgress = false;
-                       }
-                       if (pLed->bLedBlinkInProgress) {
-                               cancel_delayed_work(&pLed->blink_work);
-                               pLed->bLedBlinkInProgress = false;
-                       }
+               if (pLed->bLedNoLinkBlinkInProgress)
+                       return;
 
-                       pLed->bLedNoLinkBlinkInProgress = true;
-                       pLed->CurrLedState = LED_BLINK_SLOWLY;
-                       if (pLed->bLedOn)
-                               pLed->BlinkingLedState = RTW_LED_OFF;
-                       else
-                               pLed->BlinkingLedState = RTW_LED_ON;
-                       schedule_delayed_work(&pLed->blink_work, LED_BLINK_NO_LINK_INTVL);
+               if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed))
+                       return;
+               if (pLed->bLedLinkBlinkInProgress) {
+                       cancel_delayed_work(&pLed->blink_work);
+                       pLed->bLedLinkBlinkInProgress = false;
                }
+               if (pLed->bLedBlinkInProgress) {
+                       cancel_delayed_work(&pLed->blink_work);
+                       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;
+               schedule_delayed_work(&pLed->blink_work, LED_BLINK_NO_LINK_INTVL);
                break;
        case LED_CTL_LINK:
                if (!pLed->bLedLinkBlinkInProgress) {