Skip to contentSkip to conversation

staging: r8188eu: continue rtw_led_control cleanup

PATCH In review Martin Kaiser 2 participants 9 messages Sep 5, 2022 – Sep 6, 2022 Staging

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index c57059eeda34..dd3f0169ff94 100644
@@ -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
#2 lore raw

PATCH 2/7 staging: r8188eu: don't restart WPS blinking unnecessarily

In reply to Martin Kaiser

Simplify 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
index dd3f0169ff94..d899e42b703d 100644
@@ -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
#3 lore raw

PATCH 3/7 staging: r8188eu: always cancel blink_work before WPS blinking

In reply to Martin Kaiser

In 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
index d899e42b703d..72fef3ac8c0e 100644
@@ -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
#4 lore raw

PATCH 4/7 staging: r8188eu: always update status before WPS blinking

In reply to Martin Kaiser

Always 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
index 72fef3ac8c0e..4841bb2898ba 100644
@@ -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
#5 lore raw

PATCH 5/7 staging: r8188eu: always cancel blink_work when WPS failed

In reply to Martin Kaiser

Cancel 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
index 4841bb2898ba..80d9d8184fcd 100644
@@ -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
#6 lore raw

PATCH 6/7 staging: r8188eu: reset blink state when WPS fails

In reply to Martin Kaiser

When 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
index 80d9d8184fcd..f5af2e25e34a 100644
@@ -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
#7 lore raw

PATCH 7/7 staging: r8188eu: do not "scan blink" if we have a link

In reply to Martin Kaiser

Do 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
index f5af2e25e34a..5b7e12421d19 100644
@@ -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
Tested-by on the v1 series
#8 lore raw
In reply to Martin Kaiser
Quoted 11 lines · Martin Kaiser

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

Quoted 3 lines
  drivers/staging/r8188eu/core/rtw_led.c | 80 +++++++++-----------------
  1 file changed, 28 insertions(+), 52 deletions(-)

For all patches: