realtek: move private bus structure closer to the bus
authorMarkus Stockhausen <[email protected]>
Fri, 2 May 2025 14:17:11 +0000 (10:17 -0400)
committerStijn Tintel <[email protected]>
Mon, 12 May 2025 13:09:19 +0000 (16:09 +0300)
Relocate the bus structure definition into the MDIO source code area
of the ethernet driver. So if the real bus driver is forked from the
rest of the code only one area needs to be removed. Rename it to make
clear it belongs to the bus.

Signed-off-by: Markus Stockhausen <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/18402
Signed-off-by: Stijn Tintel <[email protected]>
target/linux/realtek/files-6.6/drivers/net/ethernet/rtl838x_eth.c
target/linux/realtek/files-6.6/drivers/net/ethernet/rtl838x_eth.h

index 557df765937bbcc05ad9420b0c98ddddc9c7077d..d9c689d8cc9a598eb1046b9027862b54b3f641d8 100644 (file)
@@ -1707,6 +1707,18 @@ static int rtl838x_set_link_ksettings(struct net_device *ndev,
  * reimplemented. For now it should be sufficient.
  */
 
+struct rtmdio_bus_priv {
+       struct rtl838x_eth_priv *eth_priv;
+       int extaddr;
+       int rawpage;
+       int page[64];
+       bool raw[64];
+       int (*read_mmd_phy)(u32 port, u32 addr, u32 reg, u32 *val);
+       int (*write_mmd_phy)(u32 port, u32 addr, u32 reg, u32 val);
+       int (*read_phy)(u32 port, u32 page, u32 reg, u32 *val);
+       int (*write_phy)(u32 port, u32 page, u32 reg, u32 val);
+};
+
 /*
  * Provide a generic read/write function so we can access arbitrary ports on the bus.
  * E.g. other ports of a PHY package on the bus. This basically resembles the kernel
@@ -1803,7 +1815,7 @@ int phy_port_read_paged(struct phy_device *phydev, int port, int page, u32 regnu
 static int rtmdio_read_c45(struct mii_bus *bus, int addr, int devnum, int regnum)
 {
        int err, val;
-       struct rtl838x_bus_priv *bus_priv = bus->priv;
+       struct rtmdio_bus_priv *bus_priv = bus->priv;
 
        if (bus_priv->extaddr >= 0)
                addr = bus_priv->extaddr;
@@ -1817,7 +1829,7 @@ static int rtmdio_read_c45(struct mii_bus *bus, int addr, int devnum, int regnum
 static int rtmdio_83xx_read(struct mii_bus *bus, int addr, int regnum)
 {
        int err, val;
-       struct rtl838x_bus_priv *bus_priv = bus->priv;
+       struct rtmdio_bus_priv *bus_priv = bus->priv;
        struct rtl838x_eth_priv *eth_priv = bus_priv->eth_priv;
 
        if (bus_priv->extaddr >= 0)
@@ -1842,7 +1854,7 @@ static int rtmdio_83xx_read(struct mii_bus *bus, int addr, int regnum)
 static int rtmdio_93xx_read(struct mii_bus *bus, int addr, int regnum)
 {
        int err, val;
-       struct rtl838x_bus_priv *bus_priv = bus->priv;
+       struct rtmdio_bus_priv *bus_priv = bus->priv;
        struct rtl838x_eth_priv *eth_priv = bus_priv->eth_priv;
 
        if (bus_priv->extaddr >= 0)
@@ -1870,7 +1882,7 @@ static int rtmdio_93xx_read(struct mii_bus *bus, int addr, int regnum)
 static int rtmdio_write_c45(struct mii_bus *bus, int addr, int devnum, int regnum, u16 val)
 {
        int err;
-       struct rtl838x_bus_priv *bus_priv = bus->priv;
+       struct rtmdio_bus_priv *bus_priv = bus->priv;
 
        if (bus_priv->extaddr >= 0)
                addr = bus_priv->extaddr;
@@ -1884,7 +1896,7 @@ static int rtmdio_write_c45(struct mii_bus *bus, int addr, int devnum, int regnu
 static int rtmdio_83xx_write(struct mii_bus *bus, int addr, int regnum, u16 val)
 {
        int err, page, offset = 0;
-       struct rtl838x_bus_priv *bus_priv = bus->priv;
+       struct rtmdio_bus_priv *bus_priv = bus->priv;
        struct rtl838x_eth_priv *eth_priv = bus_priv->eth_priv;
 
        if (regnum == RTMDIO_PORT_SELECT) {
@@ -1924,7 +1936,7 @@ static int rtmdio_83xx_write(struct mii_bus *bus, int addr, int regnum, u16 val)
 static int rtmdio_93xx_write(struct mii_bus *bus, int addr, int regnum, u16 val)
 {
        int err, page;
-       struct rtl838x_bus_priv *bus_priv = bus->priv;
+       struct rtmdio_bus_priv *bus_priv = bus->priv;
        struct rtl838x_eth_priv *eth_priv = bus_priv->eth_priv;
 
        if (regnum == RTMDIO_PORT_SELECT) {
@@ -1993,7 +2005,7 @@ u8 mac_type_bit[RTL930X_CPU_PORT] = {0, 0, 0, 0, 2, 2, 2, 2, 4, 4, 4, 4, 6, 6, 6
 
 static int rtmdio_930x_reset(struct mii_bus *bus)
 {
-       struct rtl838x_bus_priv *bus_priv = bus->priv;
+       struct rtmdio_bus_priv *bus_priv = bus->priv;
        struct rtl838x_eth_priv *priv = bus_priv->eth_priv;
        u32 c45_mask = 0;
        u32 poll_sel[2];
@@ -2099,7 +2111,7 @@ static int rtmdio_930x_reset(struct mii_bus *bus)
 
 static int rtmdio_931x_reset(struct mii_bus *bus)
 {
-       struct rtl838x_bus_priv *bus_priv = bus->priv;
+       struct rtmdio_bus_priv *bus_priv = bus->priv;
        struct rtl838x_eth_priv *priv = bus_priv->eth_priv;
        u32 c45_mask = 0;
        u32 poll_sel[4];
@@ -2199,7 +2211,7 @@ static int rtl931x_chip_init(struct rtl838x_eth_priv *priv)
 static int rtl838x_mdio_init(struct rtl838x_eth_priv *priv)
 {
        struct device_node *mii_np, *dn;
-       struct rtl838x_bus_priv *bus_priv;
+       struct rtmdio_bus_priv *bus_priv;
        u32 pn;
        int i, ret;
 
index d6d88fc2ed01b8d7aa9c359c33a9f1707e1c4a4a..47ed286aa44731746bd922010850002d6a6bb024 100644 (file)
@@ -408,18 +408,6 @@ inline u32 rtl931x_get_mac_tx_pause_sts(int p)
 struct p_hdr;
 struct dsa_tag;
 
-struct rtl838x_bus_priv {
-       struct rtl838x_eth_priv *eth_priv;
-       int extaddr;
-       int rawpage;
-       int page[64];
-       bool raw[64];
-       int (*read_mmd_phy)(u32 port, u32 addr, u32 reg, u32 *val);
-       int (*write_mmd_phy)(u32 port, u32 addr, u32 reg, u32 val);
-       int (*read_phy)(u32 port, u32 page, u32 reg, u32 *val);
-       int (*write_phy)(u32 port, u32 page, u32 reg, u32 val);
-};
-
 struct rtl838x_eth_reg {
        irqreturn_t (*net_irq)(int irq, void *dev_id);
        int (*mac_port_ctrl)(int port);