From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bin Meng Date: Tue, 2 Mar 2021 23:34:41 +0800 Subject: [PATCH 10/20] net: phy: Simplify the logic of phy_connect_fixed() In-Reply-To: <20210302153451.19440-1-bmeng.cn@gmail.com> References: <20210302153451.19440-1-bmeng.cn@gmail.com> Message-ID: <20210302153451.19440-11-bmeng.cn@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Simplify the logic of phy_connect_fixed() by using the new API ofnode_phy_is_fixed_link(), which brings additional bonus of supporting the old DT bindings. Signed-off-by: Bin Meng --- drivers/net/phy/phy.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 69e02685fa..0e85a80761 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1002,19 +1003,12 @@ static struct phy_device *phy_connect_fixed(struct mii_dev *bus, phy_interface_t interface) { struct phy_device *phydev = NULL; - ofnode node = dev_ofnode(dev); - const char *name; + ofnode eth_node = dev_ofnode(dev); + ofnode phy_node; - node = ofnode_first_subnode(node); - while (ofnode_valid(node)) { - name = ofnode_get_name(node); - if (name && strcmp(name, "fixed-link") == 0) { - phydev = phy_device_create(bus, ofnode_to_offset(node), - PHY_FIXED_ID, false, - interface); - break; - } - node = ofnode_next_subnode(node); + if (ofnode_phy_is_fixed_link(eth_node, &phy_node)) { + phydev = phy_device_create(bus, ofnode_to_offset(phy_node), + PHY_FIXED_ID, false, interface); } return phydev; -- 2.25.1