Re: [PATCH net 2/2] net: phy: broadcom: release PTP clock with PHY devres

From: Andrew Lunn

Date: Wed Nov 18 2026 - 09:08:51 EST


> +static void bcm_ptp_remove(void *data)
> +{
> + struct bcm_ptp_private *priv = data;
> + struct phy_device *phydev = priv->phydev;

Reverse Christmas tree.

> +
> + if (phydev->mii_ts == &priv->mii_ts) {
> + phydev->mii_ts = NULL;
> + phydev->default_timestamp = false;
> + }
> +
> + ptp_clock_unregister(priv->ptp_clock);
> + skb_queue_purge(&priv->tx_queue);
> +}
> +
> struct bcm_ptp_private *bcm_ptp_probe(struct phy_device *phydev)
> {
> struct bcm_ptp_private *priv;
> struct ptp_clock *clock;
> + int err;
>
> switch (BRCM_PHY_MODEL(phydev)) {
> case PHY_ID_BCM54210E:
> @@ -949,6 +964,10 @@ struct bcm_ptp_private *bcm_ptp_probe(struct
> phy_device *phydev)
> priv->phydev = phydev;
> bcm_ptp_init(priv);
>
> + err = devm_add_action_or_reset(&phydev->mdio.dev, bcm_ptp_remove, priv);

Consider if it makes more sense to not use devm_.

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html

says:

Netdev remains skeptical about promises of all “auto-cleanup” APIs,
including even devm_ helpers, historically.

Andrew