Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1043780pxp; Thu, 17 Mar 2022 01:18:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwbdlnCq67clHckhnfKKShkoTGne3Wg1QNS1+4jD+8bQjeNAqsv1fJpd06yFsjoVPKuLAb X-Received: by 2002:a17:906:d555:b0:6da:ac8c:f66b with SMTP id cr21-20020a170906d55500b006daac8cf66bmr3165789ejc.107.1647505109372; Thu, 17 Mar 2022 01:18:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647505109; cv=none; d=google.com; s=arc-20160816; b=S9lAC0J2jYrNboNWMOnx7s1h1Wv/4ieQR8muKPFgInNsS5X5FBp/TMhO+qSn6gmZDn wCylIGgry68o2QEpTTTXogyXIuMB7cicygYjU2Tuqtlhbq/f8kPdGr9KnRaa/CUcftTW cREcbV4WvVyw1cxVOiiGNsjF5L2FI0PteVrTdbVZtbQ/t54+Lzrjub0LqEl0ApBOXdbP fiK+eCRUUg/Sh61V3hih4uV1sV0IJ6XbIZBXKHTz28CkwyfSES4ytjbEj3+CQHWSA6XP abrw1c66kdelZ6R/c+9A/UcuVK83zRtMz90jQtpEUCmRldih4o5fk1KELv6k/L4iCyLu FCTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:content-disposition :content-transfer-encoding:mime-version:in-reply-to:references:cc :user-agent:date:subject:to:from; bh=F4PZc/FY/ns3nZmmRgaFEF84zXUJcSmP1Fduzpvo3p0=; b=owvM113Zy2Oz5u0qrccwjGvDu5rRgU0By+On/mFuJ+GiPW9c3Yk5vhE47qmWi/RXKo IKqkGHf+qYprHy7Ah5ioUVONROkZi1CgCBHqZ9ayxd2UJva9nbl/7vbVH4i4vU3PD3Un Ym44HCs5RUCINgY4k6SAUJb9Ok1rxvSANKofoBoO6to1fZjElsaAJAGb3Vc5AHJ9D1bx Gjg9QwCVN00CWUoWEB95e4BkfPqL+6nJyFsuz7N7l2pQ3aCeVfer8qY2/+lM2C39c5Wr iufbpWdsTPlk3CNffn9+DpkHo6Gr5vShTZOH28ljzMl1djTlWh6HfwRRGzgMeuE2aHeS CTLQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h14-20020a50c38e000000b00418c2b5bdd1si865828edf.179.2022.03.17.01.18.02; Thu, 17 Mar 2022 01:18:29 -0700 (PDT) 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 S230099AbiCQIB6 (ORCPT + 99 others); Thu, 17 Mar 2022 04:01:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbiCQIB5 (ORCPT ); Thu, 17 Mar 2022 04:01:57 -0400 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6FDD7EBB8D for ; Thu, 17 Mar 2022 01:00:41 -0700 (PDT) Received: from [192.168.1.3] (ns.gsystem.sk [62.176.172.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by hosting.gsystem.sk (Postfix) with ESMTPSA id 580F27A025B; Thu, 17 Mar 2022 09:00:39 +0100 (CET) From: Ondrej Zary To: Meng Tang Subject: Re: [PATCH] net: 3com: 3c59x: Change the conditional processing for vortex_ioctl Date: Thu, 17 Mar 2022 09:00:36 +0100 User-Agent: KMail/1.9.10 Cc: klassert@kernel.org, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220317043344.15317-1-tangmeng@uniontech.com> In-Reply-To: <20220317043344.15317-1-tangmeng@uniontech.com> X-KMail-QuotePrefix: > MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <202203170900.36931.linux@zary.sk> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Thursday 17 March 2022, Meng Tang wrote: > 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. Congratulations, you've just added 3 lines of code and broke a driver. Your "simplified" version does not work with EISA devices. Why? Please stop "improving" drivers if you can't test them. > 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; > } -- Ondrej Zary