From: 王擎 <wangqing@vivo.com>
To: Martin Kaiser <lists@kaiser.cx>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-staging@lists.linux.dev" <linux-staging@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: 回复: [PATCH] r8188eu: core: use time_is_after_eq_jiffies() instead of open coding it
Date: Mon, 7 Mar 2022 01:56:08 +0000 [thread overview]
Message-ID: <SL2PR06MB30829C82386B3278C2E4A17ABD089@SL2PR06MB3082.apcprd06.prod.outlook.com> (raw)
In-Reply-To: <YiNCJFFLPcD+aGnr@martin-debian-1.paytec.ch>
>Hi,
>
>Thus wrote Qing Wang (wangqing@vivo.com):
>
>> From: Wang Qing <wangqing@vivo.com>
>
>> Use the helper function time_is_{before,after}_jiffies() to improve
>> code readability.
>
>> Signed-off-by: Wang Qing <wangqing@vivo.com>
>> ---
>> drivers/staging/r8188eu/core/rtw_pwrctrl.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>> diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c
>> index 46e44ae..9894abb
>> --- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c
>> +++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c
>> @@ -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) ||
>> --
>> 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
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
next prev parent reply other threads:[~2022-03-07 1:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-28 3:14 Qing Wang
2022-03-05 10:57 ` Martin Kaiser
2022-03-07 1:56 ` 王擎 [this message]
2022-03-08 20:44 ` 回复: " Martin Kaiser
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=SL2PR06MB30829C82386B3278C2E4A17ABD089@SL2PR06MB3082.apcprd06.prod.outlook.com \
--to=wangqing@vivo.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=lists@kaiser.cx \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®