Skip to content

Commit b7f519f

Browse files
plappermaulrobimarko
authored andcommitted
realtek: mdio: move read/write functions to config structure
Move the read/write functions to where they belong. Signed-off-by: Markus Stockhausen <[email protected]> Link: openwrt/openwrt#21274 Signed-off-by: Robert Marko <[email protected]>
1 parent 3fb1c9c commit b7f519f

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

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

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,17 @@ struct rtmdio_bus_priv {
163163
bool smi_bus_isc45[RTMDIO_MAX_SMI_BUS];
164164
bool phy_is_internal[RTMDIO_MAX_PORT];
165165
phy_interface_t interfaces[RTMDIO_MAX_PORT];
166-
int (*read_mmd_phy)(u32 port, u32 addr, u32 reg, u32 *val);
167-
int (*write_mmd_phy)(u32 port, u32 addr, u32 reg, u32 val);
168-
int (*read_phy)(u32 port, u32 page, u32 reg, u32 *val);
169-
int (*write_phy)(u32 port, u32 page, u32 reg, u32 val);
170-
int (*read_sds_phy)(int sds, int page, int regnum);
171-
int (*write_sds_phy)(int sds, int page, int regnum, u16 val);
172166
};
173167

174168
struct rtmdio_config {
175169
int cpu_port;
176170
int raw_page;
171+
int (*read_mmd_phy)(u32 port, u32 addr, u32 reg, u32 *val);
172+
int (*read_phy)(u32 port, u32 page, u32 reg, u32 *val);
173+
int (*read_sds_phy)(int sds, int page, int regnum);
174+
int (*write_mmd_phy)(u32 port, u32 addr, u32 reg, u32 val);
175+
int (*write_phy)(u32 port, u32 page, u32 reg, u32 val);
176+
int (*write_sds_phy)(int sds, int page, int regnum, u16 val);
177177
};
178178

