Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp8888rdb; Thu, 7 Sep 2023 11:51:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEehFcxNnbrp9OJokzTcVdBDcJDP5QVpiiZOsYJ0fFbJVCAa6aI6ufY24F7xi8WvBwwqy6B X-Received: by 2002:a05:6402:35d5:b0:523:3e5b:52da with SMTP id z21-20020a05640235d500b005233e5b52damr137277edc.2.1694112700505; Thu, 07 Sep 2023 11:51:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694112700; cv=none; d=google.com; s=arc-20160816; b=fnjvTWWXusmk89HcpDTVw30FO/R3DD/d/HxYCp2mVip6WjG0xcjPLWJ9vhLhrOEL0Q xDdvPymHFXitl8kbxVVc4zkyHWz3i1G0cGs1yyFEltI1eewxW7BnIdSkWNArenGzfyXZ M4Y9l8aO6puT8nsQpeqTJxRG1Z19aPwGtEtxdG5efVA87CxizSmbBoU7/NGZm+zHqESU XrvLcggPZRtAlBXCwlshrd0ROqEjRZNTEaDFxDSFM5xE0VLid3MLRbGQxmXCj/Nx6KvD E4P69VwQVDSb9d3vKSnm5shupnOCfQM8g8cWSamJfVwpHlBWfHm1jGPKupF2ghaDr50j BMzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=F7vSpfCfYCvODMAyXRt6Ug4ZFfLol/1tefnPrblJooA=; fh=j9SruR9Ac+oA73xRUJMGhTHAV4TZFZaj7zK2BJntXNI=; b=soQtJRDEMto+leQMGSrXaXszdRuJkorADth/Khdo6AB0m1pm4i0THK+S5htz5jRURA oetNPPktnKsB95oV1AGKMbqFq+qaPt908FbtNan46VW5QEsVGpBrONJCD3BC5c8cb9V1 MT7NWoKrXbY9qeeaesYp4f6CVAYHPTSuH6k78RTLHY4200vvsjph3hC9UpcF7+Y33di5 mY/VN+xnUwaNr1uOFKu+0DClRNPpGkFs176RrEbfRYjMRj2R/9bOtlCQEEI1hW+cQEtG b7UF2i5f/Vvp6udBaZxe892u4nkljzwt85Ows6nRUDl27f1dGU0zSAsJ+HCt7hwudF5V wqWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=fMOtER0K; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r4-20020aa7da04000000b0052907bbfbe6si117617eds.393.2023.09.07.11.50.59; Thu, 07 Sep 2023 11:51:40 -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; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=fMOtER0K; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245121AbjIGQXs (ORCPT + 99 others); Thu, 7 Sep 2023 12:23:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239375AbjIGQWH (ORCPT ); Thu, 7 Sep 2023 12:22:07 -0400 Received: from pandora.armlinux.org.uk (unknown [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D487493CB; Thu, 7 Sep 2023 09:19:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=F7vSpfCfYCvODMAyXRt6Ug4ZFfLol/1tefnPrblJooA=; b=fMOtER0Kc3s0dWOOXdWUtzuoWA dWl8L35t9P5Oddj5gWtY8xsnKWUvCkbc/D1Ac/S/bGTbqaQBUZeF225T2faMESNfQYx+alM5b26cp 2Zd6OJJ660Y9ofKMEWwcBhxl29S77LF5hhkur4SX1RKv25PGVCNnh92l4JzJ+xVRAnd680jY5Ojwj x8pg96Xg6igE69LQ0fWlmaiomAI+vapPlLtSf3cgAUY4xvbC62dX13Cdl4Nyrgvagtc7KUxUDIPTV vzWxJTxfivuKIOOvk8UfxrknCPUVQz8sZmTH29NDO7EyhS7oU8WYc9CGZoEZfAqfDq0tCIAlpFmM/ qMfs6kww==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:48762) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qeAWl-0001ci-0Q; Thu, 07 Sep 2023 09:38:15 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qeAWd-0005ft-Ce; Thu, 07 Sep 2023 09:38:07 +0100 Date: Thu, 7 Sep 2023 09:38:07 +0100 From: "Russell King (Oracle)" To: Bo Liu Cc: iyappan@os.amperecomputing.com, keyur@os.amperecomputing.com, quan@os.amperecomputing.com, andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: mdio: Use helper function IS_ERR_OR_NULL() Message-ID: References: <20230907071705.3907-1-liubo03@inspur.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230907071705.3907-1-liubo03@inspur.com> Sender: Russell King (Oracle) X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,RDNS_NONE, SPF_HELO_NONE,SPF_NONE 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 On Thu, Sep 07, 2023 at 03:17:05AM -0400, Bo Liu wrote: > Use IS_ERR_OR_NULL() to detect an error pointer or a null pointer > open-coding to simplify the code. > > Signed-off-by: Bo Liu Please do a more thorough review of the code before proposing changes to discover what the correct solution should be. > diff --git a/drivers/net/mdio/mdio-xgene.c b/drivers/net/mdio/mdio-xgene.c > index 1190a793555a..1518abfc3e22 100644 > --- a/drivers/net/mdio/mdio-xgene.c > +++ b/drivers/net/mdio/mdio-xgene.c > @@ -263,7 +263,7 @@ struct phy_device *xgene_enet_phy_register(struct mii_bus *bus, int phy_addr) > struct phy_device *phy_dev; > > phy_dev = get_phy_device(bus, phy_addr, false); > - if (!phy_dev || IS_ERR(phy_dev)) > + if (IS_ERR_OR_NULL(phy_dev)) Looking at get_phy_device(), the returns from this function are either: if (r) return ERR_PTR(r); which can't return NULL, or the return value from phy_device_create(). Looking at phy_device_create(), the returns from this function are: if (!dev) return ERR_PTR(-ENOMEM); if (ret) { ... dev = ERR_PTR(ret); ... return dev; so I don't see any of this being able to return NULL either. Therefore, the code that you are modifying should be: - if (!phy_dev || IS_ERR(phy_dev)) + if (IS_ERR(phy_dev)) and the commit description needs to be updated to state that get_phy_device() does not return NULL. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!