diff mbox series

net: phy: micrel: Try default PHY ofnode first

Message ID 20210116231616.302205-1-marex@denx.de
State Accepted
Commit b5f09df246a8a24a3b4acb669cbf95d2a063176b
Delegated to: Tom Rini
Headers show
Series net: phy: micrel: Try default PHY ofnode first | expand

Commit Message

Marek Vasut Jan. 16, 2021, 11:16 p.m. UTC
The phydev structure has a PHY OF node pointer in it, use that OF node
first when looking up PHY OF node properties, since that is likely the
correct PHY OF node pointer. If the pointer is not valid, which is the
case e.g. on legacy DTs, fall back to parsing MAC ethernet-phy subnode.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
---
 drivers/net/phy/micrel_ksz90x1.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Tom Rini Jan. 27, 2021, 7:22 p.m. UTC | #1
On Sun, Jan 17, 2021 at 12:16:16AM +0100, Marek Vasut wrote:

> The phydev structure has a PHY OF node pointer in it, use that OF node
> first when looking up PHY OF node properties, since that is likely the
> correct PHY OF node pointer. If the pointer is not valid, which is the
> case e.g. on legacy DTs, fall back to parsing MAC ethernet-phy subnode.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Ramon Fried <rfried.dev@gmail.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/net/phy/micrel_ksz90x1.c b/drivers/net/phy/micrel_ksz90x1.c
index f0032e8ce16..23a018c2c25 100644
--- a/drivers/net/phy/micrel_ksz90x1.c
+++ b/drivers/net/phy/micrel_ksz90x1.c
@@ -120,8 +120,13 @@  static int ksz90x1_of_config_group(struct phy_device *phydev,
 	if (!drv || !drv->writeext)
 		return -EOPNOTSUPP;
 
-	/* Look for a PHY node under the Ethernet node */
-	node = dev_read_subnode(dev, "ethernet-phy");
+	node = phydev->node;
+
+	if (!ofnode_valid(node)) {
+		/* Look for a PHY node under the Ethernet node */
+		node = dev_read_subnode(dev, "ethernet-phy");
+	}
+
 	if (!ofnode_valid(node)) {
 		/* No node found, look in the Ethernet node */
 		node = dev_ofnode(dev);