Message ID | 809c4a645c8d1306c0d256345515865c40ec731c.1676464422.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp165244wrn; Wed, 15 Feb 2023 04:37:00 -0800 (PST) X-Google-Smtp-Source: AK7set/NF0OMVWI8G8XIePSY2X8T/Il5HPITPR9OLPEWIqLTEgXkbMJO8pgzGIB7xFbCBz3g1hN4 X-Received: by 2002:a17:902:eccc:b0:199:2a36:6c3f with SMTP id a12-20020a170902eccc00b001992a366c3fmr2587673plh.6.1676464620528; Wed, 15 Feb 2023 04:37:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676464620; cv=none; d=google.com; s=arc-20160816; b=UlFON2VbDYQxTwnsKGVxjRnwtlKZEVFBitTlEXGVhAHOc46Q7xfAZMqxnf1Slm/iui mBiSy+kXOgiExdmImapx1ueDy1eTnDaYSRvreRX1FvBdpao0MfSW/ea2b1Q/1K/9K+79 C4IN5ycIeVwLOTFasnedZxP/e6P8IvpZ5y/ZT4Ywtete3tniEfBuWcH4wFJHHlOZthVH VDXXp9128H70Lqf+4D5S6QouZ8jBHXh47guuG55gdVrqdihp2uHWLCV/0JVKKOCf/BOw rgg8RKZd9AxbIW5Xcsf6gmBf4Xp12YRSbcOuoV9RxjC6XJovIGkd2bHVPqtIEZqc08oX aGjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=vXlMaif3MrYGKKccgnuwhHS4RgBSzsKFdL8QuJGxTNo=; b=MSsswh5QOT2F/BuXCXp4zMSvKsUZuU2D6mgmsNfDO+2KjroOPzF+G1zwCRJoM7ekcr ZLl2QlUnVZlHrIzgWhFU76Ny17/4WMuHMlZrWRlhb06ybKm0CdK6Tcs2MF0OWS8Bf5IJ 9/jBdjtv1OjstS1b9Zvou7X3DUjwNsnqVKWMNGYgaG+3UwQm7V/eXSy8+I5+7gaoszvv cy/I+NH2En/TtqXB+HG50cdYXV0eWNlryTTijvt7jT27PjlCDn8yVcCI3BoDeqY5wZWK Xnty6iTNjjI4mH+TeoMnAKa7/qkfWG5D0UCIwABzOWQPwsK30oc6yK6HX2N0ttV+h8Sc Sz7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q9-20020a170902bd8900b0019aa6c46413si7114037pls.345.2023.02.15.04.36.48; Wed, 15 Feb 2023 04:37:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233767AbjBOMfH (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Wed, 15 Feb 2023 07:35:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234051AbjBOMe4 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 15 Feb 2023 07:34:56 -0500 Received: from smtp.smtpout.orange.fr (smtp-30.smtpout.orange.fr [80.12.242.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 783003865C for <linux-kernel@vger.kernel.org>; Wed, 15 Feb 2023 04:34:42 -0800 (PST) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id SGzfp3ZUhl3gSSGzfpDd5X; Wed, 15 Feb 2023 13:34:41 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 15 Feb 2023 13:34:41 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= <jerome.pouiller@silabs.com>, Kalle Valo <kvalo@kernel.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH] wifi: wfx: Remove some dead code Date: Wed, 15 Feb 2023 13:34:37 +0100 Message-Id: <809c4a645c8d1306c0d256345515865c40ec731c.1676464422.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757900565496974468?= X-GMAIL-MSGID: =?utf-8?q?1757900565496974468?= |
Series |
wifi: wfx: Remove some dead code
|
|
Commit Message
Christophe JAILLET
Feb. 15, 2023, 12:34 p.m. UTC
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(-)
Comments
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)
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) > >
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>
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
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; }