diff mbox series

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

Message ID 20240603091541.8367-6-wsa+renesas@sang-engineering.com
State New
Headers show
Series [1/6] wifi: ath11k: use 'time_left' variable with wait_event_timeout() | expand

Commit Message

Wolfram Sang June 3, 2024, 9:15 a.m. UTC
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 <wsa+renesas@sang-engineering.com>
---
 drivers/net/wireless/realtek/rtw89/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Kalle Valo June 4, 2024, 8:13 a.m. UTC | #1
Ping-Ke Shih <pkshih@realtek.com> writes:

> 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_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 <wsa+renesas@sang-engineering.com>
>
> Acked-by: Ping-Ke Shih <pkshih@realtek.com>

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.
Ping-Ke Shih June 4, 2024, 8:57 a.m. UTC | #2
Kalle Valo <kvalo@kernel.org> wrote:
> Ping-Ke Shih <pkshih@realtek.com> writes:
> 
> > 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_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 <wsa+renesas@sang-engineering.com>
> >
> > Acked-by: Ping-Ke Shih <pkshih@realtek.com>
> 
> 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
Ping-Ke Shih June 17, 2024, 2:07 a.m. UTC | #3
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_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 <wsa+renesas@sang-engineering.com>
> Acked-by: Ping-Ke Shih <pkshih@realtek.com>

1 patch(es) applied to rtw-next branch of rtw.git, thanks.

3d530eeaf8e7 wifi: rtw89: use 'time_left' variable with wait_for_completion_timeout()

---
https://github.com/pkshih/rtw.git
diff mbox series

Patch

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;
 	}