* [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 1/6] wifi: ath11k: 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 1/6] wifi: ath11k: 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 22:57 ` Jeff Johnson 2024-06-11 18:41 ` 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, Kalle Valo, Jeff Johnson, linux-wireless, ath11k 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> --- drivers/net/wireless/ath/ath11k/qmi.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c index d4a243b64f6c..2fe0ef660456 100644 --- a/drivers/net/wireless/ath/ath11k/qmi.c +++ b/drivers/net/wireless/ath/ath11k/qmi.c @@ -2859,7 +2859,7 @@ int ath11k_qmi_firmware_start(struct ath11k_base *ab, int ath11k_qmi_fwreset_from_cold_boot(struct ath11k_base *ab) { - int timeout; + long time_left; if (!ath11k_core_coldboot_cal_support(ab) || ab->hw_params.cbcal_restart_fw == 0) @@ -2867,11 +2867,11 @@ int ath11k_qmi_fwreset_from_cold_boot(struct ath11k_base *ab) ath11k_dbg(ab, ATH11K_DBG_QMI, "wait for cold boot done\n"); - timeout = wait_event_timeout(ab->qmi.cold_boot_waitq, - (ab->qmi.cal_done == 1), - ATH11K_COLD_BOOT_FW_RESET_DELAY); + time_left = wait_event_timeout(ab->qmi.cold_boot_waitq, + (ab->qmi.cal_done == 1), + ATH11K_COLD_BOOT_FW_RESET_DELAY); - if (timeout <= 0) { + if (time_left <= 0) { ath11k_warn(ab, "Coldboot Calibration timed out\n"); return -ETIMEDOUT; } @@ -2886,7 +2886,7 @@ EXPORT_SYMBOL(ath11k_qmi_fwreset_from_cold_boot); static int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab) { - int timeout; + long time_left; int ret; ret = ath11k_qmi_wlanfw_mode_send(ab, ATH11K_FIRMWARE_MODE_COLD_BOOT); @@ -2897,10 +2897,10 @@ static int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab) ath11k_dbg(ab, ATH11K_DBG_QMI, "Coldboot calibration wait started\n"); - timeout = wait_event_timeout(ab->qmi.cold_boot_waitq, - (ab->qmi.cal_done == 1), - ATH11K_COLD_BOOT_FW_RESET_DELAY); - if (timeout <= 0) { + time_left = wait_event_timeout(ab->qmi.cold_boot_waitq, + (ab->qmi.cal_done == 1), + ATH11K_COLD_BOOT_FW_RESET_DELAY); + if (time_left <= 0) { ath11k_warn(ab, "coldboot calibration timed out\n"); return 0; } -- 2.43.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/6] wifi: ath11k: use 'time_left' variable with wait_event_timeout() 2024-06-03 9:15 ` [PATCH 1/6] wifi: ath11k: use 'time_left' variable with wait_event_timeout() Wolfram Sang @ 2024-06-03 22:57 ` Jeff Johnson 2024-06-04 17:11 ` Kalle Valo 2024-06-11 18:41 ` Kalle Valo 1 sibling, 1 reply; 5+ messages in thread From: Jeff Johnson @ 2024-06-03 22:57 UTC (permalink / raw) To: Wolfram Sang, linux-kernel Cc: Kalle Valo, Jeff Johnson, linux-wireless, ath11k On 6/3/2024 2: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. > > Fix to the proper variable type 'long' while here. > > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> > --- > drivers/net/wireless/ath/ath11k/qmi.c | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) > > diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c > index d4a243b64f6c..2fe0ef660456 100644 > --- a/drivers/net/wireless/ath/ath11k/qmi.c > +++ b/drivers/net/wireless/ath/ath11k/qmi.c > @@ -2859,7 +2859,7 @@ int ath11k_qmi_firmware_start(struct ath11k_base *ab, > > int ath11k_qmi_fwreset_from_cold_boot(struct ath11k_base *ab) > { > - int timeout; > + long time_left; > > if (!ath11k_core_coldboot_cal_support(ab) || > ab->hw_params.cbcal_restart_fw == 0) > @@ -2867,11 +2867,11 @@ int ath11k_qmi_fwreset_from_cold_boot(struct ath11k_base *ab) > > ath11k_dbg(ab, ATH11K_DBG_QMI, "wait for cold boot done\n"); > > - timeout = wait_event_timeout(ab->qmi.cold_boot_waitq, > - (ab->qmi.cal_done == 1), > - ATH11K_COLD_BOOT_FW_RESET_DELAY); > + time_left = wait_event_timeout(ab->qmi.cold_boot_waitq, > + (ab->qmi.cal_done == 1), > + ATH11K_COLD_BOOT_FW_RESET_DELAY); > > - if (timeout <= 0) { > + if (time_left <= 0) { > ath11k_warn(ab, "Coldboot Calibration timed out\n"); > return -ETIMEDOUT; > } > @@ -2886,7 +2886,7 @@ EXPORT_SYMBOL(ath11k_qmi_fwreset_from_cold_boot); > > static int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab) > { > - int timeout; > + long time_left; > int ret; > > ret = ath11k_qmi_wlanfw_mode_send(ab, ATH11K_FIRMWARE_MODE_COLD_BOOT); > @@ -2897,10 +2897,10 @@ static int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab) > > ath11k_dbg(ab, ATH11K_DBG_QMI, "Coldboot calibration wait started\n"); > > - timeout = wait_event_timeout(ab->qmi.cold_boot_waitq, > - (ab->qmi.cal_done == 1), > - ATH11K_COLD_BOOT_FW_RESET_DELAY); > - if (timeout <= 0) { > + time_left = wait_event_timeout(ab->qmi.cold_boot_waitq, > + (ab->qmi.cal_done == 1), > + ATH11K_COLD_BOOT_FW_RESET_DELAY); > + if (time_left <= 0) { > ath11k_warn(ab, "coldboot calibration timed out\n"); > return 0; > } This looks ok to me, but note that changes to ath11k go through the ath tree, so, unless Kalle has a different opinion, this should be submitted separately from changes that go through the wireless tree. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/6] wifi: ath11k: use 'time_left' variable with wait_event_timeout() 2024-06-03 22:57 ` Jeff Johnson @ 2024-06-04 17:11 ` Kalle Valo 0 siblings, 0 replies; 5+ messages in thread From: Kalle Valo @ 2024-06-04 17:11 UTC (permalink / raw) To: Jeff Johnson Cc: Wolfram Sang, linux-kernel, Jeff Johnson, linux-wireless, ath11k Jeff Johnson <quic_jjohnson@quicinc.com> writes: > On 6/3/2024 2: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. >> >> Fix to the proper variable type 'long' while here. >> >> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> >> --- >> drivers/net/wireless/ath/ath11k/qmi.c | 20 ++++++++++---------- >> 1 file changed, 10 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c >> index d4a243b64f6c..2fe0ef660456 100644 >> --- a/drivers/net/wireless/ath/ath11k/qmi.c >> +++ b/drivers/net/wireless/ath/ath11k/qmi.c >> @@ -2859,7 +2859,7 @@ int ath11k_qmi_firmware_start(struct ath11k_base *ab, >> >> int ath11k_qmi_fwreset_from_cold_boot(struct ath11k_base *ab) >> { >> - int timeout; >> + long time_left; >> >> if (!ath11k_core_coldboot_cal_support(ab) || >> ab->hw_params.cbcal_restart_fw == 0) >> @@ -2867,11 +2867,11 @@ int ath11k_qmi_fwreset_from_cold_boot(struct ath11k_base *ab) >> >> ath11k_dbg(ab, ATH11K_DBG_QMI, "wait for cold boot done\n"); >> >> - timeout = wait_event_timeout(ab->qmi.cold_boot_waitq, >> - (ab->qmi.cal_done == 1), >> - ATH11K_COLD_BOOT_FW_RESET_DELAY); >> + time_left = wait_event_timeout(ab->qmi.cold_boot_waitq, >> + (ab->qmi.cal_done == 1), >> + ATH11K_COLD_BOOT_FW_RESET_DELAY); >> >> - if (timeout <= 0) { >> + if (time_left <= 0) { >> ath11k_warn(ab, "Coldboot Calibration timed out\n"); >> return -ETIMEDOUT; >> } >> @@ -2886,7 +2886,7 @@ EXPORT_SYMBOL(ath11k_qmi_fwreset_from_cold_boot); >> >> static int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab) >> { >> - int timeout; >> + long time_left; >> int ret; >> >> ret = ath11k_qmi_wlanfw_mode_send(ab, ATH11K_FIRMWARE_MODE_COLD_BOOT); >> @@ -2897,10 +2897,10 @@ static int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab) >> >> ath11k_dbg(ab, ATH11K_DBG_QMI, "Coldboot calibration wait started\n"); >> >> - timeout = wait_event_timeout(ab->qmi.cold_boot_waitq, >> - (ab->qmi.cal_done == 1), >> - ATH11K_COLD_BOOT_FW_RESET_DELAY); >> - if (timeout <= 0) { >> + time_left = wait_event_timeout(ab->qmi.cold_boot_waitq, >> + (ab->qmi.cal_done == 1), >> + ATH11K_COLD_BOOT_FW_RESET_DELAY); >> + if (time_left <= 0) { >> ath11k_warn(ab, "coldboot calibration timed out\n"); >> return 0; >> } > > This looks ok to me, but note that changes to ath11k go through the ath tree, > so, unless Kalle has a different opinion, this should be submitted separately > from changes that go through the wireless tree. As there are no dependencies to other patches I can take this directly to ath.git, so no need to resend because of this. -- https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/6] wifi: ath11k: use 'time_left' variable with wait_event_timeout() 2024-06-03 9:15 ` [PATCH 1/6] wifi: ath11k: use 'time_left' variable with wait_event_timeout() Wolfram Sang 2024-06-03 22:57 ` Jeff Johnson @ 2024-06-11 18:41 ` Kalle Valo 1 sibling, 0 replies; 5+ messages in thread From: Kalle Valo @ 2024-06-11 18:41 UTC (permalink / raw) To: Wolfram Sang Cc: linux-kernel, Wolfram Sang, Jeff Johnson, linux-wireless, ath11k 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> > Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Patch applied to ath-next branch of ath.git, thanks. 65a8368bf34e wifi: ath11k: use 'time_left' variable with wait_event_timeout() -- https://patchwork.kernel.org/project/linux-wireless/patch/20240603091541.8367-2-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-11 18:41 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 1/6] wifi: ath11k: use 'time_left' variable with wait_event_timeout() Wolfram Sang 2024-06-03 22:57 ` Jeff Johnson 2024-06-04 17:11 ` Kalle Valo 2024-06-11 18:41 ` Kalle Valo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox