* [PATCH] wifi: wfx: Remove some dead code
@ 2023-02-15 12:34 Christophe JAILLET
2023-02-15 13:23 ` Jérôme Pouiller
2023-02-22 12:29 ` Kalle Valo
0 siblings, 2 replies; 5+ messages in thread
From: Christophe JAILLET @ 2023-02-15 12:34 UTC (permalink / raw)
To: Jérôme Pouiller, Kalle Valo, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-wireless,
netdev
wait_for_completion_timeout() can not return a <0 value.
So simplify the logic and remove dead code.
-ERESTARTSYS can not be returned by do_wait_for_common() for tasks with
TASK_UNINTERRUPTIBLE, which is the case for wait_for_completion_timeout()
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/net/wireless/silabs/wfx/main.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/net/wireless/silabs/wfx/main.c b/drivers/net/wireless/silabs/wfx/main.c
index 6b9864e478ac..0b50f7058bbb 100644
--- a/drivers/net/wireless/silabs/wfx/main.c
+++ b/drivers/net/wireless/silabs/wfx/main.c
@@ -358,13 +358,9 @@ int wfx_probe(struct wfx_dev *wdev)
wfx_bh_poll_irq(wdev);
err = wait_for_completion_timeout(&wdev->firmware_ready, 1 * HZ);
- if (err <= 0) {
- if (err == 0) {
- dev_err(wdev->dev, "timeout while waiting for startup indication\n");
- err = -ETIMEDOUT;
- } else if (err == -ERESTARTSYS) {
- dev_info(wdev->dev, "probe interrupted by user\n");
- }
+ if (err == 0) {
+ dev_err(wdev->dev, "timeout while waiting for startup indication\n");
+ err = -ETIMEDOUT;
goto bh_unregister;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] wifi: wfx: Remove some dead code
2023-02-15 12:34 [PATCH] wifi: wfx: Remove some dead code Christophe JAILLET
@ 2023-02-15 13:23 ` Jérôme Pouiller
2023-02-17 19:51 ` Christophe JAILLET
2023-02-22 12:29 ` Kalle Valo
1 sibling, 1 reply; 5+ messages in thread
From: Jérôme Pouiller @ 2023-02-15 13:23 UTC (permalink / raw)
To: Kalle Valo, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, linux-kernel
Cc: kernel-janitors, Christophe JAILLET, linux-wireless, netdev
Hello Christophe,
On Wednesday 15 February 2023 13:34:37 CET Christophe JAILLET wrote:
>
> wait_for_completion_timeout() can not return a <0 value.
> So simplify the logic and remove dead code.
>
> -ERESTARTSYS can not be returned by do_wait_for_common() for tasks with
> TASK_UNINTERRUPTIBLE, which is the case for wait_for_completion_timeout()
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/net/wireless/silabs/wfx/main.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/wireless/silabs/wfx/main.c b/drivers/net/wireless/silabs/wfx/main.c
> index 6b9864e478ac..0b50f7058bbb 100644
> --- a/drivers/net/wireless/silabs/wfx/main.c
> +++ b/drivers/net/wireless/silabs/wfx/main.c
> @@ -358,13 +358,9 @@ int wfx_probe(struct wfx_dev *wdev)
>
> wfx_bh_poll_irq(wdev);
> err = wait_for_completion_timeout(&wdev->firmware_ready, 1 * HZ);
> - if (err <= 0) {
> - if (err == 0) {
> - dev_err(wdev->dev, "timeout while waiting for startup indication\n");
> - err = -ETIMEDOUT;
> - } else if (err == -ERESTARTSYS) {
> - dev_info(wdev->dev, "probe interrupted by user\n");
This code is ran during modprobe/insmod. We would like to allow the user
to interrupt (Ctrl+C) the probing if something is going wrong with the
device.
So, the real issue is wait_for_completion_interruptible_timeout() should
be used instead of wait_for_completion_timeout().
(By reading this code again, it also seems the test "if (err <= 0)" is
useless)
--
Jérôme Pouiller
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] wifi: wfx: Remove some dead code
2023-02-15 13:23 ` Jérôme Pouiller
@ 2023-02-17 19:51 ` Christophe JAILLET
2023-02-21 17:02 ` Jérôme Pouiller
0 siblings, 1 reply; 5+ messages in thread
From: Christophe JAILLET @ 2023-02-17 19:51 UTC (permalink / raw)
To: Jérôme Pouiller, Kalle Valo, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel
Cc: kernel-janitors, linux-wireless, netdev
Le 15/02/2023 à 14:23, Jérôme Pouiller a écrit :
> Hello Christophe,
>
> On Wednesday 15 February 2023 13:34:37 CET Christophe JAILLET wrote:
>>
>> wait_for_completion_timeout() can not return a <0 value.
>> So simplify the logic and remove dead code.
>>
>> -ERESTARTSYS can not be returned by do_wait_for_common() for tasks with
>> TASK_UNINTERRUPTIBLE, which is the case for wait_for_completion_timeout()
>>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>> drivers/net/wireless/silabs/wfx/main.c | 10 +++-------
>> 1 file changed, 3 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/net/wireless/silabs/wfx/main.c b/drivers/net/wireless/silabs/wfx/main.c
>> index 6b9864e478ac..0b50f7058bbb 100644
>> --- a/drivers/net/wireless/silabs/wfx/main.c
>> +++ b/drivers/net/wireless/silabs/wfx/main.c
>> @@ -358,13 +358,9 @@ int wfx_probe(struct wfx_dev *wdev)
>>
>> wfx_bh_poll_irq(wdev);
>> err = wait_for_completion_timeout(&wdev->firmware_ready, 1 * HZ);
>> - if (err <= 0) {
>> - if (err == 0) {
>> - dev_err(wdev->dev, "timeout while waiting for startup indication\n");
>> - err = -ETIMEDOUT;
>> - } else if (err == -ERESTARTSYS) {
>> - dev_info(wdev->dev, "probe interrupted by user\n");
>
> This code is ran during modprobe/insmod. We would like to allow the user
> to interrupt (Ctrl+C) the probing if something is going wrong with the
> device.
>
> So, the real issue is wait_for_completion_interruptible_timeout() should
> be used instead of wait_for_completion_timeout().
Hmmm, not that clear.
See commit 01088cd143a9.
Let me know if you prefer this patch as-is or if 01088cd143a9 should be
reverted.
CJ
>
> (By reading this code again, it also seems the test "if (err <= 0)" is
> useless)
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] wifi: wfx: Remove some dead code
2023-02-17 19:51 ` Christophe JAILLET
@ 2023-02-21 17:02 ` Jérôme Pouiller
0 siblings, 0 replies; 5+ messages in thread
From: Jérôme Pouiller @ 2023-02-21 17:02 UTC (permalink / raw)
To: Kalle Valo, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, linux-kernel, Christophe JAILLET
Cc: kernel-janitors, linux-wireless, netdev
On Friday 17 February 2023 20:51:24 CET Christophe JAILLET wrote:
> Le 15/02/2023 à 14:23, Jérôme Pouiller a écrit :
> > On Wednesday 15 February 2023 13:34:37 CET Christophe JAILLET wrote:
> >>
> >> wait_for_completion_timeout() can not return a <0 value.
> >> So simplify the logic and remove dead code.
> >>
> >> -ERESTARTSYS can not be returned by do_wait_for_common() for tasks with
> >> TASK_UNINTERRUPTIBLE, which is the case for wait_for_completion_timeout()
> >>
> >> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> >> ---
> >> drivers/net/wireless/silabs/wfx/main.c | 10 +++-------
> >> 1 file changed, 3 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/drivers/net/wireless/silabs/wfx/main.c b/drivers/net/wireless/silabs/wfx/main.c
> >> index 6b9864e478ac..0b50f7058bbb 100644
> >> --- a/drivers/net/wireless/silabs/wfx/main.c
> >> +++ b/drivers/net/wireless/silabs/wfx/main.c
> >> @@ -358,13 +358,9 @@ int wfx_probe(struct wfx_dev *wdev)
> >>
> >> wfx_bh_poll_irq(wdev);
> >> err = wait_for_completion_timeout(&wdev->firmware_ready, 1 * HZ);
> >> - if (err <= 0) {
> >> - if (err == 0) {
> >> - dev_err(wdev->dev, "timeout while waiting for startup indication\n");
> >> - err = -ETIMEDOUT;
> >> - } else if (err == -ERESTARTSYS) {
> >> - dev_info(wdev->dev, "probe interrupted by user\n");
> >
> > This code is ran during modprobe/insmod. We would like to allow the user
> > to interrupt (Ctrl+C) the probing if something is going wrong with the
> > device.
> >
> > So, the real issue is wait_for_completion_interruptible_timeout() should
> > be used instead of wait_for_completion_timeout().
>
> Hmmm, not that clear.
>
> See commit 01088cd143a9.
>
> Let me know if you prefer this patch as-is or if 01088cd143a9 should be
> reverted.
Good catch. So this patch is correct.
Reviewed-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
--
Jérôme Pouiller
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] wifi: wfx: Remove some dead code
2023-02-15 12:34 [PATCH] wifi: wfx: Remove some dead code Christophe JAILLET
2023-02-15 13:23 ` Jérôme Pouiller
@ 2023-02-22 12:29 ` Kalle Valo
1 sibling, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2023-02-22 12:29 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Jérôme Pouiller, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, linux-kernel, kernel-janitors,
Christophe JAILLET, linux-wireless, netdev
Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:
> wait_for_completion_timeout() can not return a <0 value.
> So simplify the logic and remove dead code.
>
> -ERESTARTSYS can not be returned by do_wait_for_common() for tasks with
> TASK_UNINTERRUPTIBLE, which is the case for wait_for_completion_timeout()
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> Reviewed-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Patch applied to wireless-next.git, thanks.
015bf4df8ea6 wifi: wfx: Remove some dead code
--
https://patchwork.kernel.org/project/linux-wireless/patch/809c4a645c8d1306c0d256345515865c40ec731c.1676464422.git.christophe.jaillet@wanadoo.fr/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-02-22 12:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-15 12:34 [PATCH] wifi: wfx: Remove some dead code Christophe JAILLET
2023-02-15 13:23 ` Jérôme Pouiller
2023-02-17 19:51 ` Christophe JAILLET
2023-02-21 17:02 ` Jérôme Pouiller
2023-02-22 12:29 ` Kalle Valo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).