Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp993537pxp; Wed, 16 Mar 2022 23:47:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQ/9MJt8YN1Y9nhLtEguwCVym9RuctVjPSwVd/wLidboV5mVhCkg0nVS2K19x0oRjB35mg X-Received: by 2002:a17:90b:3504:b0:1c6:8569:c28d with SMTP id ls4-20020a17090b350400b001c68569c28dmr1333293pjb.92.1647499643336; Wed, 16 Mar 2022 23:47:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647499643; cv=none; d=google.com; s=arc-20160816; b=FySIK5eTMkhyy6SqcnPv6Y9fRBxkjFbGgnkY9QfhpUSBXZG+7XDtbIHJIG0tXgyHkp t6r/FVzYy6/1cPmKCPqscTq4YEg7uCCH+IorSi0x3VTKGStkAP6L0kfVJQlkPMl4XpBG guT/NNSfSvG6RhaHr90Svrz0Un8HTm9++EdtmHktYQdbBPHxdnIo05HdqH3eNhpdrCT+ H3AbtE13oGDdq3zkzjqimfAkRR3ISfwo0LtuhqyHOdDr7y3txEjtKf1AE/TCXFsVgxpQ Wz9SzNrCZZOlZYgUaQRtvSPUFgBe8FYxhbyySyrcUIizs8CTrgVTu5dv+Qh0zz4v9mfu 1yjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=6oaIhiCJ8Z6ICdEzCrxoTsqpb1i5+HEDet4vbu+zPnM=; b=NWZ8ucYCnpSYf7WSYGXabtJe9bDLRSe9KFGQmmsWf2HElcDNYq7ddliiAw1lZ2TwCl UW9lqXBnOeRpGWzlQEJDSIMpyqr1EBXp4Fk8Wnuo86MVGWG0Eop9xCrOEEBDnOLo5U/A Jh+RXxrA1ZRqYv3yuu5HJP5Iq0m4uZeu9Lpjpe0lDuIpsi4G1qNddrxE2yxLJ5eXCKDv AU3xoV4lFzi6yej8ot3drmHxbf3j87bSppp/IupRxMEyf614SP6QXXcg+ufEy8uS2m8P uHSOVZWYEym7VjQ0Q1in2usD6dhwgrD19w2WLMNeJd6tenWF4pCr0Zx9Fel/NX2TYxXM rF1g== 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:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h8-20020a656388000000b003816043eee3si1159098pgv.216.2022.03.16.23.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 23:47:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2C39921C06A; Wed, 16 Mar 2022 22:32:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229581AbiCQE7H (ORCPT + 99 others); Thu, 17 Mar 2022 00:59:07 -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: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign4 X-QQ-Bgrelay: 1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 != 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, struct ifreq *rq, int cmd) struct vortex_private *vp = netdev_priv(dev); pci_power_t state = 0; - if(VORTEX_PCI(vp)) - state = VORTEX_PCI(vp)->current_state; + if (!VORTEX_PCI(vp)) + return -EOPNOTSUPP; - /* The kernel core really should have pci_get_power_state() */ + state = VORTEX_PCI(vp)->current_state; - if(state != 0) + /* The kernel core really should have pci_get_power_state() */ + if (!state) { + err = generic_mii_ioctl(&vp->mii, if_mii(rq), cmd, NULL); + } else { pci_set_power_state(VORTEX_PCI(vp), PCI_D0); - err = generic_mii_ioctl(&vp->mii, if_mii(rq), cmd, NULL); - if(state != 0) + err = generic_mii_ioctl(&vp->mii, if_mii(rq), cmd, NULL); pci_set_power_state(VORTEX_PCI(vp), state); + } return err; } -- 2.20.1