From: Markus Stockhausen Date: Wed, 10 Jun 2026 19:41:43 +0000 (+0200) Subject: net: mdio: realtek-rtl9300: Make otto_emdio_read_cmd() generic X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e1d8b024de7385567899049a71f880fccc733cc;p=thirdparty%2Flinux.git net: mdio: realtek-rtl9300: Make otto_emdio_read_cmd() generic 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 Signed-off-by: Markus Stockhausen Link: https://patch.msgid.link/20260610194145.4153668-4-markus.stockhausen@gmx.de Signed-off-by: Jakub Kicinski --- diff --git a/drivers/net/mdio/mdio-realtek-rtl9300.c b/drivers/net/mdio/mdio-realtek-rtl9300.c index 007a07136fa1..5aa447ed6424 100644 --- a/drivers/net/mdio/mdio-realtek-rtl9300.c +++ b/drivers/net/mdio/mdio-realtek-rtl9300.c @@ -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,