* [PATCH 0/3] staging: r8188eu: start cleaning up led blinking
@ 2022-08-22 20:13 Martin Kaiser
2022-08-22 20:13 ` [PATCH 1/3] staging: r8188eu: don't restart "no link" blinking unnecessarily Martin Kaiser
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Martin Kaiser @ 2022-08-22 20:13 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
linux-staging, linux-kernel, Martin Kaiser
The code for led blinking contains too many states and state variables.
This series is a first tiny step towards cleaning things up.
Martin Kaiser (3):
staging: r8188eu: don't restart "no link" blinking unnecessarily
staging: r8188eu: always cancel blink_work
staging: r8188eu: always update the status variables
drivers/staging/r8188eu/core/rtw_led.c | 36 ++++++++++++--------------
1 file changed, 17 insertions(+), 19 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] staging: r8188eu: don't restart "no link" blinking unnecessarily
2022-08-22 20:13 [PATCH 0/3] staging: r8188eu: start cleaning up led blinking Martin Kaiser
@ 2022-08-22 20:13 ` Martin Kaiser
2022-08-22 20:13 ` [PATCH 2/3] staging: r8188eu: always cancel blink_work Martin Kaiser
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Martin Kaiser @ 2022-08-22 20:13 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
linux-staging, linux-kernel, Martin Kaiser
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>
---
drivers/staging/r8188eu/core/rtw_led.c | 37 +++++++++++++-------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c
index d5c6c5e29621..d3299fd1e39d 100644
--- a/drivers/staging/r8188eu/core/rtw_led.c
+++ b/drivers/staging/r8188eu/core/rtw_led.c
@@ -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) {
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] staging: r8188eu: always cancel blink_work
2022-08-22 20:13 [PATCH 0/3] staging: r8188eu: start cleaning up led blinking Martin Kaiser
2022-08-22 20:13 ` [PATCH 1/3] staging: r8188eu: don't restart "no link" blinking unnecessarily Martin Kaiser
@ 2022-08-22 20:13 ` Martin Kaiser
2022-08-22 20:13 ` [PATCH 3/3] staging: r8188eu: always update the status variables Martin Kaiser
2022-08-23 18:49 ` [PATCH 0/3] staging: r8188eu: start cleaning up led blinking Philipp Hortmann
3 siblings, 0 replies; 5+ messages in thread
From: Martin Kaiser @ 2022-08-22 20:13 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
linux-staging, linux-kernel, Martin Kaiser
In rtw_led_control, we can always cancel a running blink worker when we
start blinking because of no link.
The worker will be scheduled again and there's no point in having more
than one pending blink worker.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
drivers/staging/r8188eu/core/rtw_led.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c
index d3299fd1e39d..e63bcf9c0e84 100644
--- a/drivers/staging/r8188eu/core/rtw_led.c
+++ b/drivers/staging/r8188eu/core/rtw_led.c
@@ -222,14 +222,14 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction)
if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed))
return;
- if (pLed->bLedLinkBlinkInProgress) {
- cancel_delayed_work(&pLed->blink_work);
+
+ 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;
- }
pLed->bLedNoLinkBlinkInProgress = true;
pLed->CurrLedState = LED_BLINK_SLOWLY;
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] staging: r8188eu: always update the status variables
2022-08-22 20:13 [PATCH 0/3] staging: r8188eu: start cleaning up led blinking Martin Kaiser
2022-08-22 20:13 ` [PATCH 1/3] staging: r8188eu: don't restart "no link" blinking unnecessarily Martin Kaiser
2022-08-22 20:13 ` [PATCH 2/3] staging: r8188eu: always cancel blink_work Martin Kaiser
@ 2022-08-22 20:13 ` Martin Kaiser
2022-08-23 18:49 ` [PATCH 0/3] staging: r8188eu: start cleaning up led blinking Philipp Hortmann
3 siblings, 0 replies; 5+ messages in thread
From: Martin Kaiser @ 2022-08-22 20:13 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
linux-staging, linux-kernel, Martin Kaiser
Always update the status variables in rtw_led_control when we start
blinking because of no link. The code is easier to understand without
the if conditions.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
drivers/staging/r8188eu/core/rtw_led.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c
index e63bcf9c0e84..c57059eeda34 100644
--- a/drivers/staging/r8188eu/core/rtw_led.c
+++ b/drivers/staging/r8188eu/core/rtw_led.c
@@ -225,13 +225,10 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction)
cancel_delayed_work(&pLed->blink_work);
- if (pLed->bLedLinkBlinkInProgress)
- pLed->bLedLinkBlinkInProgress = false;
-
- if (pLed->bLedBlinkInProgress)
- pLed->bLedBlinkInProgress = false;
-
+ pLed->bLedLinkBlinkInProgress = false;
+ pLed->bLedBlinkInProgress = false;
pLed->bLedNoLinkBlinkInProgress = true;
+
pLed->CurrLedState = LED_BLINK_SLOWLY;
if (pLed->bLedOn)
pLed->BlinkingLedState = RTW_LED_OFF;
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] staging: r8188eu: start cleaning up led blinking
2022-08-22 20:13 [PATCH 0/3] staging: r8188eu: start cleaning up led blinking Martin Kaiser
` (2 preceding siblings ...)
2022-08-22 20:13 ` [PATCH 3/3] staging: r8188eu: always update the status variables Martin Kaiser
@ 2022-08-23 18:49 ` Philipp Hortmann
3 siblings, 0 replies; 5+ messages in thread
From: Philipp Hortmann @ 2022-08-23 18:49 UTC (permalink / raw)
To: Martin Kaiser, Greg Kroah-Hartman
Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
linux-staging, linux-kernel
On 8/22/22 22:13, Martin Kaiser wrote:
> The code for led blinking contains too many states and state variables.
> This series is a first tiny step towards cleaning things up.
>
> Martin Kaiser (3):
> staging: r8188eu: don't restart "no link" blinking unnecessarily
> staging: r8188eu: always cancel blink_work
> staging: r8188eu: always update the status variables
>
> drivers/staging/r8188eu/core/rtw_led.c | 36 ++++++++++++--------------
> 1 file changed, 17 insertions(+), 19 deletions(-)
>
Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-08-23 18:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-22 20:13 [PATCH 0/3] staging: r8188eu: start cleaning up led blinking Martin Kaiser
2022-08-22 20:13 ` [PATCH 1/3] staging: r8188eu: don't restart "no link" blinking unnecessarily Martin Kaiser
2022-08-22 20:13 ` [PATCH 2/3] staging: r8188eu: always cancel blink_work Martin Kaiser
2022-08-22 20:13 ` [PATCH 3/3] staging: r8188eu: always update the status variables Martin Kaiser
2022-08-23 18:49 ` [PATCH 0/3] staging: r8188eu: start cleaning up led blinking Philipp Hortmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.