staging: r8188eu: remove BlinkingLedState

Both bLedOn and BlinkingLedState in struct led_priv store the same
information.

The boolean bLedOn stores the curent led state while BlinkingLedState
stores the next led state to be set during blinking, which is the inverse
of the current led state. (The led is either off or blinking, it's never
continuously on.)

This patch removes BlinkingLedState and uses bLedOn instead.

The LED_BLINK_WPS_STOP case in blink_work checked for
pLed->BlinkingLedState != RTW_LED_ON. This is true if the next led
blinking state is ON, i.e. if the led has just been switched off by
blink_work, i.e. if (!pLed->bLedOn).

Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220918175700.215170-5-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Martin Kaiser 2022-09-18 19:56:58 +02:00 committed by Greg Kroah-Hartman
parent 64c82a8888
commit bf0d687586
2 changed files with 4 additions and 62 deletions

View File

@ -25,7 +25,6 @@ static void ResetLedStatus(struct led_priv *pLed)
pLed->bLedWPSBlinkInProgress = false; pLed->bLedWPSBlinkInProgress = false;
pLed->BlinkTimes = 0; /* Number of times to toggle led state for blinking. */ pLed->BlinkTimes = 0; /* Number of times to toggle led state for blinking. */
pLed->BlinkingLedState = LED_UNKNOWN; /* Next state for blinking, either RTW_LED_ON or RTW_LED_OFF are. */
pLed->bLedLinkBlinkInProgress = false; pLed->bLedLinkBlinkInProgress = false;
pLed->bLedScanBlinkInProgress = false; pLed->bLedScanBlinkInProgress = false;
@ -87,32 +86,19 @@ static void blink_work(struct work_struct *work)
return; return;
} }
/* Change LED according to BlinkingLedState specified. */ if (pLed->bLedOn)
if (pLed->BlinkingLedState == RTW_LED_ON)
SwLedOn(padapter, pLed);
else
SwLedOff(padapter, pLed); SwLedOff(padapter, pLed);
else
SwLedOn(padapter, pLed);
switch (pLed->CurrLedState) { switch (pLed->CurrLedState) {
case LED_BLINK_SLOWLY: case 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); schedule_delayed_work(&pLed->blink_work, LED_BLINK_NO_LINK_INTVL);
break; break;
case LED_BLINK_NORMAL: case LED_BLINK_NORMAL:
if (pLed->bLedOn)
pLed->BlinkingLedState = RTW_LED_OFF;
else
pLed->BlinkingLedState = RTW_LED_ON;
schedule_delayed_work(&pLed->blink_work, LED_BLINK_LINK_INTVL); schedule_delayed_work(&pLed->blink_work, LED_BLINK_LINK_INTVL);
break; break;
case LED_BLINK_SCAN: case LED_BLINK_SCAN:
if (pLed->bLedOn)
pLed->BlinkingLedState = RTW_LED_OFF;
else
pLed->BlinkingLedState = RTW_LED_ON;
pLed->BlinkTimes--; pLed->BlinkTimes--;
if (pLed->BlinkTimes == 0) { if (pLed->BlinkTimes == 0) {
if (check_fwstate(pmlmepriv, _FW_LINKED)) { if (check_fwstate(pmlmepriv, _FW_LINKED)) {
@ -129,10 +115,6 @@ static void blink_work(struct work_struct *work)
} }
break; break;
case LED_BLINK_TXRX: case LED_BLINK_TXRX:
if (pLed->bLedOn)
pLed->BlinkingLedState = RTW_LED_OFF;
else
pLed->BlinkingLedState = RTW_LED_ON;
pLed->BlinkTimes--; pLed->BlinkTimes--;
if (pLed->BlinkTimes == 0) { if (pLed->BlinkTimes == 0) {
if (check_fwstate(pmlmepriv, _FW_LINKED)) { if (check_fwstate(pmlmepriv, _FW_LINKED)) {
@ -149,25 +131,16 @@ static void blink_work(struct work_struct *work)
} }
break; break;
case LED_BLINK_WPS: case 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); schedule_delayed_work(&pLed->blink_work, LED_BLINK_SCAN_INTVL);
break; break;
case LED_BLINK_WPS_STOP: /* WPS success */ case LED_BLINK_WPS_STOP: /* WPS success */
if (pLed->BlinkingLedState != RTW_LED_ON) { if (!pLed->bLedOn) {
pLed->bLedLinkBlinkInProgress = true; pLed->bLedLinkBlinkInProgress = true;
pLed->CurrLedState = LED_BLINK_NORMAL; pLed->CurrLedState = LED_BLINK_NORMAL;
if (pLed->bLedOn)
pLed->BlinkingLedState = RTW_LED_OFF;
else
pLed->BlinkingLedState = RTW_LED_ON;
schedule_delayed_work(&pLed->blink_work, LED_BLINK_LINK_INTVL); schedule_delayed_work(&pLed->blink_work, LED_BLINK_LINK_INTVL);
pLed->bLedWPSBlinkInProgress = false; pLed->bLedWPSBlinkInProgress = false;
} else { } else {
pLed->BlinkingLedState = RTW_LED_OFF;
schedule_delayed_work(&pLed->blink_work, LED_BLINK_WPS_SUCESS_INTVL); schedule_delayed_work(&pLed->blink_work, LED_BLINK_WPS_SUCESS_INTVL);
} }
break; break;
@ -223,10 +196,6 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction)
pLed->bLedBlinkInProgress = false; pLed->bLedBlinkInProgress = false;
pLed->CurrLedState = LED_BLINK_SLOWLY; 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); schedule_delayed_work(&pLed->blink_work, LED_BLINK_NO_LINK_INTVL);
break; break;
case LED_CTL_LINK: case LED_CTL_LINK:
@ -242,10 +211,6 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction)
pLed->bLedLinkBlinkInProgress = true; pLed->bLedLinkBlinkInProgress = true;
pLed->CurrLedState = LED_BLINK_NORMAL; pLed->CurrLedState = LED_BLINK_NORMAL;
if (pLed->bLedOn)
pLed->BlinkingLedState = RTW_LED_OFF;
else
pLed->BlinkingLedState = RTW_LED_ON;
schedule_delayed_work(&pLed->blink_work, LED_BLINK_LINK_INTVL); schedule_delayed_work(&pLed->blink_work, LED_BLINK_LINK_INTVL);
break; break;
case LED_CTL_SITE_SURVEY: case LED_CTL_SITE_SURVEY:
@ -266,10 +231,6 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction)
pLed->CurrLedState = LED_BLINK_SCAN; pLed->CurrLedState = LED_BLINK_SCAN;
pLed->BlinkTimes = 24; pLed->BlinkTimes = 24;
if (pLed->bLedOn)
pLed->BlinkingLedState = RTW_LED_OFF;
else
pLed->BlinkingLedState = RTW_LED_ON;
schedule_delayed_work(&pLed->blink_work, LED_BLINK_SCAN_INTVL); schedule_delayed_work(&pLed->blink_work, LED_BLINK_SCAN_INTVL);
break; break;
case LED_CTL_TX: case LED_CTL_TX:
@ -287,10 +248,6 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction)
pLed->CurrLedState = LED_BLINK_TXRX; pLed->CurrLedState = LED_BLINK_TXRX;
pLed->BlinkTimes = 2; pLed->BlinkTimes = 2;
if (pLed->bLedOn)
pLed->BlinkingLedState = RTW_LED_OFF;
else
pLed->BlinkingLedState = RTW_LED_ON;
schedule_delayed_work(&pLed->blink_work, LED_BLINK_FASTER_INTVL); schedule_delayed_work(&pLed->blink_work, LED_BLINK_FASTER_INTVL);
break; break;
case LED_CTL_START_WPS: /* wait until xinpin finish */ case LED_CTL_START_WPS: /* wait until xinpin finish */
@ -304,10 +261,6 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction)
pLed->bLedScanBlinkInProgress = false; pLed->bLedScanBlinkInProgress = false;
pLed->bLedWPSBlinkInProgress = true; pLed->bLedWPSBlinkInProgress = true;
pLed->CurrLedState = LED_BLINK_WPS; 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); schedule_delayed_work(&pLed->blink_work, LED_BLINK_SCAN_INTVL);
break; break;
case LED_CTL_STOP_WPS: case LED_CTL_STOP_WPS:
@ -320,10 +273,8 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction)
pLed->CurrLedState = LED_BLINK_WPS_STOP; pLed->CurrLedState = LED_BLINK_WPS_STOP;
if (pLed->bLedOn) { if (pLed->bLedOn) {
pLed->BlinkingLedState = RTW_LED_OFF;
schedule_delayed_work(&pLed->blink_work, LED_BLINK_WPS_SUCESS_INTVL); schedule_delayed_work(&pLed->blink_work, LED_BLINK_WPS_SUCESS_INTVL);
} else { } else {
pLed->BlinkingLedState = RTW_LED_ON;
schedule_delayed_work(&pLed->blink_work, 0); schedule_delayed_work(&pLed->blink_work, 0);
} }
break; break;
@ -331,15 +282,10 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction)
cancel_delayed_work(&pLed->blink_work); cancel_delayed_work(&pLed->blink_work);
pLed->bLedWPSBlinkInProgress = false; pLed->bLedWPSBlinkInProgress = false;
pLed->CurrLedState = LED_BLINK_SLOWLY; 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); schedule_delayed_work(&pLed->blink_work, LED_BLINK_NO_LINK_INTVL);
break; break;
case LED_CTL_POWER_OFF: case LED_CTL_POWER_OFF:
pLed->CurrLedState = RTW_LED_OFF; pLed->CurrLedState = RTW_LED_OFF;
pLed->BlinkingLedState = RTW_LED_OFF;
pLed->bLedLinkBlinkInProgress = false; pLed->bLedLinkBlinkInProgress = false;
pLed->bLedBlinkInProgress = false; pLed->bLedBlinkInProgress = false;
pLed->bLedWPSBlinkInProgress = false; pLed->bLedWPSBlinkInProgress = false;

View File

@ -21,8 +21,6 @@ enum LED_CTL_MODE {
}; };
enum LED_STATE_871x { enum LED_STATE_871x {
LED_UNKNOWN = 0,
RTW_LED_ON = 1,
RTW_LED_OFF = 2, RTW_LED_OFF = 2,
LED_BLINK_NORMAL = 3, LED_BLINK_NORMAL = 3,
LED_BLINK_SLOWLY = 4, LED_BLINK_SLOWLY = 4,
@ -43,8 +41,6 @@ struct led_priv {
bool bRegUseLed; bool bRegUseLed;
enum LED_STATE_871x CurrLedState; /* Current LED state. */ enum LED_STATE_871x CurrLedState; /* Current LED state. */
enum LED_STATE_871x BlinkingLedState; /* Next state for blinking,
* either RTW_LED_ON or RTW_LED_OFF are. */
bool bLedOn; /* true if LED is ON, false if LED is OFF. */ bool bLedOn; /* true if LED is ON, false if LED is OFF. */