From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F2D2C4727C for ; Wed, 30 Sep 2020 16:34:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4A6C820789 for ; Wed, 30 Sep 2020 16:34:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725372AbgI3Qeo (ORCPT ); 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-acpi@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