Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4707601pxk; Wed, 30 Sep 2020 09:36:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzP9SZkD2A4kL91VRO6x5iqS/O0XuDFib619SSz8AgHmzxs0rYhRBoRHiz48dCEutAf1gn X-Received: by 2002:a50:f197:: with SMTP id x23mr3796491edl.367.1601483767691; Wed, 30 Sep 2020 09:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601483767; cv=none; d=google.com; s=arc-20160816; b=bHStbsQ059Nc0T1pY0ZJMNfYeQf0FcFfSP5fQldT/f00BPAjPQ+2sb4OIuHhqshjeT 2UyW1kFhzOUu0CRmSZfeN5vRpLUcuaigxE/rFP4QFSWHSzYJgRmiSDz1Lu0/iMRPt1RD S3rvyD6KVRNF5x2moHzDNCl6FARI1PZSHopBrTdmPTlGhXdF3LhI3QccdVxQe5wBD4xf n0ae4oaVDtfWnhu2VPE8NqYYVGqut6o4hzvDSAznxp8hRnDCT3y1s6kcXvvmz32T+vX7 kzEQMIOuJBongQO4J73f+LYHSUZyLqtWblmiw1achP0L9PVNSyZqwA+H0iats3yGBsl1 /wmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=LR+ZZpiSV+TgD8WFcHzek59oNKhaEvwlJT18TE2/Zm0=; b=opGobXTUFRpZ3GQZMlcebO6A/g1i3qKM8lQ7sHw5cKdSR26F3V97yc80HH1fM8IPCD 24EXEWNfkP/gBP1KwUq07ZEBhrVwj7pdofhUJf/XePgYxqRPScrB0OWjRArGNKmAj0j9 Adc3C2XPkIFCN1goS2QsNGkBaC36ayP97yhXn4L6RorJySw6061JlSAHpqwyVghOYfZK 1XYU4ca7znMrVS0rkzIJDGC8SgwOdFT15GTVriVfUm/n8NnSsuT+uQjw7aED77ffKMIq 4bqaWfnJYTfYBqVIv9a06q4rJDHlROFZEwjF6nE64z3CMN4sZDhGxJpnLmOO3+NGd1fs FK3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d16si1327596edr.309.2020.09.30.09.35.44; Wed, 30 Sep 2020 09:36:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728674AbgI3Qeo (ORCPT + 99 others); Wed, 30 Sep 2020 12:34:44 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:36400 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725355AbgI3Qeo (ORCPT ); Wed, 30 Sep 2020 12:34:44 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1kNf3w-00GvXT-6Z; Wed, 30 Sep 2020 18:34:40 +0200 Date: Wed, 30 Sep 2020 18:34:40 +0200 From: Andrew Lunn To: Calvin Johnson Cc: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , linux-kernel@vger.kernel.org, linux.cj@gmail.com, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Diana Madalina Craciun , Laurentiu Tudor , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: Re: [net-next PATCH v1 3/7] net: phy: Introduce fwnode_get_phy_id() Message-ID: <20200930163440.GR3996795@lunn.ch> References: <20200930160430.7908-1-calvin.johnson@oss.nxp.com> <20200930160430.7908-4-calvin.johnson@oss.nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200930160430.7908-4-calvin.johnson@oss.nxp.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +/* Extract the phy ID from the compatible string of the form > + * ethernet-phy-idAAAA.BBBB. > + */ > +int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id) > +{ > + unsigned int upper, lower; > + const char *cp; > + int ret; > + > + ret = fwnode_property_read_string(fwnode, "compatible", &cp); > + if (ret) > + return ret; > + > + if (sscanf(cp, "ethernet-phy-id%4x.%4x", &upper, &lower) == 2) { > + *phy_id = ((upper & 0xFFFF) << 16) | (lower & 0xFFFF); > + return 0; > + } > + return -EINVAL; > +} > +EXPORT_SYMBOL(fwnode_get_phy_id); Hi Calvin Do you really need this? Do you have a board with a broken PHY ID? > /** > * get_phy_device - reads the specified PHY device and returns its @phy_device > * struct > @@ -2866,7 +2888,15 @@ EXPORT_SYMBOL_GPL(device_phy_find_device); > */ > struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode) > { > - return fwnode_find_reference(fwnode, "phy-handle", 0); > + struct fwnode_handle *phy_node; > + > + phy_node = fwnode_find_reference(fwnode, "phy-handle", 0); > + if (is_acpi_node(fwnode) || !IS_ERR(phy_node)) > + return phy_node; > + phy_node = fwnode_find_reference(fwnode, "phy", 0); > + if (IS_ERR(phy_node)) > + phy_node = fwnode_find_reference(fwnode, "phy-device", 0); > + return phy_node; Why do you have three different ways to reference a PHY? Andrew