[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170601130527.GG9282@lunn.ch>
Date: Thu, 1 Jun 2017 15:05:27 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Russell King - ARM Linux <linux@...linux.org.uk>
Cc: Florian Fainelli <f.fainelli@...il.com>, netdev@...r.kernel.org
Subject: Re: [PATCH 2/5] net: phy: hook up clause 45 autonegotiation restart
> > > +/**
> > > + * phy_restart_aneg - restart auto-negotiation
> > > + * @phydev: target phy_device struct
> > > + *
> > > + * Restart the autonegotiation on @phydev. Returns >= 0 on success or
> > > + * negative errno on error.
> > > + */
> > > +int phy_restart_aneg(struct phy_device *phydev)
> > > +{
> > > + int ret;
> > > +
> > > + if (phydev->is_c45)
> > > + ret = genphy_c45_restart_aneg(phydev);
> > > + else
> > > + ret = genphy_restart_aneg(phydev);
> > > +
> > > + return ret;
> > > +}
> > > +EXPORT_SYMBOL_GPL(phy_restart_aneg);
> >
> > Hi Russell
> >
> > Isn't the same sort of thing needed in phy_aneg_done()?
>
> No, because phy_aneg_done() already has hooks in it which PHY drivers
> can use to override the default C22 implementation.
>
> I did toy with providing a similar conditional in phy_aneg_done(), but
> decided it was better to use the existing hooks where present, rather
> than needlessly adding additional code.
Hi Russell
So you are saying a 10G PHY driver always needs to have a aneg_done
callback, even if it just needs to call phygen_c45_aneg_done?
This seems a bit error prone. I can see somebody writing a 10G driver,
leaving out aneg_done() and having the c22 version called. Is the read
of MII_BMSR likely to return 0xffff, since the register does not
exist? If so, genphy_aneg_done() is likely to always return
BMSR_ANEGCOMPLETE.
Seems like a trap waiting for somebody to fall into it. The additional
code might be worth it to avoid placing this trap.
Andrew
Powered by blists - more mailing lists