Re: [PATCH 03/12] net: phy: add phy_device_set_miits helper
From: Marco Felsch
Date: Wed Apr 05 2023 - 10:50:44 EST
On 23-04-05, Andrew Lunn wrote:
> > +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.
I can drop the 'if (!phydev)' check if you want. Return -EINVAL is
possible too.
> > +EXPORT_SYMBOL(phy_device_set_miits);
>
> _GPL please. The code is a bit inconsistent, but new symbols should be
> EXPORT_SYMBOL_GPL.
Sure! Don't know why I added it as EXPORT_SYMBOL in the first place.
> I do however like this patch, hiding away the internals of phydev.
Thanks for the fast response.
Regards,
Marco
>
> Andrew
>