Commit 1dd0ac70 authored by Martin Kaiser's avatar Martin Kaiser Committed by Greg Kroah-Hartman

staging: r8188eu: clean up the code to set ips_deny_time

Clean up the code in rtw_pwr_wakeup that sets pwrpriv->ips_deny_time.

Make ips_deny_time an unsigned long, this type is used by the kernel
functions that process jiffies.

Remove the temporary variable ips_deffer_ms and use
RTW_PWR_STATE_CHK_INTERVAL directly.

There's no need to set ips_deny_time twice, it's sufficient to set it at
the end of rtw_pwr_wakeup.

Use time_before to check if ips_deny_time should be updated.

We can now remove rtw_ms_to_systime, this function is not used any more.
Signed-off-by: default avatarMartin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220413193654.258507-7-martin@kaiser.cxSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3b9d0da6
...@@ -373,14 +373,8 @@ int rtw_pwr_wakeup(struct adapter *padapter) ...@@ -373,14 +373,8 @@ int rtw_pwr_wakeup(struct adapter *padapter)
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
unsigned long timeout = jiffies + msecs_to_jiffies(3000); unsigned long timeout = jiffies + msecs_to_jiffies(3000);
unsigned long deny_time;
int ret = _SUCCESS; int ret = _SUCCESS;
u32 ips_deffer_ms;
/* the ms will prevent from falling into IPS after wakeup */
ips_deffer_ms = RTW_PWR_STATE_CHK_INTERVAL;
if (pwrpriv->ips_deny_time < jiffies + rtw_ms_to_systime(ips_deffer_ms))
pwrpriv->ips_deny_time = jiffies + rtw_ms_to_systime(ips_deffer_ms);
while (pwrpriv->ps_processing && time_before(jiffies, timeout)) while (pwrpriv->ps_processing && time_before(jiffies, timeout))
msleep(10); msleep(10);
...@@ -406,8 +400,9 @@ int rtw_pwr_wakeup(struct adapter *padapter) ...@@ -406,8 +400,9 @@ int rtw_pwr_wakeup(struct adapter *padapter)
} }
exit: exit:
if (pwrpriv->ips_deny_time < jiffies + rtw_ms_to_systime(ips_deffer_ms)) deny_time = jiffies + msecs_to_jiffies(RTW_PWR_STATE_CHK_INTERVAL);
pwrpriv->ips_deny_time = jiffies + rtw_ms_to_systime(ips_deffer_ms); if (time_before(pwrpriv->ips_deny_time, deny_time))
pwrpriv->ips_deny_time = deny_time;
return ret; return ret;
} }
......
...@@ -78,7 +78,6 @@ void *rtw_malloc2d(int h, int w, int size); ...@@ -78,7 +78,6 @@ void *rtw_malloc2d(int h, int w, int size);
} while (0) } while (0)
u32 rtw_systime_to_ms(u32 systime); u32 rtw_systime_to_ms(u32 systime);
u32 rtw_ms_to_systime(u32 ms);
s32 rtw_get_passing_time_ms(u32 start); s32 rtw_get_passing_time_ms(u32 start);
void rtw_usleep_os(int us); void rtw_usleep_os(int us);
......
...@@ -56,7 +56,7 @@ struct pwrctrl_priv { ...@@ -56,7 +56,7 @@ struct pwrctrl_priv {
u8 ips_mode_req; /* used to accept the mode setting request, u8 ips_mode_req; /* used to accept the mode setting request,
* will update to ipsmode later */ * will update to ipsmode later */
uint bips_processing; uint bips_processing;
u32 ips_deny_time; /* will deny IPS when system time less than this */ unsigned long ips_deny_time; /* will deny IPS when system time less than this */
u8 ps_processing; /* temp used to mark whether in rtw_ps_processor */ u8 ps_processing; /* temp used to mark whether in rtw_ps_processor */
u8 bLeisurePs; u8 bLeisurePs;
......
...@@ -47,11 +47,6 @@ inline u32 rtw_systime_to_ms(u32 systime) ...@@ -47,11 +47,6 @@ inline u32 rtw_systime_to_ms(u32 systime)
return systime * 1000 / HZ; return systime * 1000 / HZ;
} }
inline u32 rtw_ms_to_systime(u32 ms)
{
return ms * HZ / 1000;
}
/* the input parameter start use the same unit as jiffies */ /* the input parameter start use the same unit as jiffies */
inline s32 rtw_get_passing_time_ms(u32 start) inline s32 rtw_get_passing_time_ms(u32 start)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment