realtek: mdio: provide bidirectional bus lookup

Add two attributes to the central control and the channel structure.

chan->smi_bus: The index of the selected channel.
ctrl->bus[].mii_bus: Links to all busses

With this ctrl/chan can lookup each others data more easily.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/22830
Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
Markus Stockhausen 2026-04-07 18:22:07 +02:00 committed by Robert Marko
parent c635df7030
commit fafe10fd25

View File

@ -185,6 +185,7 @@ struct rtmdio_port {
struct rtmdio_bus {
bool is_c45;
struct mii_bus *mii_bus;
};
struct rtmdio_ctrl {
@ -198,6 +199,7 @@ struct rtmdio_ctrl {
struct rtmdio_chan {
struct rtmdio_ctrl *ctrl;
u8 smi_bus;
};
struct rtmdio_config {
@ -947,6 +949,9 @@ static int rtmdio_probe_one(struct device *dev, struct rtmdio_ctrl *ctrl)
chan = bus->priv;
chan->ctrl = ctrl;
chan->smi_bus = 0;
ctrl->bus[0].mii_bus = bus;
bus->name = "Realtek MDIO bus";
bus->reset = rtmdio_reset;
bus->read = rtmdio_read;