[PATCH v2 1/2] net: fec: Don't use disabled phys

Sean Anderson sean.anderson at seco.com
Thu Apr 15 19:06:08 CEST 2021


If a phy is disabled, don't use it. This matches Linux's behavior.

Signed-off-by: Sean Anderson <sean.anderson at seco.com>
Reviewed-by: Ramon Fried <rfried.dev at gmail.com>
---

Changes in v2:
- Fix debug statement missing a parameter.
- Assign phy_of_node only after we determine if the node is available.

 drivers/net/fec_mxc.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index ec21157d71..59f5a14e54 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -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;
-- 
2.25.1



More information about the U-Boot mailing list