On Tue, May 26, 2026 at 07:43:42PM +0200, Markus Stockhausen wrote:
quoted hunk ↗ jump to hunk
The command runner can only be used for C22/C45 writes. Enhance it
so it can be used for reading as well. For this.
- Enhance signature and add pointer to return value
- If pointer is given, read back the return value from read operation
- Hand over NULL pointer for current write consumers.
Signed-off-by: Markus Stockhausen <redacted>
---
drivers/net/mdio/mdio-realtek-rtl9300.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/net/mdio/mdio-realtek-rtl9300.c b/drivers/net/mdio/mdio-realtek-rtl9300.c
index a1870b16d8b9..6f4affe0696d 100644
--- a/drivers/net/mdio/mdio-realtek-rtl9300.c
+++ b/drivers/net/mdio/mdio-realtek-rtl9300.c
@@ -139,7 +139,7 @@ static struct otto_emdio_priv *otto_emdio_bus_to_priv(struct mii_bus *bus)
}
static int otto_emdio_run_cmd(struct mii_bus *bus, u32 cmd,
- struct otto_emdio_cmd_regs *cmd_data)
+ struct otto_emdio_cmd_regs *cmd_data, u32 *value)
+ if (!value)
+ return 0;
- return otto_emdio_run_cmd(bus, PHY_CTRL_TYPE_C22 | PHY_CTRL_WRITE, &cmd_regs);
+ return otto_emdio_run_cmd(bus, PHY_CTRL_TYPE_C22 | PHY_CTRL_WRITE, &cmd_regs, NULL);
Optional parameters like this which change the behaviour of a function
is not great.
It is better to have two functions, with a helper containing the
common code. So otto_emdio_write_cmd() and otto_emdio_read_cmd(). They
can then OR in the PHY_CTRL_WRITE or PHY_CTRL_READ.
Andrew