]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: fec: Don't use disabled phys
authorSean Anderson <sean.anderson@seco.com>
Thu, 15 Apr 2021 17:06:08 +0000 (13:06 -0400)
committerStefano Babic <sbabic@denx.de>
Sun, 2 May 2021 10:46:54 +0000 (12:46 +0200)
If a phy is disabled, don't use it. This matches Linux's behavior.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
drivers/net/fec_mxc.c

index ec21157d71052766e5ce93c82aa6c7b66cdfa555..59f5a14e54e819d1f078286539d305716ade076e 100644 (file)
@@ -1299,16 +1299,19 @@ static const struct eth_ops fecmxc_ops = {
 static int device_get_phy_addr(struct fec_priv *priv, struct udevice *dev)
 {
        struct ofnode_phandle_args phandle_args;
-       int reg;
+       int reg, ret;
 
-       if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
-                                      &phandle_args)) {
-               debug("Failed to find phy-handle");
-               return -ENODEV;
+       ret = dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
+                                        &phandle_args);
+       if (ret) {
+               debug("Failed to find phy-handle (err = %d\n)", ret);
+               return ret;
        }
 
-       priv->phy_of_node = phandle_args.node;
+       if (!ofnode_is_available(phandle_args.node))
+               return -ENOENT;
 
+       priv->phy_of_node = phandle_args.node;
        reg = ofnode_read_u32_default(phandle_args.node, "reg", 0);
 
        return reg;