]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: mdio: realtek-rtl9300: Make otto_emdio_read_cmd() generic
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Wed, 10 Jun 2026 19:41:43 +0000 (21:41 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 13 Jun 2026 00:24:11 +0000 (17:24 -0700)
The otto_emdio_read_cmd() helper still uses RTL9300 specific properties.
This cannot be made generic as the I/O register has different layouts for
the different SoCs. E.g.

- RTL930x: data in bits 31-16, data out bits 15-0
- RTL931x: data in bits 15-0, data out bits 31-16

Add a mask parameter to the function signature and fill it properly
in the callers. As the masks will always have bits set from constant
defines, there is no need for a consistency check.

Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://patch.msgid.link/20260610194145.4153668-4-markus.stockhausen@gmx.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/mdio/mdio-realtek-rtl9300.c

index 007a07136fa157240c1ec51e1e5da0decc2c7802..5aa447ed6424db1a7708e7aefae1baad101eda4c 100644 (file)
@@ -191,7 +191,7 @@ static int otto_emdio_run_cmd(struct mii_bus *bus, u32 cmd,
 }
 
 static int otto_emdio_read_cmd(struct mii_bus *bus, u32 cmd,
-                              struct otto_emdio_cmd_regs *cmd_data, u32 *value)
+                              struct otto_emdio_cmd_regs *cmd_data, u32 mask, u32 *value)
 {
        struct otto_emdio_priv *priv = otto_emdio_bus_to_priv(bus);
        int ret;
@@ -205,7 +205,7 @@ static int otto_emdio_read_cmd(struct mii_bus *bus, u32 cmd,
        if (ret)
                return ret;
 
-       *value = FIELD_GET(RTL9300_PHY_CTRL_DATA, *value);
+       *value = field_get(mask, *value);
 
        return 0;
 }
@@ -230,7 +230,8 @@ static int otto_emdio_9300_read_c22(struct mii_bus *bus, int port, int regnum, u
                .io_data        = FIELD_PREP(RTL9300_PHY_CTRL_INDATA, port),
        };
 
-       return otto_emdio_read_cmd(bus, RTL9300_PHY_CTRL_TYPE_C22, &cmd_data, value);
+       return otto_emdio_read_cmd(bus, RTL9300_PHY_CTRL_TYPE_C22, &cmd_data,
+                                  RTL9300_PHY_CTRL_DATA, value);
 }
 
 static int otto_emdio_9300_write_c22(struct mii_bus *bus, int port, int regnum, u16 value)
@@ -256,7 +257,8 @@ static int otto_emdio_9300_read_c45(struct mii_bus *bus, int port,
                .io_data        = FIELD_PREP(RTL9300_PHY_CTRL_INDATA, port),
        };
 
-       return otto_emdio_read_cmd(bus, RTL9300_PHY_CTRL_TYPE_C45, &cmd_data, value);
+       return otto_emdio_read_cmd(bus, RTL9300_PHY_CTRL_TYPE_C45, &cmd_data,
+                                  RTL9300_PHY_CTRL_DATA, value);
 }
 
 static int otto_emdio_9300_write_c45(struct mii_bus *bus, int port,