Re: [net-next PATCH v6 5/6] net: phy: Add support for Aeonsemi AS21xxx PHYs

Andrew Lunn
2025-04-09T16:30:15Z

> +static int aeon_ipc_get_fw_version(struct phy_device *phydev)
> +{
> + u16 ret_data[8], data[1];
> + u16 ret_sts;
> + int ret;
> +
> + data[0] = IPC_INFO_VERSION;
> + ret = aeon_ipc_send_msg(phydev, IPC_CMD_INFO, data,
> + sizeof(data), &ret_sts);
> + if (ret)
> + return ret;
> +
> + ret = aeon_ipc_rcv_msg(phydev, ret_sts, ret_data);
> + if (ret < 0)
> + return ret;
> +
> + phydev_info(phydev, "Firmware Version: %s\n", (char *)ret_data);

Maybe don't trust the firmware to return a \0 terminated string?

> +static int as21xxx_match_phy_device(struct phy_device *phydev,
> + const struct phy_driver *phydrv)
> +{
> + /* Sync parity... */
> + ret = aeon_ipc_sync_parity(phydev, priv);
> + if (ret)
> + goto out;
> +
> + /* ...and send a third NOOP cmd to wait for firmware finish loading */
> + ret = aeon_ipc_noop(phydev, priv, &ret_sts);
> + if (ret)
> + goto out;
> +
> +out:
> + mutex_destroy(&priv->ipc_lock);
> + kfree(priv);
> +
> + /* Return not maching anyway as PHY ID will change after
> + * firmware is loaded. This relies on the driver probe
> + * order where the first PHY driver probed is the
> + * generic one.
> + */
> + return ret;
> +}

This is not obvious. ret is either an error code, and we want to
return it. Or it is 0 because aeon_ipc_noop() returned 0 on success.
But the code then turns that 0 success into a false, does not match.
I think this last bit needs commenting on.

With those two fixed, you can add my Reviewed-by:

Andrew

---
pw-bot: cr