179179
/* SerDes reader/writer functions for the ports without external phy. */
@@ -1073,7 +1073,7 @@ static int rtmdio_read_c45(struct mii_bus *bus, int addr, int devnum, int regnum
10731073
if (addr >= priv->cfg->cpu_port)
10741074
return -ENODEV;
10751075

1076-
err = (*priv->read_mmd_phy)(addr, devnum, regnum, &val);
1076+
err = (*priv->cfg->read_mmd_phy)(addr, devnum, regnum, &val);
10771077
pr_debug("rd_MMD(adr=%d, dev=%d, reg=%d) = %d, err = %d\n",
10781078
addr, devnum, regnum, val, err);
10791079
return err ? err : val;
@@ -1113,7 +1113,7 @@ static int rtmdio_read_sds_phy(struct rtmdio_bus_priv *priv, int sds, int page,
11131113

11141114
ret = rtmdio_map_sds_register(page, regnum, &sds_page, &sds_regnum);
11151115
if (ret)
1116-
ret = priv->read_sds_phy(sds, sds_page, sds_regnum);
1116+
ret = priv->cfg->read_sds_phy(sds, sds_page, sds_regnum);
11171117
pr_debug("rd_SDS(sds=%d, pag=%d, reg=%d) = %d\n", sds, page, regnum, ret);
11181118

11191119
return ret;
@@ -1125,7 +1125,7 @@ static int rtmdio_write_sds_phy(struct rtmdio_bus_priv *priv, int sds, int page,
11251125

11261126
ret = rtmdio_map_sds_register(page, regnum, &sds_page, &sds_regnum);
11271127
if (ret)
1128-
ret = priv->write_sds_phy(sds, sds_page, sds_regnum, val);
1128+
ret = priv->cfg->write_sds_phy(sds, sds_page, sds_regnum, val);
11291129
pr_debug("wr_SDS(sds=%d, pag=%d, reg=%d, val=%d) err = %d\n", sds, page, regnum, val, ret);
11301130

11311131
return ret;
@@ -1147,7 +1147,7 @@ static int rtmdio_read(struct mii_bus *bus, int addr, int regnum)
11471147
return rtmdio_read_sds_phy(priv, priv->sds_id[addr],
11481148
priv->page[addr], regnum);
11491149

1150-
err = (*priv->read_phy)(addr, priv->page[addr], regnum, &val);
1150+
err = (*priv->cfg->read_phy)(addr, priv->page[addr], regnum, &val);
11511151
pr_debug("rd_PHY(adr=%d, pag=%d, reg=%d) = %d, err = %d\n",
11521152
addr, priv->page[addr], regnum, val, err);
11531153
return err ? err : val;
@@ -1161,7 +1161,7 @@ static int rtmdio_write_c45(struct mii_bus *bus, int addr, int devnum, int regnu
11611161
if (addr >= priv->cfg->cpu_port)
11621162
return -ENODEV;
11631163

1164-
err = (*priv->write_mmd_phy)(addr, devnum, regnum, val);
1164+
err = (*priv->cfg->write_mmd_phy)(addr, devnum, regnum, val);
11651165
pr_debug("wr_MMD(adr=%d, dev=%d, reg=%d, val=%d) err = %d\n",
11661166
addr, devnum, regnum, val, err);
11671167
return err;
@@ -1186,7 +1186,7 @@ static int rtmdio_write(struct mii_bus *bus, int addr, int regnum, u16 val)
11861186
return rtmdio_write_sds_phy(priv, priv->sds_id[addr],
11871187
priv->page[addr], regnum, val);
11881188

1189-
err = (*priv->write_phy)(addr, page, regnum, val);
1189+
err = (*priv->cfg->write_phy)(addr, page, regnum, val);
11901190
pr_debug("wr_PHY(adr=%d, pag=%d, reg=%d, val=%d) err = %d\n",
11911191
addr, page, regnum, val, err);
11921192
return err;
@@ -1441,42 +1441,18 @@ static int rtmdio_probe(struct platform_device *pdev)
14411441
case RTMDIO_838X_FAMILY_ID:
14421442
bus->name = "rtl838x-eth-mdio";
14431443
bus->reset = rtmdio_838x_reset;
1444-
priv->read_sds_phy = rtmdio_838x_read_sds_phy;
1445-
priv->write_sds_phy = rtmdio_838x_write_sds_phy;
1446-
priv->read_mmd_phy = rtmdio_838x_read_mmd_phy;
1447-
priv->write_mmd_phy = rtmdio_838x_write_mmd_phy;
1448-
priv->read_phy = rtmdio_838x_read_phy;
1449-
priv->write_phy = rtmdio_838x_write_phy;
14501444
break;
14511445
case RTMDIO_839X_FAMILY_ID:
14521446
bus->name = "rtl839x-eth-mdio";
14531447
bus->reset = rtmdio_839x_reset;
1454-
priv->read_sds_phy = rtmdio_839x_read_sds_phy;
1455-
priv->write_sds_phy = rtmdio_839x_write_sds_phy;
1456-
priv->read_mmd_phy = rtmdio_839x_read_mmd_phy;
1457-
priv->write_mmd_phy = rtmdio_839x_write_mmd_phy;
1458-
priv->read_phy = rtmdio_839x_read_phy;
1459-
priv->write_phy = rtmdio_839x_write_phy;
14601448
break;
14611449
case RTMDIO_930X_FAMILY_ID:
14621450
bus->name = "rtl930x-eth-mdio";
14631451
bus->reset = rtmdio_930x_reset;
1464-
priv->read_sds_phy = rtmdio_930x_read_sds_phy;
1465-
priv->write_sds_phy = rtmdio_930x_write_sds_phy;
1466-
priv->read_mmd_phy = rtmdio_930x_read_mmd_phy;
1467-
priv->write_mmd_phy = rtmdio_930x_write_mmd_phy;
1468-
priv->read_phy = rtmdio_930x_read_phy;
1469-
priv->write_phy = rtmdio_930x_write_phy;
14701452
break;
14711453
case RTMDIO_931X_FAMILY_ID:
14721454
bus->name = "rtl931x-eth-mdio";
14731455
bus->reset = rtmdio_931x_reset;
1474-
priv->read_sds_phy = rtsds_931x_read;
1475-
priv->write_sds_phy = rtsds_931x_write;
1476-
priv->read_mmd_phy = rtmdio_931x_read_mmd_phy;
1477-
priv->write_mmd_phy = rtmdio_931x_write_mmd_phy;
1478-
priv->read_phy = rtmdio_931x_read_phy;
1479-
priv->write_phy = rtmdio_931x_write_phy;
14801456
break;
14811457
}
14821458

@@ -1557,21 +1533,45 @@ static int rtmdio_probe(struct platform_device *pdev)
15571533
static const struct rtmdio_config rtmdio_838x_cfg = {
15581534
.cpu_port = 28,
15591535
.raw_page = 4095,
1536+
.read_mmd_phy = rtmdio_838x_read_mmd_phy,
1537+
.read_phy = rtmdio_838x_read_phy,
1538+
.read_sds_phy = rtmdio_838x_read_sds_phy,
1539+
.write_mmd_phy = rtmdio_838x_write_mmd_phy,
1540+
.write_phy = rtmdio_838x_write_phy,
1541+
.write_sds_phy = rtmdio_838x_write_sds_phy,
15601542
};
15611543

15621544
static const struct rtmdio_config rtmdio_839x_cfg = {
15631545
.cpu_port = 52,
15641546
.raw_page = 8191,
1547+
.read_mmd_phy = rtmdio_839x_read_mmd_phy,
1548+
.read_phy = rtmdio_839x_read_phy,
1549+
.read_sds_phy = rtmdio_839x_read_sds_phy,
1550+
.write_mmd_phy = rtmdio_839x_write_mmd_phy,
1551+
.write_phy = rtmdio_839x_write_phy,
1552+
.write_sds_phy = rtmdio_839x_write_sds_phy,
15651553
};
15661554

15671555
static const struct rtmdio_config rtmdio_930x_cfg = {
15681556
.cpu_port = 28,
15691557
.raw_page = 4095,
1558+
.read_mmd_phy = rtmdio_930x_read_mmd_phy,
1559+
.read_phy = rtmdio_930x_read_phy,
1560+
.read_sds_phy = rtmdio_930x_read_sds_phy,
1561+
.write_mmd_phy = rtmdio_930x_write_mmd_phy,
1562+
.write_phy = rtmdio_930x_write_phy,
1563+
.write_sds_phy = rtmdio_930x_write_sds_phy,
15701564
};
15711565

15721566
static const struct rtmdio_config rtmdio_931x_cfg = {
15731567
.cpu_port = 56,
15741568
.raw_page = 8191,
1569+
.read_mmd_phy = rtmdio_931x_read_mmd_phy,
1570+
.read_phy = rtmdio_931x_read_phy,
1571+
.read_sds_phy = rtsds_931x_read,
1572+
.write_mmd_phy = rtmdio_931x_write_mmd_phy,
1573+
.write_phy = rtmdio_931x_write_phy,
1574+
.write_sds_phy = rtsds_931x_write,
15751575
};
15761576

15771577
static const struct of_device_id rtmdio_ids[] = {

0 commit comments

Comments
 (0)