]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: phy: Simplify the logic of phy_connect_fixed()
authorBin Meng <bmeng.cn@gmail.com>
Sun, 14 Mar 2021 12:14:52 +0000 (20:14 +0800)
committerPriyanka Jain <priyanka.jain@nxp.com>
Thu, 15 Apr 2021 08:52:17 +0000 (14:22 +0530)
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 <bmeng.cn@gmail.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
drivers/net/phy/phy.c

index c7cdf64a0a448b814fba8b164cc71b5cff6cb0c6..dcdef9e661d6fde76e5b33f7fb2af549db8cf093 100644 (file)
@@ -18,6 +18,7 @@
 #include <phy.h>
 #include <errno.h>
 #include <asm/global_data.h>
+#include <dm/of_extra.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
 #include <linux/err.h>
@@ -1008,15 +1009,14 @@ static struct phy_device *phy_connect_fixed(struct mii_dev *bus,
                                            phy_interface_t interface)
 {
        ofnode node = dev_ofnode(dev), subnode;
-       struct phy_device *phydev;
-
-       subnode = ofnode_find_subnode(node, "fixed-link");
-       if (!ofnode_valid(subnode))
-               return NULL;
+       struct phy_device *phydev = NULL;
 
-       phydev = phy_device_create(bus, 0, PHY_FIXED_ID, false, interface);
-       if (phydev)
-               phydev->node = subnode;
+       if (ofnode_phy_is_fixed_link(node, &subnode)) {
+               phydev = phy_device_create(bus, 0, PHY_FIXED_ID,
+                                          false, interface);
+               if (phydev)
+                       phydev->node = subnode;
+       }
 
        return phydev;
 }