diff options
| author | Markus Stockhausen | 2026-02-13 19:25:15 +0000 |
|---|---|---|
| committer | Robert Marko | 2026-02-16 14:44:20 +0000 |
| commit | 60d90f90171f957e6267414ddba662e80ab4aa20 (patch) | |
| tree | e7829c2b5d9cbbb6b47d0ce0ee7014c18f94b282 | |
| parent | afbbf21714b6f0229d8efa37f47a74cfeac53379 (diff) | |
| download | openwrt-60d90f90171f957e6267414ddba662e80ab4aa20.tar.gz | |
realtek: mdio: provide for_each_port helper
For better readability provide a macro to loop over all
active ports od the mdio bus.
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/22008
Signed-off-by: Robert Marko <robimarko@gmail.com>
| -rw-r--r-- | target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c | 21 |
1 files changed, 8 insertions, 13 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 cf4ca57bf3..fac116e76b 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 @@ -104,6 +104,10 @@ #define RTMDIO_931X_SMI_10GPHY_POLLING_SEL3 (0x0CFC) #define RTMDIO_931X_SMI_10GPHY_POLLING_SEL4 (0x0D00) +#define for_each_port(ctrl, addr) \ + for (int addr = 0; addr < (ctrl)->cfg->cpu_port; addr++) \ + if ((ctrl)->smi_bus[addr] >= 0) + /* * On all Realtek switch platforms the hardware periodically reads the link status of all * PHYs. This is to some degree programmable, so that one can tell the hardware to read @@ -566,10 +570,7 @@ static void rtmdio_setup_smi_topology(struct mii_bus *bus) struct rtmdio_ctrl *ctrl = bus->priv; u32 reg, mask, val; - for (int addr = 0; addr < ctrl->cfg->cpu_port; addr++) { - if (ctrl->smi_bus[addr] < 0) - continue; - + for_each_port(ctrl, addr) { if (ctrl->cfg->bus_map_base) { reg = (addr / 16) * 4; mask = 0x3 << ((addr % 16) * 2); @@ -719,10 +720,7 @@ static void rtmdio_930x_setup_polling(struct mii_bus *bus) regmap_write(ctrl->map, RTMDIO_930X_SMI_MAC_TYPE_CTRL, 0); /* Define PHY specific polling parameters */ - for (int addr = 0; addr < ctrl->cfg->cpu_port; addr++) { - if (ctrl->smi_bus[addr] < 0) - continue; - + 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", @@ -804,13 +802,10 @@ static void rtmdio_931x_setup_polling(struct mii_bus *bus) * the existing hardware designs (i.e. only equally polled PHYs on * the same SMI bus or kind of PHYs). */ - for (int addr = 0; addr < ctrl->cfg->cpu_port; addr++) { - unsigned int mask, val; + for_each_port(ctrl, addr) { int smi = ctrl->smi_bus[addr]; + unsigned int mask, val; - if (smi < 0) - continue; - rtmdio_get_phy_info(bus, addr, &phyinfo); if (phyinfo.phy_unknown) { pr_warn("skip polling setup for unknown PHY %08x on port %d\n", |