From 898f67826173e5264d1531600934d58bb2c97fee Mon Sep 17 00:00:00 2001 From: Markus Stockhausen Date: Sun, 1 Mar 2026 17:16:31 +0100 Subject: [PATCH] realtek: dsa: relax rtldsa_ethernet_loaded() The Realtek DSA driver accesses the DTS at two locations. - rtldsa_ethernet_loaded(): to check if ethernet driver is active - rtl83xx_mdio_probe(): to create ports and link to pcs/phy The first function does not directly search for the ethernet driver but looks it up through the switch port nodes. Avoid future issues and simply search all nodes that have a "ethernet" link to the network driver. While we are here add a missing put_device() to keep reference counters clean. Signed-off-by: Markus Stockhausen Link: https://github.com/openwrt/openwrt/pull/22235 Signed-off-by: Hauke Mehrtens --- .../drivers/net/dsa/rtl83xx/common.c | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c index a7a614a0c5..59c1444e6e 100644 --- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c +++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c @@ -1540,19 +1540,13 @@ static int rtl83xx_fib_event(struct notifier_block *this, unsigned long event, v */ static int rtldsa_ethernet_loaded(struct platform_device *pdev) { - struct device_node *dn = pdev->dev.of_node; - struct device_node *ports, *port; + struct platform_device *eth_pdev; + struct device_node *port_np; + struct device_node *eth_np; int ret = -EPROBE_DEFER; - ports = of_get_child_by_name(dn, "ethernet-ports"); - if (!ports) - return -ENODEV; - - for_each_child_of_node(ports, port) { - struct device_node *eth_np; - struct platform_device *eth_pdev; - - eth_np = of_parse_phandle(port, "ethernet", 0); + for_each_node_with_property(port_np, "ethernet") { + eth_np = of_parse_phandle(port_np, "ethernet", 0); if (!eth_np) continue; @@ -1564,9 +1558,9 @@ static int rtldsa_ethernet_loaded(struct platform_device *pdev) if (eth_pdev->dev.driver) ret = 0; - } - of_node_put(ports); + put_device(ð_pdev->dev); + } return ret; }