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.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 8E323C4727E for ; Wed, 30 Sep 2020 16:36:08 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D4809206E3 for ; Wed, 30 Sep 2020 16:36:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="A0igF194" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D4809206E3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lunn.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wWqheqOipfU1LUmUS8QjzldaBKEEpkN8pAyZQ51xxhE=; b=A0igF194zEyU5ohbMbefruOli 3RxRc4nfxkQ8S+A7keURwLjeNMbtamwZc7ENvb0Pp9wWGnabXzPcOC+paH4mIFAijWduaSyYxLlS/ CAAU1DF9CmopDdY6fj7CQTO14/FApXiUMJNEQ1cLdhQfDDzEzEM8MTQan7fC7em3zP3rXtZ9RX/oC hSohyN4RCLnqTqqqc5jznr54FbEQ9Y30C2nYHidZLVOEKjbBvgaus9agRFDAlywrJHJ2zTLIppmSg xSqKIgGTAQIoK8KHYUzhf/2s5LjXj8cyeigrzlfoeR0+HR0HSYr3egzSPpCc84RboYa7pOfVeBtyC 17VvEjl+w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNf44-0007pJ-L3; Wed, 30 Sep 2020 16:34:48 +0000 Received: from vps0.lunn.ch ([185.16.172.187]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNf42-0007oD-2M for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2020 16:34:47 +0000 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 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-Disposition: inline In-Reply-To: <20200930160430.7908-4-calvin.johnson@oss.nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200930_123446_585108_86020682 X-CRM114-Status: GOOD ( 14.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Fainelli , Jakub Kicinski , "Rafael J . Wysocki" , Madalin Bucur , netdev@vger.kernel.org, Russell King - ARM Linux admin , Jeremy Linton , linux-kernel@vger.kernel.org, Diana Madalina Craciun , linux-acpi@vger.kernel.org, Andy Shevchenko , Grant Likely , linux.cj@gmail.com, Ioana Ciornei , Heikki Krogerus , Heiner Kallweit , Laurentiu Tudor , Cristi Sovaiala , "David S. Miller" , linux-arm-kernel@lists.infradead.org, Florin Laurentiu Chiculita Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel