Skip to content

Commit 6d82a50

Browse files
plappermaulrobimarko
authored andcommitted
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@gmx.de> Link: openwrt/openwrt#22008 Signed-off-by: Robert Marko <robimarko@gmail.com>
1 parent 60d90f9 commit 6d82a50

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,6 @@ struct rtmdio_config {
199199
};
200200

201201
struct rtmdio_phy_info {
202-
unsigned int phy_id;
203-
bool phy_unknown;
204202
int mac_type;
205203
bool has_giga_lite;
206204
bool has_res_reg;
@@ -604,10 +602,11 @@ static u32 rtmdio_get_phy_id(struct phy_device *phydev)
604602
return phydev->phy_id;
605603
}
606604

607-
static void rtmdio_get_phy_info(struct mii_bus *bus, int addr, struct rtmdio_phy_info *phyinfo)
605+
static int rtmdio_get_phy_info(struct mii_bus *bus, int addr, struct rtmdio_phy_info *phyinfo)
608606
{
609607
struct phy_device *phydev = mdiobus_get_phy(bus, addr);
610608
u32 phyid = rtmdio_get_phy_id(phydev);
609+
int ret = 0;
611610

612611
/*
613612
* 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
641640
phyinfo->poll_lpa_1000 = RTMDIO_PHY_POLL_MMD(31, 0xa414, 11);
642641
break;
643642
default:
644-
phyinfo->phy_unknown = true;
643+
pr_warn("skip polling setup for unknown PHY %08x on port %d\n", phyid, addr);
644+
ret = -EINVAL;
645645
break;
646646
}
647+
648+
return ret;
647649
}
648650

649651
static int rtmdio_838x_reset(struct mii_bus *bus)
@@ -721,12 +723,8 @@ static void rtmdio_930x_setup_polling(struct mii_bus *bus)
721723

722724
/* Define PHY specific polling parameters */
723725
for_each_port(ctrl, addr) {
724-
rtmdio_get_phy_info(bus, addr, &phyinfo);
725-
if (phyinfo.phy_unknown) {
726-
pr_warn("skip polling setup for unknown PHY %08x on port %d\n",
727-
phyinfo.phy_id, addr);
726+
if (rtmdio_get_phy_info(bus, addr, &phyinfo))
728727
continue;
729-
}
730728

731729
/* port MAC type */
732730
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)
806804
int smi = ctrl->smi_bus[addr];
807805
unsigned int mask, val;
808806

809-
rtmdio_get_phy_info(bus, addr, &phyinfo);
810-
if (phyinfo.phy_unknown) {
811-
pr_warn("skip polling setup for unknown PHY %08x on port %d\n",
812-
phyinfo.phy_id, addr);
807+
if (rtmdio_get_phy_info(bus, addr, &phyinfo))
813808
continue;
814-
}
815809

816810
mask = val = 0;
817811

0 commit comments

Comments
 (0)