2023-02-06 21:01:45

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 0/3] simplify suspend/resume functions

Here's some simple cleanups for suspend + resume.

Martin Kaiser (3):
staging: r8188eu: make ips_enter static
staging: r8188eu: make ips_leave static
staging: r8188eu: remove change_rfpwrstate

drivers/staging/r8188eu/core/rtw_pwrctrl.c | 23 ++++++++-----------
drivers/staging/r8188eu/include/rtw_pwrctrl.h | 3 ---
2 files changed, 10 insertions(+), 16 deletions(-)

--
2.30.2



2023-02-06 21:01:50

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 1/3] staging: r8188eu: make ips_enter static

The ips_enter function is used only in rtw_pwrctrl.c. We can make this
function static.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_pwrctrl.c | 2 +-
drivers/staging/r8188eu/include/rtw_pwrctrl.h | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c
index 5290ac36f08c..e70d78357bcb 100644
--- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c
+++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c
@@ -8,7 +8,7 @@
#include "../include/osdep_intf.h"
#include "../include/linux/usb.h"

-void ips_enter(struct adapter *padapter)
+static void ips_enter(struct adapter *padapter)
{
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
struct xmit_priv *pxmit_priv = &padapter->xmitpriv;
diff --git a/drivers/staging/r8188eu/include/rtw_pwrctrl.h b/drivers/staging/r8188eu/include/rtw_pwrctrl.h
index 6e9fdd66fad1..56492ab0f78d 100644
--- a/drivers/staging/r8188eu/include/rtw_pwrctrl.h
+++ b/drivers/staging/r8188eu/include/rtw_pwrctrl.h
@@ -99,7 +99,6 @@ void rtw_set_firmware_ps_mode(struct adapter *adapter, u8 mode);
void rtw_set_ps_mode(struct adapter *adapter, u8 ps_mode, u8 smart_ps,
u8 bcn_ant_mode);
void LeaveAllPowerSaveMode(struct adapter *adapter);
-void ips_enter(struct adapter *padapter);
int ips_leave(struct adapter *padapter);

void rtw_ps_processor(struct adapter *padapter);
--
2.30.2


2023-02-06 21:01:53

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 3/3] staging: r8188eu: remove change_rfpwrstate

Remove the change_rfpwrstate component in struct pwrctrl_priv.

change_rfpwrstate is set to rf_off directly before each ips_enter call and
then checked in ips_enter. This makes no sense.

change_rfpwrstate might have been used to avoid conflicts between
suspend and resume operations. If a driver has to do this at all,
pwrpriv->ps_processing will do this job.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_pwrctrl.c | 19 ++++++++-----------
drivers/staging/r8188eu/include/rtw_pwrctrl.h | 1 -
2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c
index 702a29f96d74..051cdcb11ff5 100644
--- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c
+++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c
@@ -25,15 +25,14 @@ static void ips_enter(struct adapter *padapter)
pwrpriv->ips_mode = pwrpriv->ips_mode_req;

pwrpriv->ips_enter_cnts++;
- if (rf_off == pwrpriv->change_rfpwrstate) {
- pwrpriv->bpower_saving = true;
+ pwrpriv->bpower_saving = true;

- if (pwrpriv->ips_mode == IPS_LEVEL_2)
- pwrpriv->bkeepfwalive = true;
+ if (pwrpriv->ips_mode == IPS_LEVEL_2)
+ pwrpriv->bkeepfwalive = true;
+
+ rtw_ips_pwr_down(padapter);
+ pwrpriv->rf_pwrstate = rf_off;

- rtw_ips_pwr_down(padapter);
- pwrpriv->rf_pwrstate = rf_off;
- }
pwrpriv->bips_processing = false;

mutex_unlock(&pwrpriv->lock);
@@ -51,7 +50,6 @@ static int ips_leave(struct adapter *padapter)

if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) {
pwrpriv->bips_processing = true;
- pwrpriv->change_rfpwrstate = rf_on;
pwrpriv->ips_leave_cnts++;

result = rtw_ips_pwr_up(padapter);
@@ -133,10 +131,9 @@ void rtw_ps_processor(struct adapter *padapter)
if (!rtw_pwr_unassociated_idle(padapter))
goto exit;

- if (pwrpriv->rf_pwrstate == rf_on) {
- pwrpriv->change_rfpwrstate = rf_off;
+ if (pwrpriv->rf_pwrstate == rf_on)
ips_enter(padapter);
- }
+
exit:
rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv);
pwrpriv->ps_processing = false;
diff --git a/drivers/staging/r8188eu/include/rtw_pwrctrl.h b/drivers/staging/r8188eu/include/rtw_pwrctrl.h
index f7aeac262fad..9f5cffd8bfb1 100644
--- a/drivers/staging/r8188eu/include/rtw_pwrctrl.h
+++ b/drivers/staging/r8188eu/include/rtw_pwrctrl.h
@@ -71,7 +71,6 @@ struct pwrctrl_priv {
int pwr_state_check_interval;

enum rt_rf_power_state rf_pwrstate;/* cur power state */
- enum rt_rf_power_state change_rfpwrstate;

u8 bkeepfwalive;
};
--
2.30.2


2023-02-06 21:01:56

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 2/3] staging: r8188eu: make ips_leave static

The ips_leave function is used only in rtw_pwrctrl.c. We can make this
function static.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_pwrctrl.c | 2 +-
drivers/staging/r8188eu/include/rtw_pwrctrl.h | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c
index e70d78357bcb..702a29f96d74 100644
--- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c
+++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c
@@ -39,7 +39,7 @@ static void ips_enter(struct adapter *padapter)
mutex_unlock(&pwrpriv->lock);
}

-int ips_leave(struct adapter *padapter)
+static int ips_leave(struct adapter *padapter)
{
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
struct security_priv *psecuritypriv = &padapter->securitypriv;
diff --git a/drivers/staging/r8188eu/include/rtw_pwrctrl.h b/drivers/staging/r8188eu/include/rtw_pwrctrl.h
index 56492ab0f78d..f7aeac262fad 100644
--- a/drivers/staging/r8188eu/include/rtw_pwrctrl.h
+++ b/drivers/staging/r8188eu/include/rtw_pwrctrl.h
@@ -99,7 +99,6 @@ void rtw_set_firmware_ps_mode(struct adapter *adapter, u8 mode);
void rtw_set_ps_mode(struct adapter *adapter, u8 ps_mode, u8 smart_ps,
u8 bcn_ant_mode);
void LeaveAllPowerSaveMode(struct adapter *adapter);
-int ips_leave(struct adapter *padapter);

void rtw_ps_processor(struct adapter *padapter);

--
2.30.2


2023-02-07 06:14:28

by Philipp Hortmann

[permalink] [raw]
Subject: Re: [PATCH 0/3] simplify suspend/resume functions

On 2/6/23 22:01, Martin Kaiser wrote:
> Here's some simple cleanups for suspend + resume.
>
> Martin Kaiser (3):
> staging: r8188eu: make ips_enter static
> staging: r8188eu: make ips_leave static
> staging: r8188eu: remove change_rfpwrstate
>
> drivers/staging/r8188eu/core/rtw_pwrctrl.c | 23 ++++++++-----------
> drivers/staging/r8188eu/include/rtw_pwrctrl.h | 3 ---
> 2 files changed, 10 insertions(+), 16 deletions(-)
>
Tested-by: Philipp Hortmann <[email protected]> # Edimax N150