Re: [PATCH net-next 5/5] net: mdio: bcm-unimac: implement timestamped MDIO writes

From: Andrew Lunn

Date: Mon Oct 12 2026 - 08:21:18 EST


> +static int unimac_mdio_sts_delays(struct unimac_mdio_priv *priv,
> + u64 *pre_ns, u64 *post_ns)
> +{
> + u32 cmd, config, divisor;
> + int ret;
> +
> + /* The delays assume the controller is idle. */
> + ret = read_poll_timeout(unimac_mdio_readl, cmd,
> + !(cmd & MDIO_START_BUSY),
> + 1, 1000, false, priv, MDIO_CMD);
> + if (ret)
> + return ret;
> +
> + config = unimac_mdio_readl(priv, MDIO_CFG);
> + if (config & MDIO_SUPP_PREAMBLE)

The preample has a fixed size, so you can take this into account,
reduce your 64 to 32.

> @@ -138,19 +192,38 @@ static int unimac_mdio_write(struct mii_bus *bus, int phy_id,
> if (ret)
> return ret;
>
> + if (sts) {
> + ret = unimac_mdio_sts_delays(priv, &pre_ns, &post_ns);
> + if (ret)
> + goto out;
> + }
> +

Maybe just repeat unimac_mdio_write(), rather than try and squeeze all
this sts stuff into what is a simple function.

Andrew