2024-06-03 09:19:02

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 0/6] net: use 'time_left' instead of 'timeout' with wait_*() functions

There is a confusing pattern in the kernel to use a variable named 'timeout' to
store the result of wait_*() functions causing patterns like:

timeout = wait_for_completion_timeout(...)
if (!timeout) return -ETIMEDOUT;

with all kinds of permutations. Use 'time_left' as a variable to make the code
obvious and self explaining.

This is part of a tree-wide series. The rest of the patches can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/time_left

Because these patches are generated, I audit them before sending. This is why I
will send series step by step. Build bot is happy with these patches, though.
No functional changes intended.


Wolfram Sang (6):
wifi: ath11k: use 'time_left' variable with wait_event_timeout()
wifi: brcmfmac: use 'time_left' variable with wait_event_timeout()
wifi: mac80211: use 'time_left' variable with
wait_for_completion_timeout()
wifi: p54: use 'time_left' variable with
wait_for_completion_interruptible_timeout()
wifi: rtw89: use 'time_left' variable with
wait_for_completion_timeout()
wifi: zd1211rw: use 'time_left' variable with
wait_for_completion_timeout()

drivers/net/wireless/ath/ath11k/qmi.c | 20 +++++++++----------
.../broadcom/brcm80211/brcmfmac/cfg80211.c | 10 +++++-----
drivers/net/wireless/intersil/p54/fwio.c | 6 +++---
drivers/net/wireless/intersil/p54/p54pci.c | 8 ++++----
drivers/net/wireless/intersil/p54/p54spi.c | 10 +++++-----
drivers/net/wireless/marvell/mwl8k.c | 10 +++++-----
drivers/net/wireless/realtek/rtw89/core.c | 6 +++---
drivers/net/wireless/zydas/zd1211rw/zd_usb.c | 8 ++++----
8 files changed, 39 insertions(+), 39 deletions(-)

--
2.43.0



2024-06-03 09:22:52

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 5/6] wifi: rtw89: use 'time_left' variable with wait_for_completion_timeout()

There is a confusing pattern in the kernel to use a variable named 'timeout' to
store the result of wait_for_completion_timeout() causing patterns like:

timeout = wait_for_completion_timeout(...)
if (!timeout) return -ETIMEDOUT;

with all kinds of permutations. Use 'time_left' as a variable to make the code
self explaining.

Signed-off-by: Wolfram Sang <[email protected]>
---
drivers/net/wireless/realtek/rtw89/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index ddc390d24ec1..16ab834185b4 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -4022,15 +4022,15 @@ void rtw89_core_update_beacon_work(struct work_struct *work)
int rtw89_wait_for_cond(struct rtw89_wait_info *wait, unsigned int cond)
{
struct completion *cmpl = &wait->completion;
- unsigned long timeout;
+ unsigned long time_left;
unsigned int cur;

cur = atomic_cmpxchg(&wait->cond, RTW89_WAIT_COND_IDLE, cond);
if (cur != RTW89_WAIT_COND_IDLE)
return -EBUSY;

- timeout = wait_for_completion_timeout(cmpl, RTW89_WAIT_FOR_COND_TIMEOUT);
- if (timeout == 0) {
+ time_left = wait_for_completion_timeout(cmpl, RTW89_WAIT_FOR_COND_TIMEOUT);
+ if (time_left == 0) {
atomic_set(&wait->cond, RTW89_WAIT_COND_IDLE);
return -ETIMEDOUT;
}
--
2.43.0


2024-06-04 00:35:55

by Ping-Ke Shih

[permalink] [raw]
Subject: RE: [PATCH 5/6] wifi: rtw89: use 'time_left' variable with wait_for_completion_timeout()

Wolfram Sang <[email protected]> wrote:
> There is a confusing pattern in the kernel to use a variable named 'timeout' to
> store the result of wait_for_completion_timeout() causing patterns like:
>
> timeout = wait_for_completion_timeout(...)
> if (!timeout) return -ETIMEDOUT;
>
> with all kinds of permutations. Use 'time_left' as a variable to make the code
> self explaining.
>
> Signed-off-by: Wolfram Sang <[email protected]>

Acked-by: Ping-Ke Shih <[email protected]>



2024-06-04 08:58:09

by Ping-Ke Shih

[permalink] [raw]
Subject: RE: [PATCH 5/6] wifi: rtw89: use 'time_left' variable with wait_for_completion_timeout()

Kalle Valo <[email protected]> wrote:
> Ping-Ke Shih <[email protected]> writes:
>
> > Wolfram Sang <[email protected]> wrote:
> >> There is a confusing pattern in the kernel to use a variable named 'timeout' to
> >> store the result of wait_for_completion_timeout() causing patterns like:
> >>
> >> timeout = wait_for_completion_timeout(...)
> >> if (!timeout) return -ETIMEDOUT;
> >>
> >> with all kinds of permutations. Use 'time_left' as a variable to make the code
> >> self explaining.
> >>
> >> Signed-off-by: Wolfram Sang <[email protected]>
> >
> > Acked-by: Ping-Ke Shih <[email protected]>
>
> BTW Ping, you can also take it directly to your tree if you want. But if you
> want me to take the patch, then please assign it to me on patchwork (ie.
> change 'Delegate to' to 'kvalo'). My preference is to take it to your
> tree, smaller risk of concflicts that way, but up to you.

I will take it to my tree.

Ping-Ke