From: Markus Stockhausen Date: Wed, 25 Mar 2026 10:35:13 +0000 (+0100) Subject: realtek: mdio: create new bus structure X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c6ccca619c87f610d40e93b70fcd259eb3744618;p=thirdparty%2Fopenwrt.git realtek: mdio: create new bus structure The port specific attributes of the central control structure have been moved over to a separate port structure. Do the same for the (up to 4) busses. Establish a separate bus structure that will hold data about each bus and use it in the control structure. As a first usage type move the is_c45 attribute over. Signed-off-by: Markus Stockhausen Link: https://github.com/openwrt/openwrt/pull/22604 Signed-off-by: Robert Marko --- 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 7fa4528e958..ece60943364 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 @@ -180,11 +180,15 @@ struct rtmdio_port { u8 smi_bus; }; +struct rtmdio_bus { + bool is_c45; +}; + struct rtmdio_ctrl { struct regmap *map; const struct rtmdio_config *cfg; struct rtmdio_port port[RTMDIO_MAX_PHY]; - bool smi_bus_is_c45[RTMDIO_MAX_SMI_BUS]; + struct rtmdio_bus bus[RTMDIO_MAX_SMI_BUS]; DECLARE_BITMAP(valid_ports, RTMDIO_MAX_PHY); }; @@ -711,7 +715,7 @@ static int rtmdio_930x_reset(struct mii_bus *bus) /* Define C22/C45 bus feature set */ for (int addr = 0; addr < RTMDIO_MAX_SMI_BUS; addr++) { mask = BIT(16 + addr); - val = ctrl->smi_bus_is_c45[addr] ? mask : 0; + val = ctrl->bus[addr].is_c45 ? mask : 0; regmap_update_bits(ctrl->map, RTMDIO_930X_SMI_GLB_CTRL, mask, val); } @@ -768,7 +772,7 @@ static int rtmdio_931x_reset(struct mii_bus *bus) /* Define C22/C45 bus feature set */ for (int i = 0; i < RTMDIO_MAX_SMI_BUS; i++) { - if (ctrl->smi_bus_is_c45[i]) + if (ctrl->bus[i].is_c45) c45_mask |= 0x2 << (i * 2); /* Std. C45, non-standard is 0x3 */ } regmap_update_bits(ctrl->map, RTMDIO_931X_SMI_GLB_CTRL1, GENMASK(7, 0), c45_mask); @@ -887,7 +891,7 @@ static int rtmdio_map_ports(struct device *dev) of_fwnode_handle(phy->parent)); if (of_device_is_compatible(phy, "ethernet-phy-ieee802.3-c45")) - ctrl->smi_bus_is_c45[smi_bus] = true; + ctrl->bus[smi_bus].is_c45 = true; ctrl->port[addr].smi_bus = smi_bus; ctrl->port[addr].smi_addr = smi_addr;