From nobody Mon Jun 22 20:22:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BCFBC433F5 for ; Thu, 17 Mar 2022 04:57:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbiCQE7K (ORCPT ); Thu, 17 Mar 2022 00:59:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbiCQE7F (ORCPT ); Thu, 17 Mar 2022 00:59:05 -0400 Received: from smtpbgsg1.qq.com (smtpbgsg1.qq.com [54.254.200.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97AA1DE924 for ; Wed, 16 Mar 2022 21:41:39 -0700 (PDT) X-QQ-mid: bizesmtp85t1647491636t0mm7bcn Received: from localhost.localdomain ( [58.240.82.166]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 17 Mar 2022 12:33:47 +0800 (CST) X-QQ-SSF: 01400000002000D0H000B00A0000000 X-QQ-FEAT: RMVj0UrY8cC0YGAUx/2nKiGC/VzxwmGLjHnmxBG/tXl+3Rzg4sxVsUFyBB4UN w6bSm+qsBc5e1KXquUKV2h3yZjONLMwC9YrHc+iqDCVm7RRHYGEjADV9TtK+bk2L33oEbHq 2bAs1gTjrPbMFVwMEItex/8GLqMKbDKW6CTirY/vCs8KosZCOK4Jf7BHZ9Wo5wcXcCWnElS t8ZAwE7Uqhi9yAvfwYXA/tcFqlJCF1/X3xZzNHihT3F/PkjtFZNNQp2Yq55tFmD299aJA0g k+yZWUhU8mQiE+co69Jbrbp0l+RIVv01KmfI3MWv3Y2xogG5jBP0DchPVgCLiHNsHXVELn9 bq7BzTjwh3tLajF/afaasR8CmY7zA== X-QQ-GoodBg: 2 From: Meng Tang To: klassert@kernel.org, davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Meng Tang Subject: [PATCH] net: 3com: 3c59x: Change the conditional processing for vortex_ioctl Date: Thu, 17 Mar 2022 12:33:44 +0800 Message-Id: <20220317043344.15317-1-tangmeng@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign4 X-QQ-Bgrelay: 1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In the vortex_ioctl, there are two places where there can be better and easier to understand: First, it should be better to reverse the check on 'VORTEX_PCI(vp)' and returned early in order to be easier to understand. Second, no need to make two 'if(state !=3D 0)' judgments, we can simplify the execution process. Signed-off-by: Meng Tang --- drivers/net/ethernet/3com/3c59x.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/= 3c59x.c index ccf07667aa5e..c22de3c8cd12 100644 --- a/drivers/net/ethernet/3com/3c59x.c +++ b/drivers/net/ethernet/3com/3c59x.c @@ -3032,16 +3032,19 @@ static int vortex_ioctl(struct net_device *dev, str= uct ifreq *rq, int cmd) struct vortex_private *vp =3D netdev_priv(dev); pci_power_t state =3D 0; =20 - if(VORTEX_PCI(vp)) - state =3D VORTEX_PCI(vp)->current_state; + if (!VORTEX_PCI(vp)) + return -EOPNOTSUPP; =20 - /* The kernel core really should have pci_get_power_state() */ + state =3D VORTEX_PCI(vp)->current_state; =20 - if(state !=3D 0) + /* The kernel core really should have pci_get_power_state() */ + if (!state) { + err =3D generic_mii_ioctl(&vp->mii, if_mii(rq), cmd, NULL); + } else { pci_set_power_state(VORTEX_PCI(vp), PCI_D0); - err =3D generic_mii_ioctl(&vp->mii, if_mii(rq), cmd, NULL); - if(state !=3D 0) + err =3D generic_mii_ioctl(&vp->mii, if_mii(rq), cmd, NULL); pci_set_power_state(VORTEX_PCI(vp), state); + } =20 return err; } --=20 2.20.1