staging: r8188eu: continue rtw_led_control cleanup
cover staging: r8188eu: continue rtw_led_control cleanup
Here's some more small patches to make rtw_led_control simpler.
Martin Kaiser (7):
staging: r8188eu: simplify the LED_CTL_POWER_OFF case
staging: r8188eu: don't restart WPS blinking unnecessarily
staging: r8188eu: always cancel blink_work before WPS blinking
staging: r8188eu: always update status before WPS blinking
staging: r8188eu: always cancel blink_work when WPS failed
staging: r8188eu: reset blink state when WPS fails
staging: r8188eu: do not "scan blink" if we have a link
drivers/staging/r8188eu/core/rtw_led.c | 80 +++++++++----------------- 1 file changed, 28 insertions(+), 52 deletions(-)
Signature · 1 line
2.30.2
PATCH 1/7 staging: r8188eu: simplify the LED_CTL_POWER_OFF case
When a caller of rtw_led_control requests that the led be switched off, we should cancel the blink worker and set all blinking state variables to false. This does not depend on the current blinking state.
--- drivers/staging/r8188eu/core/rtw_led.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)
drivers/staging/r8188eu/core/rtw_led.c +6 -20
@@ -381,26 +381,12 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction)case LED_CTL_POWER_OFF : pLed->CurrLedState =RTW_LED_OFF ; pLed->BlinkingLedState =RTW_LED_OFF ; -if (pLed->bLedNoLinkBlinkInProgress) { -cancel_delayed_work (&pLed->blink_work); - pLed->bLedNoLinkBlinkInProgress = false; - } -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->bLedWPSBlinkInProgress) { -cancel_delayed_work (&pLed->blink_work); - pLed->bLedWPSBlinkInProgress = false; - } -if (pLed->bLedScanBlinkInProgress) { -cancel_delayed_work (&pLed->blink_work); - pLed->bLedScanBlinkInProgress = false; - } + pLed->bLedNoLinkBlinkInProgress = false; + pLed->bLedLinkBlinkInProgress = false; + pLed->bLedBlinkInProgress = false; + pLed->bLedWPSBlinkInProgress = false; + pLed->bLedScanBlinkInProgress = false; +cancel_delayed_work (&pLed->blink_work);SwLedOff (padapter, pLed);break ;default :
Signature · 1 line
2.30.2
PATCH 2/7 staging: r8188eu: don't restart WPS blinking unnecessarily
In reply to Martin KaiserSimplify one of the cases in rtw_led_control. If we're already blinking during WPS, we don't have to restart this blinking when the caller requests it again. We can simply return and keep on blinking.
--- drivers/staging/r8188eu/core/rtw_led.c | 49 +++++++++++++------------- 1 file changed, 25 insertions(+), 24 deletions(-)
drivers/staging/r8188eu/core/rtw_led.c +25 -24
@@ -309,31 +309,32 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction) }break ;case LED_CTL_START_WPS :/* wait until xinpin finish */ -if (!pLed->bLedWPSBlinkInProgress) { -if (pLed->bLedNoLinkBlinkInProgress) { -cancel_delayed_work (&pLed->blink_work); - pLed->bLedNoLinkBlinkInProgress = false; - } -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->bLedScanBlinkInProgress) { -cancel_delayed_work (&pLed->blink_work); - 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 ; -schedule_delayed_work (&pLed->blink_work,LED_BLINK_SCAN_INTVL ); +if (pLed->bLedWPSBlinkInProgress) +return ; + +if (pLed->bLedNoLinkBlinkInProgress) { +cancel_delayed_work (&pLed->blink_work); + pLed->bLedNoLinkBlinkInProgress = false; } +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->bLedScanBlinkInProgress) { +cancel_delayed_work (&pLed->blink_work); + 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 ; +schedule_delayed_work (&pLed->blink_work,LED_BLINK_SCAN_INTVL );break ;case LED_CTL_STOP_WPS :if (pLed->bLedNoLinkBlinkInProgress) {
Signature · 1 line
2.30.2
PATCH 3/7 staging: r8188eu: always cancel blink_work before WPS blinking
In reply to Martin KaiserIn rtw_led_control, we can always cancel a running blink worker when we start WPS blinking.
The worker will be scheduled again and there's no point in having more than one pending blink worker.
--- drivers/staging/r8188eu/core/rtw_led.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/staging/r8188eu/core/rtw_led.c +9 -12
@@ -312,22 +312,19 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction)if (pLed->bLedWPSBlinkInProgress)return ; -if (pLed->bLedNoLinkBlinkInProgress) { -cancel_delayed_work (&pLed->blink_work); +cancel_delayed_work (&pLed->blink_work); +if (pLed->bLedNoLinkBlinkInProgress) pLed->bLedNoLinkBlinkInProgress = false; - } -if (pLed->bLedLinkBlinkInProgress) { -cancel_delayed_work (&pLed->blink_work); + +if (pLed->bLedLinkBlinkInProgress) pLed->bLedLinkBlinkInProgress = false; - } -if (pLed->bLedBlinkInProgress) { -cancel_delayed_work (&pLed->blink_work); + +if (pLed->bLedBlinkInProgress) pLed->bLedBlinkInProgress = false; - } -if (pLed->bLedScanBlinkInProgress) { -cancel_delayed_work (&pLed->blink_work); + +if (pLed->bLedScanBlinkInProgress) pLed->bLedScanBlinkInProgress = false; - } + pLed->bLedWPSBlinkInProgress = true; pLed->CurrLedState =LED_BLINK_WPS ;if (pLed->bLedOn)
Signature · 1 line
2.30.2
PATCH 4/7 staging: r8188eu: always update status before WPS blinking
In reply to Martin KaiserAlways update the status variables in rtw_led_control when we start WPS blinking. The code is easier to understand without the if conditions.
--- drivers/staging/r8188eu/core/rtw_led.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/staging/r8188eu/core/rtw_led.c +4 -11
@@ -313,18 +313,11 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction)return ;cancel_delayed_work (&pLed->blink_work); -if (pLed->bLedNoLinkBlinkInProgress) - pLed->bLedNoLinkBlinkInProgress = false; - -if (pLed->bLedLinkBlinkInProgress) - pLed->bLedLinkBlinkInProgress = false; - -if (pLed->bLedBlinkInProgress) - pLed->bLedBlinkInProgress = false; - -if (pLed->bLedScanBlinkInProgress) - pLed->bLedScanBlinkInProgress = false; + pLed->bLedNoLinkBlinkInProgress = false; + pLed->bLedLinkBlinkInProgress = false; + pLed->bLedBlinkInProgress = false; + pLed->bLedScanBlinkInProgress = false; pLed->bLedWPSBlinkInProgress = true; pLed->CurrLedState =LED_BLINK_WPS ;if (pLed->bLedOn)
Signature · 1 line
2.30.2
PATCH 5/7 staging: r8188eu: always cancel blink_work when WPS failed
In reply to Martin KaiserCancel blink_work if WPS fails. Another worker will be scheduled after the state variables are updated.
--- drivers/staging/r8188eu/core/rtw_led.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/r8188eu/core/rtw_led.c +1 -1
@@ -357,8 +357,8 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction) }break ;case LED_CTL_STOP_WPS_FAIL : +cancel_delayed_work (&pLed->blink_work);if (pLed->bLedWPSBlinkInProgress) { -cancel_delayed_work (&pLed->blink_work); pLed->bLedWPSBlinkInProgress = false; } pLed->bLedNoLinkBlinkInProgress = true;
Signature · 1 line
2.30.2
PATCH 6/7 staging: r8188eu: reset blink state when WPS fails
In reply to Martin KaiserWhen WPS fails, WPS blinking is no longer in progress. The if statement can be removed.
--- drivers/staging/r8188eu/core/rtw_led.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_led.c +1 -3
@@ -358,9 +358,7 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction)break ;case LED_CTL_STOP_WPS_FAIL :cancel_delayed_work (&pLed->blink_work); -if (pLed->bLedWPSBlinkInProgress) { - pLed->bLedWPSBlinkInProgress = false; - } + pLed->bLedWPSBlinkInProgress = false; pLed->bLedNoLinkBlinkInProgress = true; pLed->CurrLedState =LED_BLINK_SLOWLY ;if (pLed->bLedOn)
Signature · 1 line
2.30.2
PATCH 7/7 staging: r8188eu: do not "scan blink" if we have a link
In reply to Martin KaiserDo not blink the led to indicate that we're scanning if we are already connected to a wireless network.
--- drivers/staging/r8188eu/core/rtw_led.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_led.c +4 -3
@@ -258,9 +258,10 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction) }break ;case LED_CTL_SITE_SURVEY : -if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate (pmlmepriv, _FW_LINKED))) { - ; - }else if (!pLed->bLedScanBlinkInProgress) { +if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate (pmlmepriv, _FW_LINKED))) +return ; + +if (!pLed->bLedScanBlinkInProgress) {if (IS_LED_WPS_BLINKING (pLed))return ;if (pLed->bLedNoLinkBlinkInProgress) {
Signature · 1 line
2.30.2
Quoted 11 lines · Martin Kaiser
Here's some more small patches to make
rtw_led_controlsimpler.Martin Kaiser (7):
staging: r8188eu: simplify theLED_CTL_POWER_OFFcase
staging: r8188eu: don't restart WPS blinking unnecessarily
staging: r8188eu: always cancelblink_workbefore WPS blinking
staging: r8188eu: always update status before WPS blinking
staging: r8188eu: always cancelblink_workwhen WPS failed
staging: r8188eu: reset blink state when WPS fails
staging: r8188eu: do not "scan blink" if we have a link
Quoted 3 lines
drivers/staging/r8188eu/core/rtw_led.c | 80 +++++++++----------------- 1 file changed, 28 insertions(+), 52 deletions(-)
For all patches: