r8188eu: core: use time_is_after_eq_jiffies() instead of open coding it
PATCH 1/1 r8188eu: core: use time_is_after_eq_jiffies() instead of open coding it
From: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
--- drivers/staging/r8188eu/core/rtw_pwrctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/r8188eu/core/rtw_pwrctrl.c +1 -1
@@ -102,7 +102,7 @@ static bool rtw_pwr_unassociated_idle(struct adapter *adapter)struct wifidirect_info *pwdinfo = &adapter->wdinfo;bool ret = false; -if (adapter->pwrctrlpriv.ips_deny_time >= jiffies) +if (time_is_after_eq_jiffies (adapter->pwrctrlpriv.ips_deny_time)) goto exit; if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE | WIFI_SITE_MONITOR) ||
Signature · 1 line
2.7.4
Hi,
Thus wrote Qing Wang ([email protected]):
Quoted 25 lines
From: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
Signed-off-by Wang Qing <[email protected]>--- drivers/staging/r8188eu/core/rtw_pwrctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/r8188eu/core/rtw_pwrctrl.c +1
-1@@ -102,7 +102,7 @@ static bool rtw_pwr_unassociated_idle(struct adapter *adapter)struct wifidirect_info *pwdinfo = &adapter->wdinfo;bool ret = false; -if (adapter->pwrctrlpriv.ips_deny_time >= jiffies) +if (time_is_after_eq_jiffies (adapter->pwrctrlpriv.ips_deny_time)) goto exit; if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE | WIFI_SITE_MONITOR) ||Signature · 1 line
2.7.4
This doesn't compile on my system:
CC [M] drivers/staging/r8188eu/core/rtw_p2p.o
In file included from ./include/linux/irqflags.h:15,
from ./arch/arm/include/asm/atomic.h:14,
from ./include/linux/atomic.h:7,
from ./include/linux/rcupdate.h:25,
from ./include/linux/rculist.h:11,
from ./include/linux/sched/signal.h:5,
from drivers/staging/r8188eu/core/../include/osdep_service.h:7,
from drivers/staging/r8188eu/core/rtw_pwrctrl.c:6:drivers/staging/r8188eu/core/rtw_pwrctrl.c: In function ‘rtw_pwr_unassociated_idle’:./include/linux/typecheck.h:12:25: warning: comparison of distinct pointer types lacks a cast
12 | (void)(&__dummy == &__dummy2); \
| ^~./include/linux/jiffies.h:111:10: note: in expansion of macro ‘typecheck’
111 | (typecheck(unsigned long, a) && \
| ^~~~~~~~~
./include/linux/jiffies.h:114:33: note: in expansion of macro ‘time_after_eq’
114 | #define time_before_eq(a,b) time_after_eq(b,a)
| ^~~~~~~~~~~~~
./include/linux/jiffies.h:166:37: note: in expansion of macro ‘time_before_eq’
166 | #define time_is_after_eq_jiffies(a) time_before_eq(jiffies, a)
| ^~~~~~~~~~~~~~
drivers/staging/r8188eu/core/rtw_pwrctrl.c:92:13: note: in expansion of macro ‘time_is_after_eq_jiffies’
92 | if (time_is_after_eq_jiffies(adapter->pwrctrlpriv.ips_deny_time))
| ^~~~~~~~~~~~~~~~~~~~~~~~time_is_after_eq_jiffies checks at compile time that its argument is unsigned long but ips_deny_time is u32 in the r8188eu driver.
We should change ips_deny_time to unsigned long, the rtl8723bs driver did this as well. ips_deny_time is used in these places
11 92 drivers/staging/r8188eu/core/rtw_pwrctrl.c <<rtw_pwr_unassociated_idle>>
if (adapter->pwrctrlpriv.ips_deny_time >= jiffies)
12 363 drivers/staging/r8188eu/core/rtw_pwrctrl.c <<_rtw_pwr_wakeup>>
if (pwrpriv->ips_deny_time < jiffies + rtw_ms_to_systime(ips_deffer_ms))
13 364 drivers/staging/r8188eu/core/rtw_pwrctrl.c <<_rtw_pwr_wakeup>>
pwrpriv->ips_deny_time = jiffies + rtw_ms_to_systime(ips_deffer_ms);
14 399 drivers/staging/r8188eu/core/rtw_pwrctrl.c <<_rtw_pwr_wakeup>>
if (pwrpriv->ips_deny_time < jiffies + rtw_ms_to_systime(ips_deffer_ms))
15 400 drivers/staging/r8188eu/core/rtw_pwrctrl.c <<_rtw_pwr_wakeup>>
pwrpriv->ips_deny_time = jiffies + rtw_ms_to_systime(ips_deffer_ms);rtw_ms_to_systime converts milliseconds to jiffies and returns u32. We should use msecs_to_jiffies instead, this functions returns unsigned long.
Do you want to have a go at this?
Best regards,
Martin
Quoted 45 lines
Hi,
Thus wrote Qing Wang ([email protected]):
Quoted 22 lines
From: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
Signed-off-by Wang Qing <[email protected]>---
drivers/staging/r8188eu/core/rtw_pwrctrl.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/r8188eu/core/rtw_pwrctrl.c +1
-1@@ -102,7 +102,7 @@ static bool rtw_pwr_unassociated_idle(struct adapter *adapter) struct wifidirect_info *pwdinfo = &adapter->wdinfo; bool ret = false; - if (adapter->pwrctrlpriv.ips_deny_time >= jiffies) + if (time_is_after_eq_jiffies(adapter->pwrctrlpriv.ips_deny_time)) goto exit;Quoted 3 lines
if (
check_fwstate(pmlmepriv, WIFI_ASOC_STATE | WIFI_SITE_MONITOR)||Signature · 1 line
2.7.4This doesn't compile on my system:
CC [M]
drivers/staging/r8188eu/core/rtw_p2p.o
In file included from./include/linux/irqflags.h:15,
from./arch/arm/include/asm/atomic.h:14,
from./include/linux/atomic.h:7,
from./include/linux/rcupdate.h:25,
from./include/linux/rculist.h:11,
from./include/linux/sched/signal.h:5,
fromdrivers/staging/r8188eu/core/../include/osdep_service.h:7, fromdrivers/staging/r8188eu/core/rtw_pwrctrl.c:6:drivers/staging/r8188eu/core/rtw_pwrctrl.c: In function ‘rtw_pwr_unassociated_idle’:./include/linux/typecheck.h:12:25: warning: comparison of distinct pointer types lacks a cast
Quoted 8 lines
12 | (void)(&__dummy ==
&__dummy2); \
| ^~./include/linux/jiffies.h:111:10: note: in expansion of macro ‘typecheck’ 111 | (typecheck(unsigned long, a)&& \
| ^~~~~~~~~./include/linux/jiffies.h:114:33: note: in expansion of macro ‘time_after_eq’ 114 | #define time_before_eq(a,b)time_after_eq(b,a)
| ^~~~~~~~~~~~~
./include/linux/jiffies.h:166:37: note: in expansion of macro ‘time_before_eq’
Quoted 25 lines
166 | #define
time_is_after_eq_jiffies(a)time_before_eq(jiffies, a)
| ^~~~~~~~~~~~~~drivers/staging/r8188eu/core/rtw_pwrctrl.c:92:13: note: in expansion of macro ‘time_is_after_eq_jiffies’ 92 | if (time_is_after_eq_jiffies(adapter->pwrctrlpriv.ips_deny_time))
| ^~~~~~~~~~~~~~~~~~~~~~~~
time_is_after_eq_jiffieschecks at compile time that its argument is unsigned long butips_deny_timeis u32 in the r8188eu driver.We should change
ips_deny_timeto unsigned long, the rtl8723bs driver did this as well.ips_deny_timeis used in these places11 92
drivers/staging/r8188eu/core/rtw_pwrctrl.c<<rtw_pwr_unassociated_idle>> if (adapter->pwrctrlpriv.ips_deny_time>= jiffies)
12 363drivers/staging/r8188eu/core/rtw_pwrctrl.c<<_rtw_pwr_wakeup>> if (pwrpriv->ips_deny_time< jiffies +rtw_ms_to_systime(ips_deffer_ms)) 13 364drivers/staging/r8188eu/core/rtw_pwrctrl.c<<_rtw_pwr_wakeup>>pwrpriv->ips_deny_time= jiffies +rtw_ms_to_systime(ips_deffer_ms); 14 399drivers/staging/r8188eu/core/rtw_pwrctrl.c<<_rtw_pwr_wakeup>> if (pwrpriv->ips_deny_time< jiffies +rtw_ms_to_systime(ips_deffer_ms)) 15 400drivers/staging/r8188eu/core/rtw_pwrctrl.c<<_rtw_pwr_wakeup>>pwrpriv->ips_deny_time= jiffies +rtw_ms_to_systime(ips_deffer_ms);
Quoted 8 lines
rtw_ms_to_systimeconverts milliseconds to jiffies and returns u32. We should usemsecs_to_jiffiesinstead, this functions returns unsigned long.Do you want to have a go at this?
Best regards,
Martin
I see rtl8723bs/include/rtw_pwrctrl.h also has a definition of struct pwrctrl_priv on it, which is unsigned long ips_deny_time.
Is there any difference, or should it be changed to unsigned long?
Thanks,
Wang
Thus wrote 王擎 ([email protected]):
Quoted 83 lines
Quoted 44 lines
Hi,
Thus wrote Qing Wang ([email protected]):
Quoted 22 lines
From: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
Signed-off-by Wang Qing <[email protected]>---
drivers/staging/r8188eu/core/rtw_pwrctrl.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/r8188eu/core/rtw_pwrctrl.c +1
-1@@ -102,7 +102,7 @@ static bool rtw_pwr_unassociated_idle(struct adapter *adapter) struct wifidirect_info *pwdinfo = &adapter->wdinfo; bool ret = false; - if (adapter->pwrctrlpriv.ips_deny_time >= jiffies) + if (time_is_after_eq_jiffies(adapter->pwrctrlpriv.ips_deny_time)) goto exit;Quoted 3 lines
if (
check_fwstate(pmlmepriv, WIFI_ASOC_STATE | WIFI_SITE_MONITOR)||Signature · 1 line
2.7.4This doesn't compile on my system:
CC [M]
drivers/staging/r8188eu/core/rtw_p2p.o
In file included from./include/linux/irqflags.h:15,
from./arch/arm/include/asm/atomic.h:14,
from./include/linux/atomic.h:7,
from./include/linux/rcupdate.h:25,
from./include/linux/rculist.h:11,
from./include/linux/sched/signal.h:5,
fromdrivers/staging/r8188eu/core/../include/osdep_service.h:7, fromdrivers/staging/r8188eu/core/rtw_pwrctrl.c:6:drivers/staging/r8188eu/core/rtw_pwrctrl.c: In function ‘rtw_pwr_unassociated_idle’:./include/linux/typecheck.h:12:25: warning: comparison of distinct pointer types lacks a castQuoted 8 lines
12 | (void)(&__dummy ==
&__dummy2); \
| ^~./include/linux/jiffies.h:111:10: note: in expansion of macro ‘typecheck’ 111 | (typecheck(unsigned long, a)&& \
| ^~~~~~~~~./include/linux/jiffies.h:114:33: note: in expansion of macro ‘time_after_eq’ 114 | #define time_before_eq(a,b)time_after_eq(b,a)
| ^~~~~~~~~~~~~
./include/linux/jiffies.h:166:37: note: in expansion of macro ‘time_before_eq’Quoted 29 lines
166 | #define
time_is_after_eq_jiffies(a)time_before_eq(jiffies, a)
| ^~~~~~~~~~~~~~drivers/staging/r8188eu/core/rtw_pwrctrl.c:92:13: note: in expansion of macro ‘time_is_after_eq_jiffies’ 92 | if (time_is_after_eq_jiffies(adapter->pwrctrlpriv.ips_deny_time))
| ^~~~~~~~~~~~~~~~~~~~~~~~
time_is_after_eq_jiffieschecks at compile time that its argument is unsigned long butips_deny_timeis u32 in the r8188eu driver.We should change
ips_deny_timeto unsigned long, the rtl8723bs driver did this as well.ips_deny_timeis used in these places11 92
drivers/staging/r8188eu/core/rtw_pwrctrl.c<<rtw_pwr_unassociated_idle>> if (adapter->pwrctrlpriv.ips_deny_time>= jiffies)
12 363drivers/staging/r8188eu/core/rtw_pwrctrl.c<<_rtw_pwr_wakeup>> if (pwrpriv->ips_deny_time< jiffies +rtw_ms_to_systime(ips_deffer_ms)) 13 364drivers/staging/r8188eu/core/rtw_pwrctrl.c<<_rtw_pwr_wakeup>>pwrpriv->ips_deny_time= jiffies +rtw_ms_to_systime(ips_deffer_ms); 14 399drivers/staging/r8188eu/core/rtw_pwrctrl.c<<_rtw_pwr_wakeup>> if (pwrpriv->ips_deny_time< jiffies +rtw_ms_to_systime(ips_deffer_ms)) 15 400drivers/staging/r8188eu/core/rtw_pwrctrl.c<<_rtw_pwr_wakeup>>pwrpriv->ips_deny_time= jiffies +rtw_ms_to_systime(ips_deffer_ms);
rtw_ms_to_systimeconverts milliseconds to jiffies and returns u32. We should usemsecs_to_jiffiesinstead, this functions returns unsigned long.Do you want to have a go at this?
Quoted 7 lines
Quoted 3 lines
Best regards,
Martin
I see
rtl8723bs/include/rtw_pwrctrl.halso has a definition of structpwrctrl_privon it, which is unsigned longips_deny_time.
Is there any difference, or should it be changed to unsigned long?
Hi Wang,
yes, I believe that we should change ips_deny_time to unsigned long.
But before this, we have to change rtw_ms_to_systime to msecs_to_jiffies.
Best regards,
Martin