From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 7/8] net: phy: fix miibus parent device of_node not matching phy node
Date: Wed, 21 Feb 2024 16:03:22 +0100 [thread overview]
Message-ID: <20240221150323.2715164-8-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20240221150323.2715164-1-s.hauer@pengutronix.de>
The device node of a miibus parent device usually points to the ethernet
device node whereas the parent device node of a phy device usually
points to the mdio {} subnode between the ethernet node and the phy
node, so both can't match. Ethernet drivers usually provide a pointer
to the mdio {} subnode in miibus::dev.of_node, so use that to match
against the phy nodes parent.
This occured on a TQMa6UL where two FECs are registered, but both phys
are connected to the FEC2.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/phy/mdio_bus.c | 10 +++-------
drivers/net/phy/phy.c | 2 +-
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 94123ef614..eed7c779e7 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -316,19 +316,15 @@ int mdiobus_register(struct mii_bus *bus)
pr_info("%s: probed\n", dev_name(&bus->dev));
+ if (!bus->dev.of_node)
+ bus->dev.of_node = bus->parent->of_node;
+
if (bus->dev.of_node) {
bus->dev.of_node->dev = &bus->dev;
/* Register PHY's as child node to mdio node */
of_mdiobus_register(bus, bus->dev.of_node);
}
- else if (bus->parent->of_node) {
- /*
- * Register PHY's as child node to the ethernet node,
- * if there was no mdio node
- */
- of_mdiobus_register(bus, bus->parent->of_node);
- }
return 0;
}
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index ad02732ff9..abd78b2c80 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -358,7 +358,7 @@ static struct phy_device *of_mdio_find_phy(struct eth_device *edev)
if (!of_property_read_u32(phy_node, "reg", &addr)) {
of_device_ensure_probed(phy_node->parent);
for_each_mii_bus(bus) {
- if (bus->parent->of_node == phy_node->parent) {
+ if (bus->dev.of_node == phy_node->parent) {
struct phy_device *phy = mdiobus_scan(bus, addr);
if (!IS_ERR(phy))
return phy;
--
2.39.2
next prev parent reply other threads:[~2024-02-21 15:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-21 15:03 [PATCH 0/8] Update TQMa6UL Sascha Hauer
2024-02-21 15:03 ` [PATCH 1/8] board: tq: add missing select Sascha Hauer
2024-02-21 15:03 ` [PATCH 2/8] board: tq: fix format specifier Sascha Hauer
2024-02-21 15:03 ` [PATCH 3/8] board: tq: add support for 16bit eeprom Sascha Hauer
2024-02-21 15:03 ` [PATCH 4/8] ARM: i.MX6: add i2c4 base address Sascha Hauer
2024-02-21 15:03 ` [PATCH 5/8] ARM: tqma6ul: add pr_fmt string Sascha Hauer
2024-02-21 15:03 ` [PATCH 6/8] ARM: tqma6ul: enable enet_ref_125m clk Sascha Hauer
2024-02-21 15:03 ` Sascha Hauer [this message]
2024-02-21 15:03 ` [PATCH 8/8] ARM: tqma6ul: use upstream device trees Sascha Hauer
2024-02-21 16:42 ` Ahmad Fatoum
2024-02-23 7:37 ` Sascha Hauer
2024-02-23 7:32 ` [PATCH 0/8] Update TQMa6UL Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240221150323.2715164-8-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox