[openwrt/openwrt] realtek: mdio: simplify phy_info handler
LEDE Commits
lede-commits at lists.infradead.org
Mon Feb 16 06:44:31 PST 2026
robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/6d82a50575d516c04d1565b2953e9349a8e4eaaa
commit 6d82a50575d516c04d1565b2953e9349a8e4eaaa
Author: Markus Stockhausen <markus.stockhausen at gmx.de>
AuthorDate: Fri Feb 13 20:37:05 2026 +0100
realtek: mdio: simplify phy_info handler
Add return value to function and add an internal pr_warn().
This simplifies the callers and avoids duplicate coding.
Signed-off-by: Markus Stockhausen <markus.stockhausen at gmx.de>
Link: https://github.com/openwrt/openwrt/pull/22008
Signed-off-by: Robert Marko <robimarko at gmail.com>
---
.../drivers/net/mdio/mdio-realtek-otto.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c b/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c
index fac116e76b..bd5ad65a32 100644
--- a/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c
+++ b/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c
@@ -199,8 +199,6 @@ struct rtmdio_config {
};
struct rtmdio_phy_info {
- unsigned int phy_id;
- bool phy_unknown;
int mac_type;
bool has_giga_lite;
bool has_res_reg;
@@ -604,10 +602,11 @@ static u32 rtmdio_get_phy_id(struct phy_device *phydev)
return phydev->phy_id;
}
-static void rtmdio_get_phy_info(struct mii_bus *bus, int addr, struct rtmdio_phy_info *phyinfo)
+static int rtmdio_get_phy_info(struct mii_bus *bus, int addr, struct rtmdio_phy_info *phyinfo)
{
struct phy_device *phydev = mdiobus_get_phy(bus, addr);
u32 phyid = rtmdio_get_phy_id(phydev);
+ int ret = 0;
/*
* Depending on the attached PHY the polling mechanism must be fine tuned. Basically
@@ -641,9 +640,12 @@ static void rtmdio_get_phy_info(struct mii_bus *bus, int addr, struct rtmdio_phy
phyinfo->poll_lpa_1000 = RTMDIO_PHY_POLL_MMD(31, 0xa414, 11);
break;
default:
- phyinfo->phy_unknown = true;
+ pr_warn("skip polling setup for unknown PHY %08x on port %d\n", phyid, addr);
+ ret = -EINVAL;
break;
}
+
+ return ret;
}
static int rtmdio_838x_reset(struct mii_bus *bus)
@@ -721,12 +723,8 @@ static void rtmdio_930x_setup_polling(struct mii_bus *bus)
/* Define PHY specific polling parameters */
for_each_port(ctrl, addr) {
- rtmdio_get_phy_info(bus, addr, &phyinfo);
- if (phyinfo.phy_unknown) {
- pr_warn("skip polling setup for unknown PHY %08x on port %d\n",
- phyinfo.phy_id, addr);
+ if (rtmdio_get_phy_info(bus, addr, &phyinfo))
continue;
- }
/* port MAC type */
mask = addr > 23 ? 0x7 << ((addr - 24) * 3 + 12): 0x3 << ((addr / 4) * 2);
@@ -806,12 +804,8 @@ static void rtmdio_931x_setup_polling(struct mii_bus *bus)
int smi = ctrl->smi_bus[addr];
unsigned int mask, val;
- rtmdio_get_phy_info(bus, addr, &phyinfo);
- if (phyinfo.phy_unknown) {
- pr_warn("skip polling setup for unknown PHY %08x on port %d\n",
- phyinfo.phy_id, addr);
+ if (rtmdio_get_phy_info(bus, addr, &phyinfo))
continue;
- }
mask = val = 0;
More information about the lede-commits
mailing list