Linux brcm80211 wireless device drivers
 help / color / mirror / Atom feed
* [PATCH 0/6] net: use 'time_left' instead of 'timeout' with wait_*() functions
@ 2024-06-03  9:15 Wolfram Sang
  2024-06-03  9:15 ` [PATCH 2/6] wifi: brcmfmac: use 'time_left' variable with wait_event_timeout() Wolfram Sang
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2024-06-03  9:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wolfram Sang, Arend van Spriel, ath11k, brcm80211-dev-list.pdl,
	brcm80211, Christian Lamparter, Jeff Johnson, Kalle Valo,
	linux-wireless, Ping-Ke Shih

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/6] wifi: brcmfmac: use 'time_left' variable with wait_event_timeout()
  2024-06-03  9:15 [PATCH 0/6] net: use 'time_left' instead of 'timeout' with wait_*() functions Wolfram Sang
@ 2024-06-03  9:15 ` Wolfram Sang
  2024-06-03  9:42   ` Arend van Spriel
  2024-06-12 12:01   ` Kalle Valo
  0 siblings, 2 replies; 5+ messages in thread
From: Wolfram Sang @ 2024-06-03  9:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wolfram Sang, Arend van Spriel, Kalle Valo, linux-wireless,
	brcm80211, brcm80211-dev-list.pdl

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

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

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

Fix to the proper variable type 'long' while here.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 .../wireless/broadcom/brcm80211/brcmfmac/cfg80211.c    | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 5fe0e671ecb3..1585a5653ee4 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -4071,7 +4071,7 @@ static void brcmf_report_wowl_wakeind(struct wiphy *wiphy, struct brcmf_if *ifp)
 	struct cfg80211_wowlan_wakeup *wakeup;
 	u32 wakeind;
 	s32 err;
-	int timeout;
+	long time_left;
 
 	err = brcmf_fil_iovar_data_get(ifp, "wowl_wakeind", &wake_ind_le,
 				       sizeof(wake_ind_le));
@@ -4113,10 +4113,10 @@ static void brcmf_report_wowl_wakeind(struct wiphy *wiphy, struct brcmf_if *ifp)
 		}
 		if (wakeind & BRCMF_WOWL_PFN_FOUND) {
 			brcmf_dbg(INFO, "WOWL Wake indicator: BRCMF_WOWL_PFN_FOUND\n");
-			timeout = wait_event_timeout(cfg->wowl.nd_data_wait,
-				cfg->wowl.nd_data_completed,
-				BRCMF_ND_INFO_TIMEOUT);
-			if (!timeout)
+			time_left = wait_event_timeout(cfg->wowl.nd_data_wait,
+						       cfg->wowl.nd_data_completed,
+						       BRCMF_ND_INFO_TIMEOUT);
+			if (!time_left)
 				bphy_err(drvr, "No result for wowl net detect\n");
 			else
 				wakeup_data.net_detect = cfg->wowl.nd_info;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/6] wifi: brcmfmac: use 'time_left' variable with wait_event_timeout()
  2024-06-03  9:15 ` [PATCH 2/6] wifi: brcmfmac: use 'time_left' variable with wait_event_timeout() Wolfram Sang
@ 2024-06-03  9:42   ` Arend van Spriel
  2024-06-03 13:15     ` Wolfram Sang
  2024-06-12 12:01   ` Kalle Valo
  1 sibling, 1 reply; 5+ messages in thread
From: Arend van Spriel @ 2024-06-03  9:42 UTC (permalink / raw)
  To: Wolfram Sang, linux-kernel
  Cc: Kalle Valo, linux-wireless, brcm80211, brcm80211-dev-list.pdl

[-- Attachment #1: Type: text/plain, Size: 934 bytes --]

On 6/3/2024 11:15 AM, Wolfram Sang wrote:
> There is a confusing pattern in the kernel to use a variable named 'timeout' to
> store the result of wait_event_timeout() causing patterns like:
> 
> 	timeout = wait_event_timeout(...)
> 	if (!timeout) return -ETIMEDOUT;
> 
> with all kinds of permutations. Use 'time_left' as a variable to make the code
> self explaining.

I feel this type of changes fall into the category of bike-shedding. 
People should know how wait_event_timeout() works and then a variable 
name does not really matter.

> Fix to the proper variable type 'long' while here.

But it may have useful side-effects to go over the code with fresh look. 
Thanks.

Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
>   .../wireless/broadcom/brcm80211/brcmfmac/cfg80211.c    | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4219 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/6] wifi: brcmfmac: use 'time_left' variable with wait_event_timeout()
  2024-06-03  9:42   ` Arend van Spriel
@ 2024-06-03 13:15     ` Wolfram Sang
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2024-06-03 13:15 UTC (permalink / raw)
  To: Arend van Spriel
  Cc: linux-kernel, Kalle Valo, linux-wireless, brcm80211,
	brcm80211-dev-list.pdl


> I feel this type of changes fall into the category of bike-shedding. People

I have two motivations for this change: One may be bike-shedding, yet
"if (!timeout) return -ETIMEDOUT" looks stupid to me.

> should know how wait_event_timeout() works and then a variable name does not
> really matter.

And for a new developer, I am quite sure the change will help to
understand how wait_event-family() works. Especially given that
wait_event_interruptible() returns 0 if condition is true and
wait_event_interruptible_timeout() returns 0 if condition is false.

> > Fix to the proper variable type 'long' while here.
> 
> But it may have useful side-effects to go over the code with fresh look.

:)

> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>

Thank you!


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/6] wifi: brcmfmac: use 'time_left' variable with wait_event_timeout()
  2024-06-03  9:15 ` [PATCH 2/6] wifi: brcmfmac: use 'time_left' variable with wait_event_timeout() Wolfram Sang
  2024-06-03  9:42   ` Arend van Spriel
@ 2024-06-12 12:01   ` Kalle Valo
  1 sibling, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2024-06-12 12:01 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel, Wolfram Sang, Arend van Spriel, linux-wireless,
	brcm80211, brcm80211-dev-list.pdl

Wolfram Sang <wsa+renesas@sang-engineering.com> wrote:

> There is a confusing pattern in the kernel to use a variable named 'timeout' to
> store the result of wait_event_timeout() causing patterns like:
> 
> 	timeout = wait_event_timeout(...)
> 	if (!timeout) return -ETIMEDOUT;
> 
> with all kinds of permutations. Use 'time_left' as a variable to make the code
> self explaining.
> 
> Fix to the proper variable type 'long' while here.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>

4 patches applied to wireless-next.git, thanks.

158d5a1b3caa wifi: brcmfmac: use 'time_left' variable with wait_event_timeout()
0c0668813cc0 wifi: mwl8k: use 'time_left' variable with wait_for_completion_timeout()
a37f6947ff07 wifi: p54: use 'time_left' variable with wait_for_completion_interruptible_timeout()
a2ead3445a63 wifi: zd1211rw: use 'time_left' variable with wait_for_completion_timeout()

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20240603091541.8367-3-wsa+renesas@sang-engineering.com/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-06-12 12:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-03  9:15 [PATCH 0/6] net: use 'time_left' instead of 'timeout' with wait_*() functions Wolfram Sang
2024-06-03  9:15 ` [PATCH 2/6] wifi: brcmfmac: use 'time_left' variable with wait_event_timeout() Wolfram Sang
2024-06-03  9:42   ` Arend van Spriel
2024-06-03 13:15     ` Wolfram Sang
2024-06-12 12:01   ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox