Re: [PATCH 03/12] net: phy: add phy_device_set_miits helper

From: Andrew Lunn
Date: Wed Apr 05 2023 - 08:07:14 EST


> +void phy_device_set_miits(struct phy_device *phydev,
> + struct mii_timestamper *mii_ts)
> +{
> + if (!phydev)
> + return;
> +
> + if (phydev->mii_ts) {
> + phydev_dbg(phydev,
> + "MII timestamper already set -> skip set\n");
> + return;
> + }
> +
> + phydev->mii_ts = mii_ts;
> +}

We tend to be less paranoid. Few, if any, other functions test that
phydev is not NULL. And the current code allows overwriting of an
existing stamper. If you think overwriting should not be allowed
return -EINVAL, and change all the callers to test for it.

> +EXPORT_SYMBOL(phy_device_set_miits);

_GPL please. The code is a bit inconsistent, but new symbols should be
EXPORT_SYMBOL_GPL.

I do however like this patch, hiding away the internals of phydev.

Andrew